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 java
.util
.List
;
14 import org
.apache
.log4j
.Logger
;
15 import org
.eclipse
.jface
.action
.IAction
;
16 import org
.eclipse
.jface
.action
.IMenuManager
;
17 import org
.eclipse
.jface
.action
.MenuManager
;
18 import org
.eclipse
.jface
.action
.Separator
;
19 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
20 import org
.eclipse
.ui
.IWorkbenchWindow
;
21 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
22 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
24 import eu
.etaxonomy
.taxeditor
.actions
.TaxEditorActionFactory
;
25 import eu
.etaxonomy
.taxeditor
.actions
.io
.ExportAction
;
26 import eu
.etaxonomy
.taxeditor
.controller
.GlobalController
;
29 * An action bar advisor is responsible for creating, adding, and disposing of
30 * the actions added to a workbench window. Each window will be populated with
37 public class ApplicationActionBarAdvisor
extends ActionBarAdvisor
{
38 private static final Logger logger
= Logger
39 .getLogger(ApplicationActionBarAdvisor
.class);
41 protected void makeActions(final IWorkbenchWindow window
) {
42 GlobalController
.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
45 protected void fillMenuBar(IMenuManager menuBar
) {
48 // Actions - important to allocate these only in makeActions, and then use
49 // them in the fill methods. This ensures that the actions aren't recreated
50 // when fillActionBars is called with FILL_PROXY.
51 // private IWorkbenchAction exitAction;
52 // private IWorkbenchAction saveAction;
53 // private IWorkbenchAction preferencesAction;
54 // private IWorkbenchAction undoAction;
55 // private IWorkbenchAction redoAction;
57 // private IAction newNameAction;
59 private List
<IAction
> importActionList
;
61 private IAction exportJaxbAction
;
64 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer
) {
68 protected void _makeActions(final IWorkbenchWindow window
) {
69 // Creates the actions and registers them.
70 // Registering is needed to ensure that key bindings work.
71 // The corresponding commands keybindings are defined in the plugin.xml
73 // Registering also provides automatic disposal of the actions when
74 // the window is closed.
76 GlobalController
.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
79 register(TaxEditorActionFactory
.NEW
.create(window
));
80 register(TaxEditorActionFactory
.SAVE
.create(window
));
81 register(TaxEditorActionFactory
.QUIT
.create(window
));
84 register(TaxEditorActionFactory
.UNDO
.create(window
));
85 register(TaxEditorActionFactory
.REDO
.create(window
));
86 register(TaxEditorActionFactory
.CUT
.create(window
));
87 register(TaxEditorActionFactory
.COPY
.create(window
));
88 register(TaxEditorActionFactory
.PASTE
.create(window
));
89 register(TaxEditorActionFactory
.DELETE
.create(window
));
91 // Window menu actions
92 register(TaxEditorActionFactory
.PREFERENCES
.create(window
));
95 register(TaxEditorActionFactory
.ABOUT
.create(window
));
101 exportJaxbAction
= new ExportAction(ExportAction
.JAXB
);
102 register(exportJaxbAction
);
106 private void makeImportActions() {
108 // importActionList = new ArrayList<IAction>();
110 // for (ImportWrapper wrapper : ImportWrapper.list()) {
111 // IAction importAction = new ImportAction(wrapper);
112 // register(importAction);
113 // importActionList.add(importAction);
117 private MenuManager
FILE_MENU(){
118 MenuManager fileMenu
= new MenuManager("&File",
119 IWorkbenchActionConstants
.M_FILE
);
121 // Create submenu for imports
122 MenuManager importMenu
= new MenuManager("Import ...", null);
124 // Create submenu for exports
125 MenuManager exportMenu
= new MenuManager("Export as ...", null);
127 // Populate file menu
128 fileMenu
.add(getAction(TaxEditorActionFactory
.NEW
.getId()));
129 fileMenu
.add(getAction(TaxEditorActionFactory
.SAVE
.getId()));
130 fileMenu
.add(new Separator());
131 fileMenu
.add(importMenu
);
132 fileMenu
.add(exportMenu
);
133 fileMenu
.add(new Separator());
134 fileMenu
.add(getAction(TaxEditorActionFactory
.QUIT
.getId()));
136 // Populate submenu for imports
137 for (IAction importAction
: importActionList
) {
138 importMenu
.add(importAction
);
141 // Populate submenu for exports
142 exportMenu
.add(exportJaxbAction
);
148 private MenuManager
EDIT_MENU() {
150 MenuManager editMenu
= new MenuManager("&Edit", IWorkbenchActionConstants
.M_EDIT
);
152 editMenu
.add(getAction(TaxEditorActionFactory
.UNDO
.getId()));
153 editMenu
.add(getAction(TaxEditorActionFactory
.REDO
.getId()));
154 editMenu
.add(new Separator());
155 editMenu
.add(getAction(TaxEditorActionFactory
.CUT
.getId()));
156 editMenu
.add(getAction(TaxEditorActionFactory
.COPY
.getId()));
157 editMenu
.add(getAction(TaxEditorActionFactory
.PASTE
.getId()));
158 editMenu
.add(new Separator());
159 editMenu
.add(getAction(TaxEditorActionFactory
.DELETE
.getId()));
164 private MenuManager
WINDOW_MENU() {
165 MenuManager windowMenu
= new MenuManager("&Window",
166 IWorkbenchActionConstants
.M_WINDOW
);
168 windowMenu
.add(getAction(TaxEditorActionFactory
.PREFERENCES
.getId()));
173 private MenuManager
HELP_MENU(){
174 MenuManager helpMenu
= new MenuManager("&Help",
175 IWorkbenchActionConstants
.M_HELP
);
177 helpMenu
.add(getAction(TaxEditorActionFactory
.ABOUT
.getId()));
182 protected void _fillMenuBar(IMenuManager menuBar
) {
184 menuBar
.add(FILE_MENU());
186 menuBar
.add(EDIT_MENU());
188 menuBar
.add(WINDOW_MENU());
190 menuBar
.add(HELP_MENU());