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
.jface
.action
.Separator
;
16 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
17 import org
.eclipse
.ui
.IWorkbenchWindow
;
18 import org
.eclipse
.ui
.actions
.ActionFactory
;
19 import org
.eclipse
.ui
.actions
.ActionFactory
.IWorkbenchAction
;
20 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
21 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
23 import eu
.etaxonomy
.taxeditor
.actions
.ActionOpenNameEditor
;
26 * An action bar advisor is responsible for creating, adding, and disposing of
27 * the actions added to a workbench window. Each window will be populated with
34 public class ApplicationActionBarAdvisor
extends ActionBarAdvisor
{
35 private static final Logger logger
= Logger
36 .getLogger(ApplicationActionBarAdvisor
.class);
38 // Actions - important to allocate these only in makeActions, and then use
39 // them 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(null);
70 register(newNameAction
);
72 preferencesAction
= ActionFactory
.PREFERENCES
.create(window
);
75 protected void fillMenuBar(IMenuManager menuBar
) {
76 MenuManager fileMenu
= new MenuManager("&File",
78 // Note: to hook into Eclipse File Menu, to use open File for instance,
79 // replace NULL with IWorkbenchActionConstants.M_FILE);
81 menuBar
.add(fileMenu
);
82 fileMenu
.add(newNameAction
);
83 fileMenu
.add(saveAction
);
84 fileMenu
.add(undoAction
);
85 fileMenu
.add(new Separator());
86 fileMenu
.add(exitAction
);
88 MenuManager preferencesMenu
= new MenuManager("&Preferences",
90 menuBar
.add(preferencesMenu
);
91 preferencesMenu
.add(preferencesAction
);