2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
;
12 import org
.apache
.log4j
.Logger
;
13 import org
.eclipse
.jface
.action
.IMenuManager
;
14 import org
.eclipse
.jface
.action
.MenuManager
;
15 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
16 import org
.eclipse
.ui
.IWorkbenchWindow
;
17 import org
.eclipse
.ui
.actions
.ActionFactory
;
18 import org
.eclipse
.ui
.actions
.ActionFactory
.IWorkbenchAction
;
19 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
20 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
22 import eu
.etaxonomy
.taxeditor
.actions
.ActionOpenNameEditor
;
25 * An action bar advisor is responsible for creating, adding, and disposing of
26 * the actions added to a workbench window. Each window will be populated with
33 public class ApplicationActionBarAdvisor
extends ActionBarAdvisor
{
34 private static final Logger logger
= Logger
35 .getLogger(ApplicationActionBarAdvisor
.class);
37 // Actions - important to allocate these only in makeActions, and then use
39 // in the fill methods. This ensures that the actions aren't recreated
40 // when fillActionBars is called with FILL_PROXY.
41 private IWorkbenchAction exitAction
;
42 private ActionOpenNameEditor newNameAction
;
43 private IWorkbenchAction saveAction
;
44 private IWorkbenchAction preferencesAction
;
45 private IWorkbenchAction undoAction
;
47 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer
) {
51 protected void makeActions(final IWorkbenchWindow window
) {
52 // Creates the actions and registers them.
53 // Registering is needed to ensure that key bindings work.
54 // The corresponding commands keybindings are defined in the plugin.xml
56 // Registering also provides automatic disposal of the actions when
57 // the window is closed.
59 saveAction
= ActionFactory
.SAVE
.create(window
);
62 undoAction
= ActionFactory
.UNDO
.create(window
);
63 // undoAction.setEnabled(true);
66 exitAction
= ActionFactory
.QUIT
.create(window
);
69 newNameAction
= new ActionOpenNameEditor();
70 register(newNameAction
);
72 preferencesAction
= ActionFactory
.PREFERENCES
.create(window
);
75 protected void fillMenuBar(IMenuManager menuBar
) {
76 MenuManager fileMenu
= new MenuManager("&File",
77 IWorkbenchActionConstants
.M_FILE
);
78 menuBar
.add(fileMenu
);
79 fileMenu
.add(newNameAction
);
80 fileMenu
.add(saveAction
);
81 fileMenu
.add(undoAction
);
82 fileMenu
.add(exitAction
);
84 MenuManager preferencesMenu
= new MenuManager("&Preferences",
86 menuBar
.add(preferencesMenu
);
87 preferencesMenu
.add(preferencesAction
);