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 private List
<IAction
> importActionList
;
43 private IAction exportJaxbAction
;
46 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer
) {
50 protected void makeActions(final IWorkbenchWindow window
) {
51 GlobalController
.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
54 protected void fillMenuBar(IMenuManager menuBar
) {
58 // Actions - important to allocate these only in makeActions, and then use
59 // them in the fill methods. This ensures that the actions aren't recreated
60 // when fillActionBars is called with FILL_PROXY.
61 // private IWorkbenchAction exitAction;
62 // private IWorkbenchAction saveAction;
63 // private IWorkbenchAction preferencesAction;
64 // private IWorkbenchAction undoAction;
65 // private IWorkbenchAction redoAction;
67 // private IAction newNameAction;
71 protected void _makeActions(final IWorkbenchWindow window
) {
72 // Creates the actions and registers them.
73 // Registering is needed to ensure that key bindings work.
74 // The corresponding commands keybindings are defined in the plugin.xml
76 // Registering also provides automatic disposal of the actions when
77 // the window is closed.
79 GlobalController
.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
82 register(TaxEditorActionFactory
.NEW
.create(window
));
83 register(TaxEditorActionFactory
.SAVE
.create(window
));
84 register(TaxEditorActionFactory
.QUIT
.create(window
));
87 register(TaxEditorActionFactory
.UNDO
.create(window
));
88 register(TaxEditorActionFactory
.REDO
.create(window
));
89 register(TaxEditorActionFactory
.CUT
.create(window
));
90 register(TaxEditorActionFactory
.COPY
.create(window
));
91 register(TaxEditorActionFactory
.PASTE
.create(window
));
92 register(TaxEditorActionFactory
.DELETE
.create(window
));
94 // Window menu actions
95 register(TaxEditorActionFactory
.PREFERENCES
.create(window
));
98 register(TaxEditorActionFactory
.ABOUT
.create(window
));
104 exportJaxbAction
= new ExportAction(ExportAction
.JAXB
);
105 register(exportJaxbAction
);
109 private void makeImportActions() {
111 // importActionList = new ArrayList<IAction>();
113 // for (ImportWrapper wrapper : ImportWrapper.list()) {
114 // IAction importAction = new ImportAction(wrapper);
115 // register(importAction);
116 // importActionList.add(importAction);
121 private MenuManager
FILE_MENU(){
122 MenuManager fileMenu
= new MenuManager("&File",
123 IWorkbenchActionConstants
.M_FILE
);
125 // Create submenu for imports
126 MenuManager importMenu
= new MenuManager("Import ...", null);
128 // Create submenu for exports
129 MenuManager exportMenu
= new MenuManager("Export as ...", null);
131 // Populate file menu
132 fileMenu
.add(getAction(TaxEditorActionFactory
.NEW
.getId()));
133 fileMenu
.add(getAction(TaxEditorActionFactory
.SAVE
.getId()));
134 fileMenu
.add(new Separator());
135 fileMenu
.add(importMenu
);
136 fileMenu
.add(exportMenu
);
137 fileMenu
.add(new Separator());
138 fileMenu
.add(getAction(TaxEditorActionFactory
.QUIT
.getId()));
140 // Populate submenu for imports
141 for (IAction importAction
: importActionList
) {
142 importMenu
.add(importAction
);
145 // Populate submenu for exports
146 exportMenu
.add(exportJaxbAction
);
152 private MenuManager
EDIT_MENU() {
154 MenuManager editMenu
= new MenuManager("&Edit", IWorkbenchActionConstants
.M_EDIT
);
156 editMenu
.add(getAction(TaxEditorActionFactory
.UNDO
.getId()));
157 editMenu
.add(getAction(TaxEditorActionFactory
.REDO
.getId()));
158 editMenu
.add(new Separator());
159 editMenu
.add(getAction(TaxEditorActionFactory
.CUT
.getId()));
160 editMenu
.add(getAction(TaxEditorActionFactory
.COPY
.getId()));
161 editMenu
.add(getAction(TaxEditorActionFactory
.PASTE
.getId()));
162 editMenu
.add(new Separator());
163 editMenu
.add(getAction(TaxEditorActionFactory
.DELETE
.getId()));
169 private MenuManager
WINDOW_MENU() {
170 MenuManager windowMenu
= new MenuManager("&Window",
171 IWorkbenchActionConstants
.M_WINDOW
);
173 windowMenu
.add(getAction(TaxEditorActionFactory
.PREFERENCES
.getId()));
179 private MenuManager
HELP_MENU(){
180 MenuManager helpMenu
= new MenuManager("&Help",
181 IWorkbenchActionConstants
.M_HELP
);
183 helpMenu
.add(getAction(TaxEditorActionFactory
.ABOUT
.getId()));
189 protected void _fillMenuBar(IMenuManager menuBar
) {
191 menuBar
.add(FILE_MENU());
193 menuBar
.add(EDIT_MENU());
195 menuBar
.add(WINDOW_MENU());
197 menuBar
.add(HELP_MENU());