p2izing the editor
[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 java.util.List;
13
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;
23
24 import eu.etaxonomy.taxeditor.actions.TaxEditorActionFactory;
25 import eu.etaxonomy.taxeditor.actions.io.ExportAction;
26 import eu.etaxonomy.taxeditor.controller.GlobalController;
27
28 /**
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
31 * new actions.
32 *
33 * @author p.ciardelli
34 * @created 02.06.2008
35 * @version 1.0
36 */
37 public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
38 private static final Logger logger = Logger
39 .getLogger(ApplicationActionBarAdvisor.class);
40
41 private List<IAction> importActionList;
42
43 private IAction exportJaxbAction;
44
45
46 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
47 super(configurer);
48 }
49
50 protected void makeActions(final IWorkbenchWindow window) {
51 GlobalController.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
52 }
53
54 protected void fillMenuBar(IMenuManager menuBar) {
55 }
56
57
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;
66 //
67 // private IAction newNameAction;
68
69
70 @Deprecated
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
75 // file.
76 // Registering also provides automatic disposal of the actions when
77 // the window is closed.
78
79 GlobalController.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
80
81 // File menu actions
82 register(TaxEditorActionFactory.NEW.create(window));
83 register(TaxEditorActionFactory.SAVE.create(window));
84 register(TaxEditorActionFactory.QUIT.create(window));
85
86 // Edit menu actions
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));
93
94 // Window menu actions
95 register(TaxEditorActionFactory.PREFERENCES.create(window));
96
97 // Help menu actions
98 register(TaxEditorActionFactory.ABOUT.create(window));
99
100
101
102 makeImportActions();
103
104 exportJaxbAction = new ExportAction(ExportAction.JAXB);
105 register(exportJaxbAction);
106 }
107
108 @Deprecated
109 private void makeImportActions() {
110
111 // importActionList = new ArrayList<IAction>();
112 //
113 // for (ImportWrapper wrapper : ImportWrapper.list()) {
114 // IAction importAction = new ImportAction(wrapper);
115 // register(importAction);
116 // importActionList.add(importAction);
117 // }
118 }
119
120 @Deprecated
121 private MenuManager FILE_MENU(){
122 MenuManager fileMenu = new MenuManager("&File",
123 IWorkbenchActionConstants.M_FILE);
124
125 // Create submenu for imports
126 MenuManager importMenu = new MenuManager("Import ...", null);
127
128 // Create submenu for exports
129 MenuManager exportMenu = new MenuManager("Export as ...", null);
130
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()));
139
140 // Populate submenu for imports
141 for (IAction importAction : importActionList) {
142 importMenu.add(importAction);
143 }
144
145 // Populate submenu for exports
146 exportMenu.add(exportJaxbAction);
147
148 return fileMenu;
149 }
150
151 @Deprecated
152 private MenuManager EDIT_MENU() {
153
154 MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
155
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()));
164
165 return editMenu;
166 }
167
168 @Deprecated
169 private MenuManager WINDOW_MENU() {
170 MenuManager windowMenu = new MenuManager("&Window",
171 IWorkbenchActionConstants.M_WINDOW);
172
173 windowMenu.add(getAction(TaxEditorActionFactory.PREFERENCES.getId()));
174
175 return windowMenu;
176 }
177
178 @Deprecated
179 private MenuManager HELP_MENU(){
180 MenuManager helpMenu = new MenuManager("&Help",
181 IWorkbenchActionConstants.M_HELP);
182
183 helpMenu.add(getAction(TaxEditorActionFactory.ABOUT.getId()));
184
185 return helpMenu;
186 }
187
188 @Deprecated
189 protected void _fillMenuBar(IMenuManager menuBar) {
190
191 menuBar.add(FILE_MENU());
192
193 menuBar.add(EDIT_MENU());
194
195 menuBar.add(WINDOW_MENU());
196
197 menuBar.add(HELP_MENU());
198 }
199 }