move the change accepted to Synonym Operation to taxon navigator.
authorKatja Luther <k.luther@bgbm.org>
Thu, 6 Feb 2014 11:58:53 +0000 (11:58 +0000)
committerKatja Luther <k.luther@bgbm.org>
Thu, 6 Feb 2014 11:58:53 +0000 (11:58 +0000)
.gitattributes
eu.etaxonomy.taxeditor.editor/plugin.xml
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java [deleted file]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java [deleted file]
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeSynonymToMisapplicationOperation.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/descriptive/handler/MoveDescriptionToOtherTaxonHandler.java
eu.etaxonomy.taxeditor.navigation/plugin.xml
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/operation/DeleteOperation.java

index 1d9402e02ad58af7161e0b9849a923a0595f1e61..a8ee33899da7538e1e2e11e0b5cbea942656cc29 100644 (file)
@@ -420,7 +420,6 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/d
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDragSourceEffect.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetEffect.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/dnd/NameEditorDropTargetListener.java -text
-eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeSynonymToAcceptedTaxonHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToConceptRelationHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeToMisapplicationHandler.java -text
@@ -436,7 +435,6 @@ eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/h
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/RemoveBasionymHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SetBasionymHandler.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/SwapSynonymAndAcceptedHandler.java -text
-eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptRelationshipTypeOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeConceptToSynonymOperation.java -text
 eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeHomotypicGroupOperation.java -text
index ad0017f0e8c78aaed542b3ffc57ef433b725fce3..70cb65697f1ab6a6393a26ea4e86ce7e726b10c9 100644 (file)
                   name="separator1"
                   visible="true">
             </separator>
-            <command
+           <!-- <command
                   commandId="eu.etaxonomy.taxeditor.editor.name.createMisapplication"
                   label="Misapplication"
                   style="push">
                      </reference>
                   </or>
                </visibleWhen>
-            </command>
+            </command>-->
          </menu>
-         <command
+        <!--<command
                commandId="eu.etaxonomy.taxeditor.editor.name.changeAcceptedToSynonym"
                label="Change Accepted Taxon to Synonym"
                style="push">
-            <!--visibleWhen
+            <visibleWhen
                   checkEnabled="true">
                <reference
                      definitionId="isAcceptedAndHasNoHomotypicSynonyms">
                </reference>
-            </visibleWhen-->
+            </visibleWhen
                 <visibleWhen>                  
                      <or>
                         <reference
                         </reference>
                      </or>                  
                </visibleWhen>
-         </command>
+         </command>-->
          <menu
                label="Change To">
             <command
             id="eu.etaxonomy.taxeditor.editor.name.createSynonymInHomotypicalGroup"
             name="Create Synonym In Homotypical Group">
       </command>
-      <command
+     <!-- <command
             categoryId="eu.etaxonomy.taxeditor.editor.taxon.name.command.category"
             defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.CreateMisapplicationHandler"
             id="eu.etaxonomy.taxeditor.editor.name.createMisapplication"
             name="Create Misapplication">
-      </command>
+      </command>-->
       <!--command
             defaultHandler="eu.etaxonomy.taxeditor.editor.handler.MoveTaxonHandler"
             id="eu.etaxonomy.taxeditor.editor.name.moveTaxon"
             id="eu.etaxonomy.taxeditor.editor.name.removeBasionym"
             name="Remove Basionym / Original Combination">
       </command>
-      <command
+     <!-- <command
             categoryId="eu.etaxonomy.taxeditor.editor.taxon.name.command.category"
             defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.ChangeAcceptedTaxonToSynonymHandler"
             id="eu.etaxonomy.taxeditor.editor.name.changeAcceptedToSynonym"
             name="Change Accepted Taxon to Synonym">
-      </command>
+      </command>-->
       <command
             categoryId="eu.etaxonomy.taxeditor.editor.taxon.name.command.category"
             defaultHandler="eu.etaxonomy.taxeditor.editor.name.handler.DeleteAllEmptyNamesHandler"
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/handler/ChangeAcceptedTaxonToSynonymHandler.java
deleted file mode 100644 (file)
index a6f7910..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * 
- */
-package eu.etaxonomy.taxeditor.editor.name.handler;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.log4j.Logger;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.commands.common.NotDefinedException;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.editor.EditorUtil;
-import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
-import eu.etaxonomy.taxeditor.editor.Page;
-import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
-import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.editor.name.operation.ChangeAcceptedTaxonToSynonymOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
-
-/**
- * <p>ChangeAcceptedTaxonToSynonymHandler class.</p>
- *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
- */
-public class ChangeAcceptedTaxonToSynonymHandler extends AbstractHandler
-               implements IHandler, IPostOperationEnabled {
-       private static final Logger logger = Logger
-                       .getLogger(ChangeAcceptedTaxonToSynonymHandler.class);
-       private ChangeAcceptedTaxonToSynonymOperation operation;
-
-       private UUID newAcceptedTaxonNodeUuid;
-       private TaxonNameEditor editor;
-       
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
-        */
-       /** {@inheritDoc} */
-       public Object execute(ExecutionEvent event) throws ExecutionException {
-               
-               editor = (TaxonNameEditor) EditorUtil.getActiveEditorPage(
-                               Page.NAME);
-               TaxonNode oldAcceptedTaxonNode = ((TaxonEditorInput) editor.getEditorInput()).getTaxonNode();
-               
-               // check if taxon has no children
-               if(oldAcceptedTaxonNode.getCountChildren() > 0) {
-                       EditorUtil.warningDialog("Prerequisite not met", this, 
-                                       "The accepted taxon must not have any childen. You need to move all childen to " +
-                                       "another taxon node in the TaxonNavigator before attempting to turn the accepted " +
-                                       "taxon into a synonym.");
-                       return null;
-               }
-               
-               // Choose new accepted taxon    
-               List<UUID> excludeTaxa = new ArrayList<UUID>();
-               excludeTaxa.add(oldAcceptedTaxonNode.getUuid());
-               TaxonNode newAcceptedTaxonNode = TaxonNodeSelectionDialog.select(HandlerUtil.getActiveShell(event), 
-                               editor.getConversationHolder(), 
-                               "Choose the accepted taxon", 
-                               excludeTaxa, 
-                               null, 
-                               oldAcceptedTaxonNode.getClassification());                      
-
-               if (newAcceptedTaxonNode == null) {
-                       return null;
-               }
-               
-               newAcceptedTaxonNodeUuid = newAcceptedTaxonNode.getUuid();
-                               
-               try {
-                       operation = new ChangeAcceptedTaxonToSynonymOperation(event.getCommand().getName(), 
-                                                                       editor.getUndoContext(), oldAcceptedTaxonNode, newAcceptedTaxonNode, this, editor);
-                       EditorUtil.executeOperation(operation);
-                       
-               } catch (NotDefinedException e) {
-                       logger.warn("Command name not set");
-               }
-               
-               return null;
-               
-       }
-
-       /* (non-Javadoc)
-        * @see eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation(eu.etaxonomy.cdm.model.common.CdmBase)
-        */
-       /** {@inheritDoc} */
-       public boolean postOperation(CdmBase objectAffectedByOperation) {
-               Display.getDefault().asyncExec(new Runnable(){
-
-                       public void run() {
-                               EditorUtil.close(editor.getMultiPageTaxonEditor());
-                               
-                               try {
-                                       MultiPageTaxonEditor possibleOpenEditor = (MultiPageTaxonEditor) EditorUtil.findEditorByTaxonNodeUuid(newAcceptedTaxonNodeUuid);
-                                       if(possibleOpenEditor != null){
-                                               EditorUtil.close(possibleOpenEditor);
-                                       }
-                                       EditorUtil.openTaxonNode(newAcceptedTaxonNodeUuid);
-                               } catch (PartInitException e) {
-                                       EditorUtil.error(this.getClass(), e);
-                                       throw new RuntimeException(e);
-                               } catch (Exception e) {
-                                       EditorUtil.warningDialog("Could not create Taxon", this, e.getMessage());
-                               }
-                       }
-                       
-               });
-               
-               
-               return true;
-       }
-
-       /**
-        * <p>onComplete</p>
-        *
-        * @return a boolean.
-        */
-       public boolean onComplete() {
-               // TODO Auto-generated method stub
-               return false;
-       }       
-}
diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/operation/ChangeAcceptedTaxonToSynonymOperation.java
deleted file mode 100644 (file)
index 42dbfec..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-// $Id$
-/**
-* 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.name.operation;
-
-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.api.conversation.IConversationEnabled;
-import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
-import eu.etaxonomy.cdm.api.service.exception.DataChangeNoRollbackException;
-import eu.etaxonomy.cdm.model.taxon.Synonym;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
-import eu.etaxonomy.taxeditor.operation.AbstractPersistentPostOperation;
-import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
-import eu.etaxonomy.taxeditor.store.CdmStore;
-
-/**
- * <p>ChangeAcceptedTaxonToSynonymOperation class.</p>
- *
- * @author n.hoffmann
- * @created Jan 4, 2010
- * @version 1.0
- */
-public class ChangeAcceptedTaxonToSynonymOperation extends
-               AbstractPersistentPostOperation {
-       
-       private TaxonNode newAcceptedTaxonNode;
-
-       private TaxonNode oldTaxonNode;
-       
-       /**
-        * <p>Constructor for ChangeAcceptedTaxonToSynonymOperation.</p>
-        *
-        * @param label a {@link java.lang.String} object.
-        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
-        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
-        * @param oldTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
-        * @param newAcceptedTaxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
-        * @param conversationEnabled a {@link eu.etaxonomy.cdm.api.conversation.IConversationEnabled} object.
-        */
-       public ChangeAcceptedTaxonToSynonymOperation(String label,
-                       IUndoContext undoContext, TaxonNode oldTaxonNode, TaxonNode newAcceptedTaxonNode,
-                       IPostOperationEnabled postOperationEnabled, IConversationEnabled conversationEnabled) {
-               super(label, undoContext, oldTaxonNode, postOperationEnabled, conversationEnabled);
-               this.oldTaxonNode = oldTaxonNode;
-               this.newAcceptedTaxonNode = newAcceptedTaxonNode;
-       }
-
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public IStatus execute(IProgressMonitor monitor, IAdaptable info)
-                       throws ExecutionException {
-
-               monitor.worked(20);
-               bind();
-       Synonym synonym = null;
-               try {
-                       synonym = CdmStore.getService(ITaxonNodeService.class).makeTaxonNodeASynonymOfAnotherTaxonNode(oldTaxonNode, newAcceptedTaxonNode, null, null, null);
-               } catch (DataChangeNoRollbackException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               monitor.worked(40);
-        
-               return postExecute(synonym);
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public IStatus redo(IProgressMonitor monitor, IAdaptable info)
-                       throws ExecutionException {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       /* (non-Javadoc)
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
-        */
-       /** {@inheritDoc} */
-       @Override
-       public IStatus undo(IProgressMonitor monitor, IAdaptable info)
-                       throws ExecutionException {
-               // TODO Auto-generated method stub
-               return null;
-       }
-}
index 3bd310bd30a9439dc44ee67de235be50e600e0fc..65b9e179727c29d0e78317ea004eab4e42e61464 100644 (file)
@@ -17,6 +17,7 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 
+import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
@@ -62,7 +63,7 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
 
-       // get name from synonym
+       /*// get name from synonym
                TaxonNameBase<?, ?> synonymName = synonym.getName();
 
                // make misapplied name with synonym name
@@ -79,8 +80,8 @@ public class ChangeSynonymToMisapplicationOperation extends AbstractPostTaxonOpe
 
                // add misapplied name to taxon
                // TODO add microcitation for misapplied name to property sheet (if microcitation is indeed needed?!)
-               element.addMisappliedName(misapplication, null, null);
-
+               element.addMisappliedName(misapplication, null, null);*/
+               misapplication = CdmStore.getService(ITaxonService.class).changeSynonymToRelatedTaxon(synonym, element, TaxonRelationshipType.MISAPPLIED_NAME_FOR(), null, null);
                // redraw editor if exists
                return postExecute(misapplication);
        }
index abddcb7a1a18de65e0b3fdcb3fec0e0fdecc0d7a..945af220e58d31f4733deda4aacfa0cc2350874d 100644 (file)
@@ -31,8 +31,8 @@ import eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor;
 import eu.etaxonomy.taxeditor.editor.Page;
 import eu.etaxonomy.taxeditor.editor.TaxonEditorInput;
 import eu.etaxonomy.taxeditor.editor.name.TaxonNameEditor;
-import eu.etaxonomy.taxeditor.editor.name.operation.ChangeAcceptedTaxonToSynonymOperation;
 import eu.etaxonomy.taxeditor.editor.view.descriptive.operation.MoveDescriptionToOtherTaxonOperation;
+//import eu.etaxonomy.taxeditor.navigator.operation.ChangeAcceptedTaxonToSynonymOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 import eu.etaxonomy.taxeditor.ui.dialog.selection.TaxonNodeSelectionDialog;
index ea92e5a527891636011a7ab62a21cc5f42ccc407..d47aa7435eab5938173f057e0263bc0585622f1e 100644 (file)
                </or>
             </visibleWhen>
          </command>
+         <command
+               commandId="eu.etaxonomy.taxeditor.navigator.command.changeAcceptedToSynonym"
+               label="Change Accepted Taxon to Synonym"
+               style="push">
+               <visibleWhen
+                  checkEnabled="true">
+               <reference
+                     definitionId="isTaxonNode">
+               </reference>
+            </visibleWhen>
+         </command>
          <command
                commandId="eu.etaxonomy.taxeditor.navigation.command.moveTaxon"
                label="Move Taxon (with child taxa)"
                label="Delete"
                style="push">
          </command>
+         
       </menuContribution>
    </extension>
    <extension
             id="eu.etaxonomy.taxeditor.navigation.command.copyTaxonName"
             name="Copy">
       </command>
+      <command
+            defaultHandler="eu.etaxonomy.taxeditor.navigation.navigator.handler.ChangeAcceptedTaxonToSynonymHandler"
+            id="eu.etaxonomy.taxeditor.navigator.command.changeAcceptedToSynonym"
+            name="Change Accepted Taxon to Synonym">
+      </command>
    </extension>
    <extension
          point="org.eclipse.ui.commands">
index 2df882e501934e06fa775e58f4ebfbb5a3b4e432..ab4fc28ce2f08ef4ef55bd09bab5e59efd80b4ce 100644 (file)
@@ -47,8 +47,8 @@ import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
  */
 public class DeleteHandler extends AbstractHandler implements IHandler{
 
-       private IWorkbenchPage activePage;
-       private TaxonNavigator taxonNavigator;
+       protected IWorkbenchPage activePage;
+       protected TaxonNavigator taxonNavigator;
 
        /** {@inheritDoc} */
        @Override
@@ -137,7 +137,7 @@ public class DeleteHandler extends AbstractHandler implements IHandler{
                return null;
        }
 
-       private boolean closeObsoleteEditor(TaxonNode taxonNode){
+       protected boolean closeObsoleteEditor(TaxonNode taxonNode){
                boolean result = true;
                for (IEditorReference ref : activePage.getEditorReferences()) {
                        try {
index 1f9cea4dfdb3607a7e1bb2ab5215ebc9321d31a5..afad39fc6a9cc961ba0ac155afba4982e76fe123 100644 (file)
@@ -43,7 +43,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
 public class DeleteOperation extends AbstractPersistentPostOperation{
 
        private Set<ITaxonTreeNode> treeNodes;
-       private final TaxonDeletionConfigurator config;
+       protected final TaxonDeletionConfigurator config;
 
 
        /**