source: trunk/de.ugoe.cs.swe.exercises/src/de/ugoe/cs/swe/exercises/ApplicationActionBarAdvisor.java @ 3

Last change on this file since 3 was 3, checked in by zeiss, 15 years ago
  • Property svn:mime-type set to text/plain
File size: 1.8 KB
Line 
1package de.ugoe.cs.swe.exercises;
2
3import org.eclipse.jface.action.IMenuManager;
4import org.eclipse.jface.action.MenuManager;
5import org.eclipse.ui.IWorkbenchWindow;
6import org.eclipse.ui.actions.ActionFactory;
7import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
8import org.eclipse.ui.application.ActionBarAdvisor;
9import org.eclipse.ui.application.IActionBarConfigurer;
10
11/**
12 * An action bar advisor is responsible for creating, adding, and disposing of
13 * the actions added to a workbench window. Each window will be populated with
14 * new actions.
15 */
16public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
17
18        // Actions - important to allocate these only in makeActions, and then use
19        // them
20        // in the fill methods. This ensures that the actions aren't recreated
21        // when fillActionBars is called with FILL_PROXY.
22        private IWorkbenchAction exitAction;
23    private IWorkbenchAction aboutAction;
24   
25        public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
26                super(configurer);
27        }
28
29
30
31        @Override
32        protected void makeActions(final IWorkbenchWindow window) {
33                // Creates the actions and registers them.
34                // Registering is needed to ensure that key bindings work.
35                // The corresponding commands keybindings are defined in the plugin.xml
36                // file.
37                // Registering also provides automatic disposal of the actions when
38                // the window is closed.
39
40                exitAction = ActionFactory.QUIT.create(window);
41                register(exitAction);
42                aboutAction = ActionFactory.ABOUT.create(window);
43                aboutAction.setText("About");
44                register(aboutAction);
45        }
46
47        @Override
48        protected void fillMenuBar(IMenuManager menuBar) {
49                MenuManager fileMenu = new MenuManager("&File");
50                menuBar.add(fileMenu);
51                fileMenu.add(aboutAction);
52                fileMenu.add(exitAction);
53
54                //MenuManager helpMenu = new MenuManager("&Help");
55                //menuBar.add(helpMenu);
56               
57        }
58
59}
Note: See TracBrowser for help on using the repository browser.