+/**
+* Copyright (C) 2007 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+
package eu.etaxonomy.taxeditor;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
-import eu.etaxonomy.taxeditor.controller.ActionOpenNameEditor;
+import eu.etaxonomy.cdm.io.common.ImportWrapper;
+import eu.etaxonomy.taxeditor.actions.TaxEditorActionFactory;
+import eu.etaxonomy.taxeditor.actions.io.ExportAction;
+import eu.etaxonomy.taxeditor.actions.io.ImportAction;
+import eu.etaxonomy.taxeditor.controller.GlobalController;
/**
* An action bar advisor is responsible for creating, adding, and disposing of
* the actions added to a workbench window. Each window will be populated with
* new actions.
+ *
+ * @author p.ciardelli
+ * @created 02.06.2008
+ * @version 1.0
*/
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
+ private static final Logger logger = Logger
+ .getLogger(ApplicationActionBarAdvisor.class);
+
+ protected void makeActions(final IWorkbenchWindow window) {
+ GlobalController.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
+ }
+ protected void fillMenuBar(IMenuManager menuBar) {
+ }
+
// Actions - important to allocate these only in makeActions, and then use
- // them
- // in the fill methods. This ensures that the actions aren't recreated
+ // them in the fill methods. This ensures that the actions aren't recreated
// when fillActionBars is called with FILL_PROXY.
- private IWorkbenchAction exitAction;
- private ActionOpenNameEditor newNameAction;
+// private IWorkbenchAction exitAction;
+// private IWorkbenchAction saveAction;
+// private IWorkbenchAction preferencesAction;
+// private IWorkbenchAction undoAction;
+// private IWorkbenchAction redoAction;
+//
+// private IAction newNameAction;
+
+ private List<IAction> importActionList;
+
+ private IAction exportJaxbAction;
+
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}
- protected void makeActions(final IWorkbenchWindow window) {
+ protected void _makeActions(final IWorkbenchWindow window) {
// Creates the actions and registers them.
// Registering is needed to ensure that key bindings work.
// The corresponding commands keybindings are defined in the plugin.xml
// file.
// Registering also provides automatic disposal of the actions when
// the window is closed.
-
- exitAction = ActionFactory.QUIT.create(window);
- register(exitAction);
- newNameAction = new ActionOpenNameEditor();
- register(newNameAction);
+ GlobalController.setStatusLineManager(getActionBarConfigurer().getStatusLineManager());
+
+ // File menu actions
+ register(TaxEditorActionFactory.NEW.create(window));
+ register(TaxEditorActionFactory.SAVE.create(window));
+ register(TaxEditorActionFactory.QUIT.create(window));
+
+ // Edit menu actions
+ register(TaxEditorActionFactory.UNDO.create(window));
+ register(TaxEditorActionFactory.REDO.create(window));
+ register(TaxEditorActionFactory.CUT.create(window));
+ register(TaxEditorActionFactory.COPY.create(window));
+ register(TaxEditorActionFactory.PASTE.create(window));
+ register(TaxEditorActionFactory.DELETE.create(window));
+
+ // Window menu actions
+ register(TaxEditorActionFactory.PREFERENCES.create(window));
+
+ // Help menu actions
+ register(TaxEditorActionFactory.ABOUT.create(window));
+
+
+
+ makeImportActions();
+
+ exportJaxbAction = new ExportAction(ExportAction.JAXB);
+ register(exportJaxbAction);
}
- protected void fillMenuBar(IMenuManager menuBar) {
+
+ private void makeImportActions() {
+
+ importActionList = new ArrayList<IAction>();
+
+ for (ImportWrapper wrapper : ImportWrapper.list()) {
+ IAction importAction = new ImportAction(wrapper);
+ register(importAction);
+ importActionList.add(importAction);
+ }
+ }
+
+ private MenuManager FILE_MENU(){
MenuManager fileMenu = new MenuManager("&File",
IWorkbenchActionConstants.M_FILE);
- menuBar.add(fileMenu);
- fileMenu.add(newNameAction);
- fileMenu.add(exitAction);
+
+ // Create submenu for imports
+ MenuManager importMenu = new MenuManager("Import ...", null);
+
+ // Create submenu for exports
+ MenuManager exportMenu = new MenuManager("Export as ...", null);
+
+ // Populate file menu
+ fileMenu.add(getAction(TaxEditorActionFactory.NEW.getId()));
+ fileMenu.add(getAction(TaxEditorActionFactory.SAVE.getId()));
+ fileMenu.add(new Separator());
+ fileMenu.add(importMenu);
+ fileMenu.add(exportMenu);
+ fileMenu.add(new Separator());
+ fileMenu.add(getAction(TaxEditorActionFactory.QUIT.getId()));
+
+ // Populate submenu for imports
+ for (IAction importAction : importActionList) {
+ importMenu.add(importAction);
+ }
+
+ // Populate submenu for exports
+ exportMenu.add(exportJaxbAction);
+
+ return fileMenu;
+ }
+
+
+ private MenuManager EDIT_MENU() {
+
+ MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
+
+ editMenu.add(getAction(TaxEditorActionFactory.UNDO.getId()));
+ editMenu.add(getAction(TaxEditorActionFactory.REDO.getId()));
+ editMenu.add(new Separator());
+ editMenu.add(getAction(TaxEditorActionFactory.CUT.getId()));
+ editMenu.add(getAction(TaxEditorActionFactory.COPY.getId()));
+ editMenu.add(getAction(TaxEditorActionFactory.PASTE.getId()));
+ editMenu.add(new Separator());
+ editMenu.add(getAction(TaxEditorActionFactory.DELETE.getId()));
+
+ return editMenu;
}
-}
+ private MenuManager WINDOW_MENU() {
+ MenuManager windowMenu = new MenuManager("&Window",
+ IWorkbenchActionConstants.M_WINDOW);
+
+ windowMenu.add(getAction(TaxEditorActionFactory.PREFERENCES.getId()));
+
+ return windowMenu;
+ }
+
+ private MenuManager HELP_MENU(){
+ MenuManager helpMenu = new MenuManager("&Help",
+ IWorkbenchActionConstants.M_HELP);
+
+ helpMenu.add(getAction(TaxEditorActionFactory.ABOUT.getId()));
+
+ return helpMenu;
+ }
+
+ protected void _fillMenuBar(IMenuManager menuBar) {
+
+ menuBar.add(FILE_MENU());
+
+ menuBar.add(EDIT_MENU());
+
+ menuBar.add(WINDOW_MENU());
+
+ menuBar.add(HELP_MENU());
+ }
+}
\ No newline at end of file