1 package eu
.etaxonomy
.taxeditor
;
3 import org
.eclipse
.jface
.action
.Action
;
4 import org
.eclipse
.jface
.action
.GroupMarker
;
5 import org
.eclipse
.jface
.action
.ICoolBarManager
;
6 import org
.eclipse
.jface
.action
.IMenuManager
;
7 import org
.eclipse
.jface
.action
.IToolBarManager
;
8 import org
.eclipse
.jface
.action
.MenuManager
;
9 import org
.eclipse
.jface
.action
.Separator
;
10 import org
.eclipse
.jface
.action
.ToolBarContributionItem
;
11 import org
.eclipse
.jface
.action
.ToolBarManager
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
14 import org
.eclipse
.ui
.IWorkbenchWindow
;
15 import org
.eclipse
.ui
.actions
.ActionFactory
;
16 import org
.eclipse
.ui
.actions
.ActionFactory
.IWorkbenchAction
;
17 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
18 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
21 * An action bar advisor is responsible for creating, adding, and disposing of the
22 * actions added to a workbench window. Each window will be populated with
25 public class ApplicationActionBarAdvisor
extends ActionBarAdvisor
{
27 // Actions - important to allocate these only in makeActions, and then use them
28 // in the fill methods. This ensures that the actions aren't recreated
29 // when fillActionBars is called with FILL_PROXY.
30 private IWorkbenchAction exitAction
;
31 private IWorkbenchAction aboutAction
;
32 private IWorkbenchAction newWindowAction
;
33 private OpenViewAction openViewAction
;
34 private Action messagePopupAction
;
37 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer
) {
41 protected void makeActions(final IWorkbenchWindow window
) {
42 // Creates the actions and registers them.
43 // Registering is needed to ensure that key bindings work.
44 // The corresponding commands keybindings are defined in the plugin.xml file.
45 // Registering also provides automatic disposal of the actions when
46 // the window is closed.
48 exitAction
= ActionFactory
.QUIT
.create(window
);
51 aboutAction
= ActionFactory
.ABOUT
.create(window
);
52 register(aboutAction
);
54 newWindowAction
= ActionFactory
.OPEN_NEW_WINDOW
.create(window
);
55 register(newWindowAction
);
57 openViewAction
= new OpenViewAction(window
, "Open Another Message View", View
.ID
);
58 register(openViewAction
);
60 messagePopupAction
= new MessagePopupAction("Open Message", window
);
61 register(messagePopupAction
);
64 protected void fillMenuBar(IMenuManager menuBar
) {
65 MenuManager fileMenu
= new MenuManager("&File", IWorkbenchActionConstants
.M_FILE
);
66 MenuManager helpMenu
= new MenuManager("&Help", IWorkbenchActionConstants
.M_HELP
);
68 menuBar
.add(fileMenu
);
69 // Add a group marker indicating where action set menus will appear.
70 menuBar
.add(new GroupMarker(IWorkbenchActionConstants
.MB_ADDITIONS
));
71 menuBar
.add(helpMenu
);
74 fileMenu
.add(newWindowAction
);
75 fileMenu
.add(new Separator());
76 fileMenu
.add(messagePopupAction
);
77 fileMenu
.add(openViewAction
);
78 fileMenu
.add(new Separator());
79 fileMenu
.add(exitAction
);
82 helpMenu
.add(aboutAction
);
85 protected void fillCoolBar(ICoolBarManager coolBar
) {
86 IToolBarManager toolbar
= new ToolBarManager(SWT
.FLAT
| SWT
.RIGHT
);
87 coolBar
.add(new ToolBarContributionItem(toolbar
, "main"));
88 toolbar
.add(openViewAction
);
89 toolbar
.add(messagePopupAction
);