Got rid of "open file" menu item by replacing:
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / ApplicationActionBarAdvisor.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor;
11
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;
22
23 import eu.etaxonomy.taxeditor.actions.ActionOpenNameEditor;
24
25 /**
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
28 * new actions.
29 *
30 * @author p.ciardelli
31 * @created 02.06.2008
32 * @version 1.0
33 */
34 public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
35 private static final Logger logger = Logger
36 .getLogger(ApplicationActionBarAdvisor.class);
37
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;
46
47 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
48 super(configurer);
49 }
50
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
55 // file.
56 // Registering also provides automatic disposal of the actions when
57 // the window is closed.
58
59 saveAction = ActionFactory.SAVE.create(window);
60 register(saveAction);
61
62 undoAction = ActionFactory.UNDO.create(window);
63 // undoAction.setEnabled(true);
64 register(undoAction);
65
66 exitAction = ActionFactory.QUIT.create(window);
67 register(exitAction);
68
69 newNameAction = new ActionOpenNameEditor(null);
70 register(newNameAction);
71
72 preferencesAction = ActionFactory.PREFERENCES.create(window);
73 }
74
75 protected void fillMenuBar(IMenuManager menuBar) {
76 MenuManager fileMenu = new MenuManager("&File",
77 null);
78 // Note: to hook into Eclipse File Menu, to use open File for instance,
79 // replace NULL with IWorkbenchActionConstants.M_FILE);
80
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);
87
88 MenuManager preferencesMenu = new MenuManager("&Preferences",
89 null);
90 menuBar.add(preferencesMenu);
91 preferencesMenu.add(preferencesAction);
92 }
93
94 }