merge from trunk
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / name / operation / DeleteSynonymOperation.java
index 159840d6531da0917db99d22f394842d580dc5ef..8b5a61b59438153b66c920a1acb7f073d0bf2d21 100644 (file)
@@ -1,8 +1,8 @@
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -17,12 +17,12 @@ import org.eclipse.core.runtime.IAdaptable;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
 
+import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
 import eu.etaxonomy.cdm.api.service.ITaxonService;
 import eu.etaxonomy.cdm.model.taxon.Synonym;
 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
 import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
-import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
@@ -33,9 +33,9 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * @created 14.01.2009
  * @version 1.0
  */
-public class DeleteSynonymOperation extends AbstractPostOperation {
-       
-       private Synonym synonym;
+public class DeleteSynonymOperation extends AbstractPostTaxonOperation {
+
+       private final Synonym synonym;
        private Set<SynonymRelationshipType> synonymTypes;
 
        /**
@@ -60,33 +60,33 @@ public class DeleteSynonymOperation extends AbstractPostOperation {
        @Override
        public IStatus execute(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
-               
+
                // Store synonymRelationshipType for later undo operations
-                               synonymTypes = synonym.getRelationType(taxon);
+                               synonymTypes = synonym.getRelationType(element);
                                monitor.worked(20);
-                               
+
                                // Remove synonym from taxon
-                               
+
                                ICdmApplicationConfiguration controller;
-                               
+
                                controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
-                               
+
                                ITaxonService service = controller.getTaxonService();
                                if (synonym.getId() == 0){
-                                       taxon.removeSynonym(synonym);
-                                       
+                                       element.removeSynonym(synonym);
+
                                } else {
                                        service.deleteSynonym(synonym, null);
                                }
                        //      taxon.removeSynonym(synonym);
 //                             CdmStore.getTaxonService().deleteSynonymRelationships(synonym);
 //                             CdmStore.getTaxonService().delete(synonym);
-                               
+
                                monitor.worked(40);
 
                                // Redraw editor if exists
-                               
-                               return postExecute(taxon);
+
+                               return postExecute(element);
        }
 
        /* (non-Javadoc)
@@ -95,7 +95,7 @@ public class DeleteSynonymOperation extends AbstractPostOperation {
        /** {@inheritDoc} */
        @Override
        public IStatus redo(IProgressMonitor monitor, IAdaptable info)
-                       throws ExecutionException {             
+                       throws ExecutionException {
                return execute(monitor, info);
        }
 
@@ -106,12 +106,12 @@ public class DeleteSynonymOperation extends AbstractPostOperation {
        @Override
        public IStatus undo(IProgressMonitor monitor, IAdaptable info)
                        throws ExecutionException {
-               
+
                // Add synonym to taxon
                for (SynonymRelationshipType synonymType : synonymTypes){
-                       taxon.addSynonym(synonym, synonymType);
+                       element.addSynonym(synonym, synonymType);
                }
-               
+
                // Redraw editor if exists
                return postExecute(synonym);
        }