From cd614957c250f380d72ba62c918614d3d1662901 Mon Sep 17 00:00:00 2001 From: "n.hoffmann" Date: Thu, 5 Feb 2009 10:24:07 +0000 Subject: [PATCH] started to refactor action delegation --- .gitattributes | 21 ++- .../META-INF/MANIFEST.MF | 4 +- .../eu.etaxonomy.taxeditor/plugin.xml | 3 +- .../ApplicationActionBarAdvisor.java | 122 ++++++++++------ .../actions/TaxEditorActionFactory.java | 61 ++++++++ .../cdm/SwapSynonymAndTaxonAction.java | 9 +- .../name/ChangeConceptRelationAction.java | 66 +++++++++ .../ChangeSynonymToConceptRelationAction.java | 62 ++++++++ .../ChangeSynonymToMisapplicationAction.java | 58 ++++++++ .../actions/name/CreateAutonymAction.java | 42 ++++++ .../name/CreateConceptRelationAction.java | 20 +-- .../name/CreateHeterotypicSynonymAction.java | 50 +++++++ .../name/CreateMisappliedNameAction.java | 11 +- .../name/CreateNewTaxonFromSynonymAction.java | 59 ++++++++ .../name/CreateSynonymInGroupAction.java | 52 +++++++ ...reateTaxonomicallyIncludedTaxonAction.java | 56 +++++++ .../actions/name/MakeBasionymAction.java | 52 +++++++ .../{editor => actions}/name/Messages.java | 4 +- .../actions/name/RemoveConceptAction.java | 64 ++++++++ .../actions/name/RemoveSynonymAction.java | 59 ++++++++ .../actions/name/UnmakeBasionymAction.java | 55 +++++++ .../name/messages.properties | 0 .../ui/ChangeTaxonToSynonymAction.java | 15 +- .../actions/ui/MoveTaxonDialogAction.java | 15 +- .../actions/ui/OpenTaxonEditorAction.java | 35 ++--- .../controller/EditorController.java | 18 ++- .../controller/GlobalController.java | 2 +- .../taxeditor/editor/ContextMenu.java | 28 +++- .../taxeditor/editor/MenuConstants.java | 62 ++++++++ .../editor/MultiPageTaxonEditor.java | 6 +- ...tiPageTaxonEditorActionBarContributor.java | 51 +++++++ .../editor/name/AcceptedNameComposite.java | 43 +++--- .../editor/name/ConceptComposite.java | 25 ++-- .../editor/name/MisappliedNameComposite.java | 19 +-- .../taxeditor/editor/name/NameComposite.java | 1 + .../editor/name/SynonymComposite.java | 137 +++--------------- .../model/CdmSessionDataRepository.java | 2 +- .../name/ChangeConceptRelationOperation.java | 80 ++++++++++ ...mInExisitingHomotypicalGroupOperation.java | 92 ++++++++++++ 39 files changed, 1274 insertions(+), 287 deletions(-) create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/TaxEditorActionFactory.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeConceptRelationAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToConceptRelationAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToMisapplicationAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateAutonymAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateHeterotypicSynonymAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateNewTaxonFromSynonymAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateSynonymInGroupAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateTaxonomicallyIncludedTaxonAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/MakeBasionymAction.java rename eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/{editor => actions}/name/Messages.java (92%) create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveConceptAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveSynonymAction.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/UnmakeBasionymAction.java rename eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/{editor => actions}/name/messages.properties (100%) create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MenuConstants.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorActionBarContributor.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeConceptRelationOperation.java create mode 100644 eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateSynonymInExisitingHomotypicalGroupOperation.java diff --git a/.gitattributes b/.gitattributes index 56d865fc1..a3d364565 100644 --- a/.gitattributes +++ b/.gitattributes @@ -404,6 +404,7 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/TaxEditorPlugi eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/NameTransfer.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/SaveAllAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/SynonymRelationshipTransfer.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/TaxEditorActionFactory.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/TaxonTransfer.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/UndoableAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/WidgetTransfer.java -text @@ -415,8 +416,22 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/Sa eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ExportAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/io/ImportAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeConceptRelationAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToConceptRelationAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToMisapplicationAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateAutonymAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateConceptRelationAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateHeterotypicSynonymAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateMisappliedNameAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateNewTaxonFromSynonymAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateSynonymInGroupAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateTaxonomicallyIncludedTaxonAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/MakeBasionymAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/Messages.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveConceptAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveSynonymAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/UnmakeBasionymAction.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/messages.properties -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/ChangeTaxonToSynonymAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/MoveTaxonDialogAction.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/OpenNameRelationWizardAction.java -text @@ -455,7 +470,9 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/IParent eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/LineBreakListener.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/LineWrapSquigglesStrategy.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/LineWrapSupport.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MenuConstants.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorActionBarContributor.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/ParseListener.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/SelectTaxonDialog.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/SimpleSelectionProvider.java -text @@ -473,7 +490,6 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/Co eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/ConceptGroupComposite.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/HomotypicalGroupComposite.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/IterableSynonymyList.java -text -eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/Messages.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/MisappliedGroupComposite.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/MisappliedNameComposite.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameComposite.java -text @@ -481,7 +497,6 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/Na eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/RulerWithIcon.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/SynonymComposite.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/TaxonNameEditor.java -text -eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/messages.properties -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/io/InputWizard.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/io/InputWizard2.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmSessionDataRepository.java -text @@ -505,6 +520,7 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/Abs eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/ChangeTaxonToSynonymOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/DeleteTaxonOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/MoveTaxonOperation.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeConceptRelationOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeHomotypicGroupOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeMisappliedNameToSynonymOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeSynonymToConceptOperation.java -text @@ -512,6 +528,7 @@ eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/nam eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeSynonymToTaxonOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateConceptRelationOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateMisappliedNameOperation.java -text +eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateSynonymInExisitingHomotypicalGroupOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateSynonymInNewGroupOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/MakeSynonymAcceptedOperation.java -text eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/MakeSynonymGroupBasionymOperation.java -text diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/META-INF/MANIFEST.MF b/eclipseprojects/eu.etaxonomy.taxeditor/META-INF/MANIFEST.MF index 4f78f436c..cbaeabbac 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/META-INF/MANIFEST.MF +++ b/eclipseprojects/eu.etaxonomy.taxeditor/META-INF/MANIFEST.MF @@ -15,9 +15,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.ui.views, org.eclipse.pde.source, org.eclipse.ui.ide, - eu.etaxonomy.cdmLibrary, org.eclipse.ui.workbench.texteditor, - org.eclipse.ui.editors + org.eclipse.ui.editors, + eu.etaxonomy.cdmLibrary;bundle-version="2.0.0" Eclipse-LazyStart: true Export-Package: com.swtdesigner, eu.etaxonomy.taxeditor, diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/plugin.xml b/eclipseprojects/eu.etaxonomy.taxeditor/plugin.xml index e14b3027e..6aa97e586 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/plugin.xml +++ b/eclipseprojects/eu.etaxonomy.taxeditor/plugin.xml @@ -72,7 +72,8 @@ class="eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor" icon="icons/edit_16x16.gif" id="eu.etaxonomy.taxeditor.editor.multipagetaxonview" - name="Multitabbed Taxon Editor"> + name="Multitabbed Taxon Editor" + contributorClass="eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditorActionBarContributor"> importActionList; @@ -72,22 +71,26 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { GlobalController.setStatusLineManager(getActionBarConfigurer().getStatusLineManager()); - saveAction = ActionFactory.SAVE.create(window); - register(saveAction); + // File menu actions + register(TaxEditorActionFactory.NEW.create(window)); + register(TaxEditorActionFactory.SAVE.create(window)); + register(TaxEditorActionFactory.QUIT.create(window)); - undoAction = ActionFactory.UNDO.create(window); - register(undoAction); + // 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)); - redoAction = ActionFactory.REDO.create(window); - register(redoAction); + // Window menu actions + register(TaxEditorActionFactory.PREFERENCES.create(window)); - exitAction = ActionFactory.QUIT.create(window); - register(exitAction); + // Help menu actions + register(TaxEditorActionFactory.ABOUT.create(window)); - newNameAction = new OpenNewTaxonEditorAction(); - register(newNameAction); - preferencesAction = ActionFactory.PREFERENCES.create(window); makeImportActions(); @@ -95,6 +98,7 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { register(exportJaxbAction); } + private void makeImportActions() { importActionList = new ArrayList(); @@ -105,35 +109,25 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { importActionList.add(importAction); } } - - protected void fillMenuBar(IMenuManager menuBar) { - - // Note: to hook into Eclipse File Menu, to use open File for instance, - // replace NULL with IWorkbenchActionConstants.M_FILE); + + private MenuManager FILE_MENU(){ MenuManager fileMenu = new MenuManager("&File", - null); - - MenuManager editMenu = new MenuManager("&Edit", null); + IWorkbenchActionConstants.M_FILE); // Create submenu for imports MenuManager importMenu = new MenuManager("Import ...", null); // Create submenu for exports MenuManager exportMenu = new MenuManager("Export as ...", null); - + // Populate file menu - menuBar.add(fileMenu); - fileMenu.add(newNameAction); - fileMenu.add(saveAction); + 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(exitAction); - - menuBar.add(editMenu); - editMenu.add(undoAction); - editMenu.add(redoAction); + fileMenu.add(getAction(TaxEditorActionFactory.QUIT.getId())); // Populate submenu for imports for (IAction importAction : importActionList) { @@ -143,10 +137,52 @@ public class ApplicationActionBarAdvisor extends ActionBarAdvisor { // Populate submenu for exports exportMenu.add(exportJaxbAction); - // Populate preferences - MenuManager preferencesMenu = new MenuManager("&Preferences", - null); - menuBar.add(preferencesMenu); - preferencesMenu.add(preferencesAction); + 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 diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/TaxEditorActionFactory.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/TaxEditorActionFactory.java new file mode 100644 index 000000000..b2d9ec8c6 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/TaxEditorActionFactory.java @@ -0,0 +1,61 @@ +/** +* 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.actions; + +import org.apache.log4j.Logger; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.NewWizardAction; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; + +import eu.etaxonomy.taxeditor.actions.ui.OpenTaxonEditorAction; + +/** + * This class is an extension to the standard ActionFactory. Any useful + * functionality already implemented in ActionFactory may be used or + * overwritten by more suitable implementations. + * + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public abstract class TaxEditorActionFactory extends ActionFactory { + private static final Logger logger = Logger + .getLogger(TaxEditorActionFactory.class); + + /** + * Workbench action (id "new"): Opens the new wizard dialog. This action maintains + * its enablement state. + */ + public static final ActionFactory NEW = new ActionFactory("new") {//$NON-NLS-1$ + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionFactory#create(org.eclipse.ui.IWorkbenchWindow) + */ + public IWorkbenchAction create(IWorkbenchWindow window) { + if (window == null) { + throw new IllegalArgumentException(); + } + IWorkbenchAction action = new OpenTaxonEditorAction(); + action.setId(getId()); + return action; + } + }; + + /** + * Creates a new workbench action factory with the given id. + * + * @param actionId + * the id of actions created by this action factory + */ + protected TaxEditorActionFactory(String actionId) { + super(actionId); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java index cd88519b8..0d8024b9f 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/SwapSynonymAndTaxonAction.java @@ -38,13 +38,18 @@ public class SwapSynonymAndTaxonAction extends Action { .getLogger(SwapSynonymAndTaxonAction.class); private static String text = "Make synonym accepted name for this taxon"; - private ImageDescriptor image = TaxEditorPlugin.getDefault() + private static ImageDescriptor image = TaxEditorPlugin.getDefault() .getImageDescriptor(ITaxEditorConstants.SYNONYM_TO_TAXON_ICON); private Synonym synonym; private Taxon taxon; - public SwapSynonymAndTaxonAction(Synonym synonym, Taxon taxon) { + public SwapSynonymAndTaxonAction(){ + super(text, image); + } + + public SwapSynonymAndTaxonAction(Taxon taxon, Synonym synonym) { + this(); this.synonym = synonym; this.taxon = taxon; } diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeConceptRelationAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeConceptRelationAction.java new file mode 100644 index 000000000..517ad0e06 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeConceptRelationAction.java @@ -0,0 +1,66 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.ChangeConceptRelationOperation; +import eu.etaxonomy.taxeditor.operations.name.CreateConceptRelationOperation; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class ChangeConceptRelationAction extends Action { + + private static final Logger logger = Logger + .getLogger(ChangeConceptRelationAction.class); + + private static String text = "Change concept relation"; + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageRegistry().getDescriptor(ITaxEditorConstants.CONCEPT_ICON); + + private Taxon relatedTaxon; + + private Taxon taxon; + + private TaxonRelationshipType taxonRelationshipType; + + private ChangeConceptRelationAction(){ + super(text, image); + } + + public ChangeConceptRelationAction(Taxon taxon, Taxon relatedTaxon, + TaxonRelationshipType taxonRelationshipType) { + this(); + this.setText(taxonRelationshipType.getLabel()); + this.taxon = taxon; + this.relatedTaxon = relatedTaxon; + this.taxonRelationshipType = taxonRelationshipType; + } + + public void run() { + IUndoableOperation operation = new ChangeConceptRelationOperation( + "Create concept relation '" + taxonRelationshipType.getLabel() + "'", + EditorController.getUndoContext(taxon), taxon, relatedTaxon, taxonRelationshipType); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToConceptRelationAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToConceptRelationAction.java new file mode 100644 index 000000000..791a1f96c --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToConceptRelationAction.java @@ -0,0 +1,62 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToConceptOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class ChangeSynonymToConceptRelationAction extends Action { + + + private static final Logger logger = Logger + .getLogger(ChangeSynonymToConceptRelationAction.class); + + private static String text = "Change synonym to concept relation"; //$NON-NLS-1$ + + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.CONCEPT_ICON); + + private Synonym synonym; + + private Taxon taxon; + + private ChangeSynonymToConceptRelationAction() { + super(text, image); + } + + public ChangeSynonymToConceptRelationAction(Taxon taxon, Synonym synonym) { + this(); + this.taxon = taxon; + this.synonym = synonym; + } + + public void run() { + IUndoableOperation operation = new ChangeSynonymToConceptOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, synonym); + + GlobalController.executeOperation(operation); + } + +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToMisapplicationAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToMisapplicationAction.java new file mode 100644 index 000000000..b3341284d --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/ChangeSynonymToMisapplicationAction.java @@ -0,0 +1,58 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToMisappliedNameOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class ChangeSynonymToMisapplicationAction extends Action { + private static final Logger logger = Logger + .getLogger(ChangeSynonymToMisapplicationAction.class); + + private static String text = "Change synonym to misapplied name"; //$NON-NLS-1$ + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.MISAPPLIED_NAME_ICON); + + private Synonym synonym; + + private Taxon taxon; + + private ChangeSynonymToMisapplicationAction(){ + super(text, image); + } + + public ChangeSynonymToMisapplicationAction(Taxon taxon, Synonym synonym){ + this(); + this.taxon = taxon; + this.synonym = synonym; + } + + public void run() { + IUndoableOperation operation = new ChangeSynonymToMisappliedNameOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, synonym); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateAutonymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateAutonymAction.java new file mode 100644 index 000000000..db414d65f --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateAutonymAction.java @@ -0,0 +1,42 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class CreateAutonymAction extends Action { + private static final Logger logger = Logger.getLogger(CreateAutonymAction.class); + + private static String text = "Create autonym"; + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageRegistry().getDescriptor(ITaxEditorConstants.AUTONYM_ICON); + + public CreateAutonymAction(){ + super(text, image); + } + + public void run(){ + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + + logger.warn("Not implemented yet!"); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateConceptRelationAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateConceptRelationAction.java index 635dd53b2..bf614d6b9 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateConceptRelationAction.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateConceptRelationAction.java @@ -33,27 +33,21 @@ public class CreateConceptRelationAction extends Action { .getLogger(CreateConceptRelationAction.class); private static String text = "Create concept relation"; - private ImageDescriptor image = TaxEditorPlugin.getDefault() + private static ImageDescriptor image = TaxEditorPlugin.getDefault() .getImageRegistry().getDescriptor(ITaxEditorConstants.CONCEPT_ICON); - private Taxon taxon; private TaxonRelationshipType taxonRelationshipType; - private CreateConceptRelationAction() { - super(text); - setImageDescriptor(image); - } - - public CreateConceptRelationAction(Taxon taxon, TaxonRelationshipType taxonRelationshipType) { - this(); - - setText(taxonRelationshipType.getLabel()); - - this.taxon = taxon; + public CreateConceptRelationAction(TaxonRelationshipType taxonRelationshipType) { + super(text, image); this.taxonRelationshipType = taxonRelationshipType; + setText(taxonRelationshipType.getLabel()); } + public void run() { + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + IUndoableOperation operation = new CreateConceptRelationOperation( "Create concept relation '" + taxonRelationshipType.getLabel() + "'", EditorController.getUndoContext(taxon), taxon, taxonRelationshipType); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateHeterotypicSynonymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateHeterotypicSynonymAction.java new file mode 100644 index 000000000..0910bc3a7 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateHeterotypicSynonymAction.java @@ -0,0 +1,50 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.CreateMisappliedNameOperation; +import eu.etaxonomy.taxeditor.operations.name.CreateSynonymInNewGroupOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class CreateHeterotypicSynonymAction extends Action { + private static final Logger logger = Logger + .getLogger(CreateHeterotypicSynonymAction.class); + + private static String text = "Create heterotypic synonym"; + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageRegistry().getDescriptor(ITaxEditorConstants.HETEROTYPIC_SYN_ICON); + + public CreateHeterotypicSynonymAction(){ + super(text, image); + } + + public void run() { + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + + IUndoableOperation operation = new CreateSynonymInNewGroupOperation(getText(), + EditorController.getUndoContext(taxon), taxon, ""); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateMisappliedNameAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateMisappliedNameAction.java index d4f23b9c6..b553cbe90 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateMisappliedNameAction.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateMisappliedNameAction.java @@ -34,19 +34,14 @@ public class CreateMisappliedNameAction extends Action { private ImageDescriptor image = TaxEditorPlugin.getDefault() .getImageRegistry().getDescriptor(ITaxEditorConstants.MISAPPLIED_NAME_ICON); - private Taxon taxon; - - private CreateMisappliedNameAction() { + public CreateMisappliedNameAction() { super(text); setImageDescriptor(image); } - public CreateMisappliedNameAction(Taxon taxon) { - this(); - this.taxon = taxon; - } - public void run() { + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + IUndoableOperation operation = new CreateMisappliedNameOperation(getText(), EditorController.getUndoContext(taxon), taxon); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateNewTaxonFromSynonymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateNewTaxonFromSynonymAction.java new file mode 100644 index 000000000..283c728b9 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateNewTaxonFromSynonymAction.java @@ -0,0 +1,59 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToTaxonOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class CreateNewTaxonFromSynonymAction extends Action { + + private static final Logger logger = Logger + .getLogger(CreateNewTaxonFromSynonymAction.class); + + private static final String text = "Use synonym name to make a new taxon"; //$NON-NLS-1$ + private static final ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.SYNONYM_TO_TAXON_ICON); + + private Synonym synonym; + + private Taxon taxon; + + private CreateNewTaxonFromSynonymAction() { + super(text, image); + } + + public CreateNewTaxonFromSynonymAction(Taxon taxon, Synonym synonym) { + this(); + this.taxon = taxon; + this.synonym = synonym; + } + + public void run() { + IUndoableOperation operation = new ChangeSynonymToTaxonOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, synonym); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateSynonymInGroupAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateSynonymInGroupAction.java new file mode 100644 index 000000000..b9436817d --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateSynonymInGroupAction.java @@ -0,0 +1,52 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.name.HomotypicalGroup; +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.CreateSynonymInExisitingHomotypicalGroupOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class CreateSynonymInGroupAction extends Action { + private static final Logger logger = Logger + .getLogger(CreateSynonymInGroupAction.class); + private static String text = "Create synonym in homotypical group"; + private ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageRegistry().getDescriptor(ITaxEditorConstants.HOMOTYPIC_SYN_ICON); + + public CreateSynonymInGroupAction(){ + super(text); + setImageDescriptor(image); + } + + public void run(){ + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + HomotypicalGroup group = taxon.getHomotypicGroup(); + + IUndoableOperation operation = new CreateSynonymInExisitingHomotypicalGroupOperation(getText(), + EditorController.getUndoContext(taxon), taxon, group, ""); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateTaxonomicallyIncludedTaxonAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateTaxonomicallyIncludedTaxonAction.java new file mode 100644 index 000000000..8a22d0416 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/CreateTaxonomicallyIncludedTaxonAction.java @@ -0,0 +1,56 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.name.TaxonNameBase; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.editor.name.CdmParserController; +import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class CreateTaxonomicallyIncludedTaxonAction extends Action { + private static final Logger logger = Logger + .getLogger(CreateTaxonomicallyIncludedTaxonAction.class); + + private static String text = "Create taxonomically included taxon"; + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageRegistry().getDescriptor(ITaxEditorConstants.BLACK_SQUARE_ICON); + + public CreateTaxonomicallyIncludedTaxonAction(){ + super(text, image); + } + + public void run(){ + + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + // Create a new taxon with an empty name + TaxonNameBase childName = + CdmParserController.parseFullReference("", null, null); + Taxon childTaxon = Taxon.NewInstance(childName, CdmSessionDataRepository.getDefault().getDefaultSec()); + + // Add the newly created taxon to the actual open taxon + taxon.addTaxonomicChild(childTaxon, null, null); + + // Open a new editor window for the new taxon + EditorController.open(childTaxon); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/MakeBasionymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/MakeBasionymAction.java new file mode 100644 index 000000000..e80d6240a --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/MakeBasionymAction.java @@ -0,0 +1,52 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.MakeSynonymGroupBasionymOperation; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class MakeBasionymAction extends Action { + private static final Logger logger = Logger + .getLogger(MakeBasionymAction.class); + + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.BASIONYM_ICON); + + private Taxon taxon; + private Synonym synonym; + + public MakeBasionymAction(Taxon taxon, Synonym synonym){ + String text = Messages.getString("AddBasionymCompositeAction.0", synonym.getName()); + this.setText(text); + this.setImageDescriptor(image); + } + + public void run() { + IUndoableOperation operation = new MakeSynonymGroupBasionymOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, synonym); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/Messages.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/Messages.java similarity index 92% rename from eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/Messages.java rename to eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/Messages.java index 63dd64741..e61eaa3ce 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/Messages.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/Messages.java @@ -6,7 +6,7 @@ * 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.editor.name; +package eu.etaxonomy.taxeditor.actions.name; import java.util.Locale; import java.util.MissingResourceException; @@ -27,7 +27,7 @@ import eu.etaxonomy.taxeditor.preference.PreferencesUtil; */ public class Messages { private static final Logger logger = Logger.getLogger(Messages.class); - private static final String BUNDLE_NAME = "eu.etaxonomy.taxeditor.editor.name.messages"; //$NON-NLS-1$ + private static final String BUNDLE_NAME = "eu.etaxonomy.taxeditor.actions.name.messages"; //$NON-NLS-1$ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle .getBundle(BUNDLE_NAME, Locale.getDefault()); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveConceptAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveConceptAction.java new file mode 100644 index 000000000..15111e711 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveConceptAction.java @@ -0,0 +1,64 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.RemoveConceptRelationOperation; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class RemoveConceptAction extends Action { + private static final Logger logger = Logger + .getLogger(RemoveConceptAction.class); + + private static String text = "Remove concept relation from taxon"; //$NON-NLS-1$ + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON); + + private TaxonRelationshipType relationshipType; + + private Taxon relatedTaxon; + + private Taxon taxon; + + private RemoveConceptAction(){ + super(text, image); + } + + public RemoveConceptAction(Taxon taxon, Taxon relatedTaxon, + TaxonRelationshipType relationshipType) { + this(); + this.taxon = taxon; + this.relatedTaxon = relatedTaxon; + this.relationshipType = relationshipType; + } + + public void run() { + IUndoableOperation operation = new RemoveConceptRelationOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, relatedTaxon, relationshipType); + + GlobalController.executeOperation(operation); + } + + +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveSynonymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveSynonymAction.java new file mode 100644 index 000000000..45ca34ed0 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/RemoveSynonymAction.java @@ -0,0 +1,59 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.RemoveSynonymOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class RemoveSynonymAction extends Action { + + private static final Logger logger = Logger + .getLogger(RemoveSynonymAction.class); + + private static final String text = "Remove synonym from taxon"; //$NON-NLS-1$ + private static final ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON); + + private Synonym synonym; + + private Taxon taxon; + + private RemoveSynonymAction() { + super(text, image); + } + + public RemoveSynonymAction(Taxon taxon, Synonym synonym) { + this(); + this.taxon = taxon; + this.synonym = synonym; + } + + public void run() { + IUndoableOperation operation = new RemoveSynonymOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, synonym); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/UnmakeBasionymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/UnmakeBasionymAction.java new file mode 100644 index 000000000..210c3a528 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/UnmakeBasionymAction.java @@ -0,0 +1,55 @@ +/** +* 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.actions.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.operations.IUndoableOperation; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.resource.ImageDescriptor; + +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; +import eu.etaxonomy.taxeditor.controller.GlobalController; +import eu.etaxonomy.taxeditor.operations.name.UnmakeSynonymGroupBasionymOperation; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class UnmakeBasionymAction extends Action { + private static final Logger logger = Logger + .getLogger(UnmakeBasionymAction.class); + + + private static ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.BASIONYM_ICON); + + private Taxon taxon; + private Synonym synonym; + + public UnmakeBasionymAction(Taxon taxon, Synonym synonym){ + String text = Messages.getString("RemoveBasionymCompositeAction.0", synonym.getName()); //$NON-NLS-1$ + this.setText(text); + this.setImageDescriptor(image); + this.taxon = taxon; + this.synonym = synonym; + } + + public void run() { + IUndoableOperation operation = new UnmakeSynonymGroupBasionymOperation + (this.getText(), EditorController.getUndoContext(taxon), taxon, synonym); + + GlobalController.executeOperation(operation); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/messages.properties b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/messages.properties similarity index 100% rename from eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/messages.properties rename to eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/name/messages.properties diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/ChangeTaxonToSynonymAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/ChangeTaxonToSynonymAction.java index 1bd8628fc..14ba36018 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/ChangeTaxonToSynonymAction.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/ChangeTaxonToSynonymAction.java @@ -18,6 +18,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.taxeditor.ITaxEditorConstants; import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.controller.EditorController; import eu.etaxonomy.taxeditor.controller.GlobalController; import eu.etaxonomy.taxeditor.operations.ChangeTaxonToSynonymOperation; @@ -31,22 +32,18 @@ public class ChangeTaxonToSynonymAction extends Action { .getLogger(ChangeTaxonToSynonymAction.class); private static String text = "Change this taxon to a synonym"; - private ImageDescriptor image = TaxEditorPlugin.getDefault() + private static ImageDescriptor image = TaxEditorPlugin.getDefault() .getImageRegistry().getDescriptor(ITaxEditorConstants.TAXON_TO_SYNONYM_ICON); private Taxon taxon; - private ChangeTaxonToSynonymAction() { - super(text); - setImageDescriptor(image); - } - - public ChangeTaxonToSynonymAction(Taxon taxon) { - this(); - this.taxon = taxon; + public ChangeTaxonToSynonymAction() { + super(text, image); } public void run() { + Taxon taxon = EditorController.getActiveEditor().getTaxon(); + IUndoableOperation operation = new ChangeTaxonToSynonymOperation(getText(), GlobalController.getWorkbenchUndoContext(), taxon); diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/MoveTaxonDialogAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/MoveTaxonDialogAction.java index ed517e3e3..b1fbcf6ec 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/MoveTaxonDialogAction.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/MoveTaxonDialogAction.java @@ -39,23 +39,16 @@ public class MoveTaxonDialogAction extends Action { .getLogger(MoveTaxonDialogAction.class); private static String text = "Move this taxon to a new parent"; - private ImageDescriptor image = TaxEditorPlugin.getDefault() + private static ImageDescriptor image = TaxEditorPlugin.getDefault() .getImageRegistry().getDescriptor(ITaxEditorConstants.MOVE_ICON); - private Taxon taxon; - - private MoveTaxonDialogAction() { - super(text); - setImageDescriptor(image); - } - - public MoveTaxonDialogAction(Taxon taxon) { - this(); - this.taxon = taxon; + public MoveTaxonDialogAction() { + super(text, image); } public void run() { + Taxon taxon = EditorController.getActiveEditor().getTaxon(); IEditorPart editor = null; diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/OpenTaxonEditorAction.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/OpenTaxonEditorAction.java index 45c7a3b2e..1e99a4941 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/OpenTaxonEditorAction.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/ui/OpenTaxonEditorAction.java @@ -11,32 +11,33 @@ package eu.etaxonomy.taxeditor.actions.ui; import org.apache.log4j.Logger; import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.actions.ActionFactory; import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.ITaxEditorConstants; +import eu.etaxonomy.taxeditor.TaxEditorPlugin; import eu.etaxonomy.taxeditor.controller.EditorController; /** * Opens a taxon editor for an existing taxon. * + * FIXME this action is broken and actually throws lots of hibernate exceptions + * * @author p.ciardelli * @created 02.06.2008 * @version 1.0 */ -public class OpenTaxonEditorAction extends Action implements IWorkbenchWindowActionDelegate { +public class OpenTaxonEditorAction extends Action implements ActionFactory.IWorkbenchAction { private static final Logger logger = Logger .getLogger(OpenTaxonEditorAction.class); private static String editTaxonText = "Edit taxon"; private static String newTaxonText = "Add new taxon"; -// private ImageDescriptor image = TaxEditorPlugin.getDefault() -// .getImageDescriptor(ITaxEditorConstants.OPEN_TAXON_ICON); - private ImageDescriptor image = null; - + private ImageDescriptor image = TaxEditorPlugin.getDefault() + .getImageDescriptor(ITaxEditorConstants.OPEN_TAXON_ICON); + private IWorkbenchWindow window; private Taxon taxon; @@ -69,23 +70,5 @@ public class OpenTaxonEditorAction extends Action implements IWorkbenchWindowAct @Override public void dispose() { - // TODO Auto-generated method stub - - } - - @Override - public void init(IWorkbenchWindow window) { - this.window = window; - } - - @Override - public void run(IAction action) { - run(); - } - - @Override - public void selectionChanged(IAction action, ISelection selection) { - // TODO Auto-generated method stub - } } \ No newline at end of file diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/EditorController.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/EditorController.java index f8ca175f3..67b57a375 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/EditorController.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/EditorController.java @@ -314,11 +314,27 @@ public class EditorController { } return taxonEditors; } + + /** + * Returns the currently active taxon editor + * + * @return the taxon editor that has focus + */ + public static MultiPageTaxonEditor getActiveEditor(){ + if(getActivePage().getActiveEditor() instanceof MultiPageTaxonEditor){ + return (MultiPageTaxonEditor) getActivePage().getActiveEditor(); + } + return null; + } public static IUndoContext getUndoContext(Taxon taxon) { // TODO make this taxon name editor specific // return getTaxonNameEditor(taxon).getUndoContext(); - return IOperationHistory.GLOBAL_UNDO_CONTEXT; + return getUndoContext(); + } + + public static IUndoContext getUndoContext() { + return IOperationHistory.GLOBAL_UNDO_CONTEXT; } diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/GlobalController.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/GlobalController.java index 689713389..1640b5fb4 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/GlobalController.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/controller/GlobalController.java @@ -31,6 +31,7 @@ import eu.etaxonomy.cdm.model.description.Feature; import eu.etaxonomy.cdm.model.name.NameRelationshipType; import eu.etaxonomy.cdm.model.name.Rank; import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor; import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository; /** @@ -159,5 +160,4 @@ public class GlobalController { logger.error("Error executing operation: " + operation.getLabel(), e); } } - } \ No newline at end of file diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/ContextMenu.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/ContextMenu.java index 025811d3e..cd3c98c9c 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/ContextMenu.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/ContextMenu.java @@ -89,7 +89,7 @@ public class ContextMenu { } }); } - + private List getActions() { if (actions == null) { actions = new ArrayList(); @@ -112,6 +112,32 @@ public class ContextMenu { public void addSubmenu(MenuManager submenu) { getActions().add(submenu); } + + public void setMenuManager(MenuManager menuManager){ + if(control == null){ + logger.warn("No control set for context menu"); + }else{ + this.menuManager = menuManager; + menu = menuManager.createContextMenu(control); + control.setMenu(menu); + + menuManager.addMenuListener(new IMenuListener() { + public void menuAboutToShow(IMenuManager manager) { + for (Object action : getActions()) { + if (action instanceof Action) { + manager.add((Action) action); + } + if (action instanceof Separator) { + manager.add((Separator) action); + } + if (action instanceof MenuManager) { + manager.add((MenuManager) action); + } + } + } + }); + } + } public Menu getMenu() { return menu; diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MenuConstants.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MenuConstants.java new file mode 100644 index 000000000..085909c4c --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MenuConstants.java @@ -0,0 +1,62 @@ +/** +* 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.editor; + +import org.apache.log4j.Logger; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; + +import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; +import eu.etaxonomy.taxeditor.actions.name.CreateAutonymAction; +import eu.etaxonomy.taxeditor.actions.name.CreateConceptRelationAction; +import eu.etaxonomy.taxeditor.actions.name.CreateHeterotypicSynonymAction; +import eu.etaxonomy.taxeditor.actions.name.CreateMisappliedNameAction; +import eu.etaxonomy.taxeditor.actions.name.CreateSynonymInGroupAction; +import eu.etaxonomy.taxeditor.actions.name.CreateTaxonomicallyIncludedTaxonAction; +import eu.etaxonomy.taxeditor.actions.ui.ChangeTaxonToSynonymAction; +import eu.etaxonomy.taxeditor.actions.ui.MoveTaxonDialogAction; +import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class MenuConstants { + private static final Logger logger = Logger.getLogger(MenuConstants.class); + + public static final MenuManager EDITOR_TAXON_MENU(){ + MenuManager taxonEditorMenu = new MenuManager("Taxon"); + + taxonEditorMenu.add(new CreateHeterotypicSynonymAction()); + taxonEditorMenu.add(new CreateSynonymInGroupAction()); + taxonEditorMenu.add(new Separator()); + taxonEditorMenu.add(new CreateMisappliedNameAction()); + + MenuManager subMenu = new MenuManager("Create concept relation"); + for (TaxonRelationshipType type : + CdmSessionDataRepository.getDefault().getConceptRelationshipTypes()) { + subMenu.add(new CreateConceptRelationAction(type)); + } + taxonEditorMenu.add(subMenu); + taxonEditorMenu.add(new Separator()); + taxonEditorMenu.add(new MoveTaxonDialogAction()); + taxonEditorMenu.add(new ChangeTaxonToSynonymAction()); + taxonEditorMenu.add(new Separator()); + // TODO is it correct that onlx taxa with rank species may have autonyms? + // if(taxon.getName().getRank().equals(Rank.SPECIES())){ + taxonEditorMenu.add(new CreateAutonymAction()); + // } + taxonEditorMenu.add(new CreateTaxonomicallyIncludedTaxonAction()); + + return taxonEditorMenu; + } + +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java index 75972b05b..c5569f0c6 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditor.java @@ -165,7 +165,7 @@ public class MultiPageTaxonEditor extends MultiPageEditorPart { }); setPartName(); - + super.init(site, input); } @@ -199,4 +199,8 @@ public class MultiPageTaxonEditor extends MultiPageEditorPart { public void setDirtyExtern(boolean IS_DIRTY) { setDirty(IS_DIRTY); } + + public Taxon getTaxon(){ + return this.taxon; + } } \ No newline at end of file diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorActionBarContributor.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorActionBarContributor.java new file mode 100644 index 000000000..dc40e7452 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/MultiPageTaxonEditorActionBarContributor.java @@ -0,0 +1,51 @@ +/** +* 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.editor; + +import org.apache.log4j.Logger; +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.part.EditorActionBarContributor; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; +import eu.etaxonomy.taxeditor.actions.name.CreateAutonymAction; +import eu.etaxonomy.taxeditor.actions.name.CreateConceptRelationAction; +import eu.etaxonomy.taxeditor.actions.name.CreateHeterotypicSynonymAction; +import eu.etaxonomy.taxeditor.actions.name.CreateMisappliedNameAction; +import eu.etaxonomy.taxeditor.actions.name.CreateSynonymInGroupAction; +import eu.etaxonomy.taxeditor.actions.name.CreateTaxonomicallyIncludedTaxonAction; +import eu.etaxonomy.taxeditor.actions.ui.ChangeTaxonToSynonymAction; +import eu.etaxonomy.taxeditor.actions.ui.MoveTaxonDialogAction; +import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class MultiPageTaxonEditorActionBarContributor extends + EditorActionBarContributor { + private static final Logger logger = Logger + .getLogger(MultiPageTaxonEditorActionBarContributor.class); + + /** + * + */ + public MultiPageTaxonEditorActionBarContributor() { + logger.warn("Setting up action bar contributions."); + } + + public void contributeToMenu(IMenuManager menubar){ + menubar.insertAfter(IWorkbenchActionConstants.M_EDIT, MenuConstants.EDITOR_TAXON_MENU()); + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/AcceptedNameComposite.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/AcceptedNameComposite.java index 364635c0e..d275db68f 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/AcceptedNameComposite.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/AcceptedNameComposite.java @@ -15,14 +15,20 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.views.properties.IPropertySource; +import eu.etaxonomy.cdm.model.name.Rank; import eu.etaxonomy.cdm.model.name.TaxonNameBase; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; +import eu.etaxonomy.taxeditor.actions.name.CreateAutonymAction; import eu.etaxonomy.taxeditor.actions.name.CreateConceptRelationAction; +import eu.etaxonomy.taxeditor.actions.name.CreateHeterotypicSynonymAction; +import eu.etaxonomy.taxeditor.actions.name.CreateSynonymInGroupAction; import eu.etaxonomy.taxeditor.actions.name.CreateMisappliedNameAction; +import eu.etaxonomy.taxeditor.actions.name.CreateTaxonomicallyIncludedTaxonAction; import eu.etaxonomy.taxeditor.actions.ui.ChangeTaxonToSynonymAction; import eu.etaxonomy.taxeditor.actions.ui.MoveTaxonDialogAction; import eu.etaxonomy.taxeditor.editor.ContextMenu; +import eu.etaxonomy.taxeditor.editor.MenuConstants; import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository; import eu.etaxonomy.taxeditor.propertysheet.name.TaxonBasePropertySource; @@ -53,25 +59,28 @@ public class AcceptedNameComposite extends NameComposite { private void createMenu() { ContextMenu contextMenu = createContextMenu(); - contextMenu.addAction(new ChangeTaxonToSynonymAction(getTaxon())); - contextMenu.addAction(new MoveTaxonDialogAction(getTaxon())); - contextMenu.addSeparator(); - contextMenu.addAction(new CreateMisappliedNameAction(getTaxon())); + contextMenu.setMenuManager(MenuConstants.EDITOR_TAXON_MENU()); - MenuManager subMenu = new MenuManager("Create concept relation"); - for (TaxonRelationshipType type : - CdmSessionDataRepository.getDefault().getConceptRelationshipTypes()) { - subMenu.add(new CreateConceptRelationAction( - getTaxon(), type)); - } - contextMenu.addSubmenu(subMenu); - - - // TODO Make action "Create autonym and subspecies" -// contextMenu.addSeparator(); +// contextMenu.addAction(new CreateHeterotypicSynonymAction()); +// contextMenu.addAction(new CreateSynonymInGroupAction()); +// contextMenu.addSeparator(); +// contextMenu.addAction(new CreateMisappliedNameAction()); // -// contextMenu.addAction(new CreateAutonym(getTaxon())); -// contextMenu.addAction(new CreateSubspecies(getTaxon())); +// MenuManager subMenu = new MenuManager("Create concept relation"); +// for (TaxonRelationshipType type : +// CdmSessionDataRepository.getDefault().getConceptRelationshipTypes()) { +// subMenu.add(new CreateConceptRelationAction(type)); +// } +// contextMenu.addSubmenu(subMenu); +// contextMenu.addSeparator(); +// contextMenu.addAction(new MoveTaxonDialogAction()); +// contextMenu.addAction(new ChangeTaxonToSynonymAction()); +// contextMenu.addSeparator(); +// // TODO is it correct that onlx taxa with rank species may have autonyms? +// // if(getTaxon().getName().getRank().equals(Rank.SPECIES())){ +// contextMenu.addAction(new CreateAutonymAction()); +// // } +// contextMenu.addAction(new CreateTaxonomicallyIncludedTaxonAction()); } @Override diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/ConceptComposite.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/ConceptComposite.java index 84d7515fb..2b2afda70 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/ConceptComposite.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/ConceptComposite.java @@ -13,6 +13,7 @@ import org.apache.log4j.Logger; import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.commands.operations.IUndoableOperation; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.widgets.Composite; @@ -25,9 +26,13 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; import eu.etaxonomy.taxeditor.ITaxEditorConstants; import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.actions.name.ChangeConceptRelationAction; +import eu.etaxonomy.taxeditor.actions.name.CreateConceptRelationAction; +import eu.etaxonomy.taxeditor.actions.name.RemoveConceptAction; import eu.etaxonomy.taxeditor.controller.EditorController; import eu.etaxonomy.taxeditor.controller.GlobalController; import eu.etaxonomy.taxeditor.editor.ContextMenu; +import eu.etaxonomy.taxeditor.model.CdmSessionDataRepository; import eu.etaxonomy.taxeditor.operations.name.RemoveConceptRelationOperation; import eu.etaxonomy.taxeditor.operations.name.RemoveMisappliedNameOperation; import eu.etaxonomy.taxeditor.propertysheet.name.TaxonBasePropertySource; @@ -105,21 +110,13 @@ public class ConceptComposite extends NameComposite { private void createMenu() { ContextMenu contextMenu = createContextMenu(); - final IUndoContext undoContext = EditorController.getUndoContext(taxon); - // Remove misapplied name from taxon - String text = "Remove concept relation from taxon"; //$NON-NLS-1$ - ImageDescriptor image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON); - contextMenu.addAction(new Action(text, image){ - - public void run() { - IUndoableOperation operation = new RemoveConceptRelationOperation - (this.getText(), undoContext, taxon, relatedTaxon, relationshipType); - - GlobalController.executeOperation(operation); - } - }); + contextMenu.addAction(new RemoveConceptAction(taxon, relatedTaxon, relationshipType)); + MenuManager subMenu = new MenuManager("Change relation type"); + for (TaxonRelationshipType type : CdmSessionDataRepository.getDefault().getConceptRelationshipTypes()) { + subMenu.add(new ChangeConceptRelationAction(taxon, relatedTaxon, type)); + } + contextMenu.addSubmenu(subMenu); } diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/MisappliedNameComposite.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/MisappliedNameComposite.java index 33ad66916..1bee97f7b 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/MisappliedNameComposite.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/MisappliedNameComposite.java @@ -25,6 +25,7 @@ import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; import eu.etaxonomy.taxeditor.ITaxEditorConstants; import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.actions.name.RemoveConceptAction; import eu.etaxonomy.taxeditor.controller.EditorController; import eu.etaxonomy.taxeditor.controller.GlobalController; import eu.etaxonomy.taxeditor.editor.ContextMenu; @@ -82,22 +83,10 @@ public class MisappliedNameComposite extends NameComposite { ContextMenu contextMenu = createContextMenu(); - final IUndoContext undoContext = EditorController.getUndoContext(taxon); - // Remove misapplied name from taxon - String text = "Remove misapplied name from taxon"; //$NON-NLS-1$ - ImageDescriptor image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON); - contextMenu.addAction(new Action(text, image){ - - public void run() { - IUndoableOperation operation = new RemoveConceptRelationOperation - (this.getText(), undoContext, taxon, - misappliedName, TaxonRelationshipType.MISAPPLIED_NAME_FOR()); - - GlobalController.executeOperation(operation); - } - }); + contextMenu.addAction(new RemoveConceptAction(taxon, + misappliedName, TaxonRelationshipType.MISAPPLIED_NAME_FOR())); + } public boolean setParent(Composite parent) { diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameComposite.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameComposite.java index b06934cee..8b3f51433 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameComposite.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/NameComposite.java @@ -17,6 +17,7 @@ import org.eclipse.core.commands.operations.IUndoContext; import org.eclipse.core.commands.operations.IUndoableOperation; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.MenuManager; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.events.FocusAdapter; diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/SynonymComposite.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/SynonymComposite.java index 589bab86b..cd5eee3ff 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/SynonymComposite.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/editor/name/SynonymComposite.java @@ -25,17 +25,21 @@ import eu.etaxonomy.cdm.model.taxon.Synonym; import eu.etaxonomy.cdm.model.taxon.Taxon; import eu.etaxonomy.taxeditor.ITaxEditorConstants; import eu.etaxonomy.taxeditor.TaxEditorPlugin; +import eu.etaxonomy.taxeditor.actions.cdm.SwapSynonymAndTaxonAction; +import eu.etaxonomy.taxeditor.actions.name.ChangeSynonymToConceptRelationAction; +import eu.etaxonomy.taxeditor.actions.name.ChangeSynonymToMisapplicationAction; +import eu.etaxonomy.taxeditor.actions.name.CreateSynonymInGroupAction; +import eu.etaxonomy.taxeditor.actions.name.CreateNewTaxonFromSynonymAction; +import eu.etaxonomy.taxeditor.actions.name.MakeBasionymAction; +import eu.etaxonomy.taxeditor.actions.name.Messages; +import eu.etaxonomy.taxeditor.actions.name.RemoveSynonymAction; +import eu.etaxonomy.taxeditor.actions.name.UnmakeBasionymAction; import eu.etaxonomy.taxeditor.controller.EditorController; import eu.etaxonomy.taxeditor.controller.GlobalController; import eu.etaxonomy.taxeditor.editor.ContextMenu; import eu.etaxonomy.taxeditor.model.CdmUtil; import eu.etaxonomy.taxeditor.operations.name.ChangeHomotypicGroupOperation; -import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToConceptOperation; import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToMisappliedNameOperation; -import eu.etaxonomy.taxeditor.operations.name.ChangeSynonymToTaxonOperation; -import eu.etaxonomy.taxeditor.operations.name.MakeSynonymAcceptedOperation; -import eu.etaxonomy.taxeditor.operations.name.MakeSynonymGroupBasionymOperation; -import eu.etaxonomy.taxeditor.operations.name.RemoveSynonymOperation; import eu.etaxonomy.taxeditor.operations.name.UnmakeSynonymGroupBasionymOperation; import eu.etaxonomy.taxeditor.propertysheet.name.TaxonBasePropertySource; @@ -136,128 +140,27 @@ public class SynonymComposite extends NameComposite { ContextMenu contextMenu = createContextMenu(); - // Change composite to a misapplied name - String text = "Change synonym to misapplied name"; //$NON-NLS-1$ - ImageDescriptor image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.MISAPPLIED_NAME_ICON); - contextMenu.addAction(new Action(text, image){ - - public void run() { - IUndoableOperation operation = new ChangeSynonymToMisappliedNameOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }); - - // Change synonym to conccept relation - text = "Change synonym to concept relation"; //$NON-NLS-1$ - image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.CONCEPT_ICON); - - contextMenu.addAction(new Action(text, image){ - - public void run() { - IUndoableOperation operation = new ChangeSynonymToConceptOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }); - - // Remove composite - text = "Remove synonym from taxon"; //$NON-NLS-1$ - image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.ACTIVE_DELETE_ICON); - contextMenu.addAction(new Action(text, image){ - - public void run() { - IUndoableOperation operation = new RemoveSynonymOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }); - - // Separator - contextMenu.addSeparator(); - - // Make the synonym the basionym of the homotypic group - text = Messages.getString - ("AddBasionymCompositeAction.0", synonym.getName()); //$NON-NLS-1$ - image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.BASIONYM_ICON); - Action makeBasionymAction = new Action(text, image){ - - public void run() { - IUndoableOperation operation = new MakeSynonymGroupBasionymOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }; - contextMenu.addAction(makeBasionymAction); - - // Action to remove the composite as basionym of the homotypic group - text = Messages.getString - ("RemoveBasionymCompositeAction.0", synonym.getName()); //$NON-NLS-1$ - image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.BASIONYM_ICON); - Action unmakeBasionymAction = new Action(text, image){ - - public void run() { - IUndoableOperation operation = new UnmakeSynonymGroupBasionymOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }; - contextMenu.addAction(unmakeBasionymAction); - + contextMenu.addAction(new RemoveSynonymAction(taxon, synonym)); if (CdmUtil.isNameGroupBasionym(synonym.getName())) { - - // Gray out action for "make synonym group basionym" - makeBasionymAction.setEnabled(false); + contextMenu.addAction(new UnmakeBasionymAction(taxon, synonym)); } else { - - // Gray out action for "unmake synonym group basionym" - unmakeBasionymAction.setEnabled(false); + contextMenu.addAction(new MakeBasionymAction(taxon, synonym)); } - - // Separator + // Add synonym to this synonyms homotypical group + // FIXME not working with the new menu action +// contextMenu.addAction(new CreateSynonymInGroupAction(synonym.getHomotypicGroup())); contextMenu.addSeparator(); - + contextMenu.addAction(new ChangeSynonymToMisapplicationAction(taxon, synonym)); + contextMenu.addAction(new ChangeSynonymToConceptRelationAction(taxon, synonym)); + contextMenu.addSeparator(); // Change this synonym to the taxon's accepted name - text = "Make synonym this taxon's accepted taxon"; //$NON-NLS-1$ - image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.SWAP_SYNONYM_AND_TAXON_ICON); - Action swapAction = new Action(text, image){ - - public void run() { - IUndoableOperation operation = new MakeSynonymAcceptedOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }; + Action swapAction = new SwapSynonymAndTaxonAction(taxon, synonym); contextMenu.addAction(swapAction); // TODO fix operation swapAction.setEnabled(false); // Make a new taxon with this synonym as the accepted name - text = "Use synonym name to make a new taxon"; //$NON-NLS-1$ - image = TaxEditorPlugin.getDefault() - .getImageDescriptor(ITaxEditorConstants.SYNONYM_TO_TAXON_ICON); - - contextMenu.addAction(new Action(text, image){ - - public void run() { - IUndoableOperation operation = new ChangeSynonymToTaxonOperation - (this.getText(), undoContext, taxon, synonym); - - GlobalController.executeOperation(operation); - } - }); + contextMenu.addAction(new CreateNewTaxonFromSynonymAction(taxon, synonym)); } diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmSessionDataRepository.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmSessionDataRepository.java index 650d79e8e..f4e28f0ea 100644 --- a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmSessionDataRepository.java +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/model/CdmSessionDataRepository.java @@ -451,7 +451,7 @@ public class CdmSessionDataRepository implements ICdmSessionDataRepository { @Override public Set getConceptRelationshipTypes() { if (conceptRelationshipTypes == null) { - conceptRelationshipTypes = getTaxonRelationshipTypes().terms; + conceptRelationshipTypes = getTaxonRelationshipTypes().getTerms(); conceptRelationshipTypes.remove(TaxonRelationshipType.MISAPPLIED_NAME_FOR()); conceptRelationshipTypes.remove(TaxonRelationshipType.TAXONOMICALLY_INCLUDED_IN()); } diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeConceptRelationOperation.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeConceptRelationOperation.java new file mode 100644 index 000000000..e744ca487 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/ChangeConceptRelationOperation.java @@ -0,0 +1,80 @@ +/** +* 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.operations.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; +import eu.etaxonomy.taxeditor.operations.AbstractEditorOperation; + +/** + * @author n.hoffmann + * @created 03.02.2009 + * @version 1.0 + */ +public class ChangeConceptRelationOperation extends AbstractEditorOperation { + + + private static final Logger logger = Logger + .getLogger(ChangeConceptRelationOperation.class); + private Taxon relatedTaxon; + private TaxonRelationshipType oldRelationshipType; + private TaxonRelationshipType newRelationshipType; + + public ChangeConceptRelationOperation(String label, + IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon, TaxonRelationshipType type) { + super(label, undoContext, taxon); + this.relatedTaxon = relatedTaxon; + //this.oldRelationshipType = relatedTaxon.get + this.newRelationshipType = type; + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus execute(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + // Remove relatedTaxon and old relationship + // FIXME since taxon relationships come in a set, which relationships are we going to delete here? +// taxon.removeTaxon(relatedTaxon, oldRelationshipType); + // Add new relationship + // TODO add microcitation for misapplied name to property sheet + relatedTaxon.addTaxonRelation(taxon, newRelationshipType, null, null); + + return redrawOpenEditor(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus redo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + return execute(monitor, info); + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus undo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + // see FIXME in execute() + logger.warn("Not implemented yet. See developer documentation for details"); + return null; + } +} diff --git a/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateSynonymInExisitingHomotypicalGroupOperation.java b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateSynonymInExisitingHomotypicalGroupOperation.java new file mode 100644 index 000000000..7138ac137 --- /dev/null +++ b/eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/operations/name/CreateSynonymInExisitingHomotypicalGroupOperation.java @@ -0,0 +1,92 @@ +/** +* 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.operations.name; + +import org.apache.log4j.Logger; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.operations.IUndoContext; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; + +import eu.etaxonomy.cdm.model.name.HomotypicalGroup; +import eu.etaxonomy.cdm.model.name.TaxonNameBase; +import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.taxeditor.editor.name.CdmParserController; +import eu.etaxonomy.taxeditor.operations.AbstractEditorOperation; + +/** + * @author n.hoffmann + * @created 02.02.2009 + * @version 1.0 + */ +public class CreateSynonymInExisitingHomotypicalGroupOperation extends + AbstractEditorOperation { + private static final Logger logger = Logger + .getLogger(CreateSynonymInExisitingHomotypicalGroupOperation.class); + + private HomotypicalGroup group; + private String newSynonymText; + + private SynonymRelationship synonymRelationship; + + public CreateSynonymInExisitingHomotypicalGroupOperation(String label, + IUndoContext undoContext, Taxon taxon, HomotypicalGroup group, String newSynonymText) { + super(label, undoContext, taxon); + this.group = group; + this.newSynonymText = newSynonymText; + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus execute(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + + // Create synonym name using newSynonymText + TaxonNameBase synonymName = + CdmParserController.parseFullReference(newSynonymText, null, null); + + // Add name to given homotypic group + group.addTypifiedName(synonymName); + + // Create a new synonym for the taxon + // TODO add citations + if(group.equals(taxon.getHomotypicGroup())){ + synonymRelationship = taxon.addHomotypicSynonymName(synonymName, null, null); + }else{ + synonymRelationship = taxon.addHeterotypicSynonymName(synonymName); + } + return redrawOpenEditor(); + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus redo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + return execute(monitor, info); + } + + /* (non-Javadoc) + * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable) + */ + @Override + public IStatus undo(IProgressMonitor monitor, IAdaptable info) + throws ExecutionException { + + taxon.removeSynonymRelation(synonymRelationship); + + return redrawOpenEditor(); + } +} -- 2.34.1