performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / CreateSynonymInNewGroupOperation.java
index 95d959506e47ca23baed5e5508e6095c6b18cefd..b89fc885042191cbe299dd11733176aa23b568ba 100644 (file)
-/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
-\r
-package eu.etaxonomy.taxeditor.operations;\r
-\r
-import org.eclipse.core.commands.ExecutionException;\r
-import org.eclipse.core.commands.operations.IUndoContext;\r
-import org.eclipse.core.runtime.IAdaptable;\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.IStatus;\r
-\r
-import eu.etaxonomy.cdm.model.name.HomotypicalGroup;\r
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;\r
-import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-\r
-/**\r
- * <ol>\r
- *     <li>Create synonym name using newSynonymText</li>\r
- *     <li>Add name to new homotypic group</li>\r
- *     <li>Create a new synonym for the taxon</li>\r
- * </ol>\r
- * @author p.ciardelli\r
- * @created 16.01.2009\r
- * @version 1.0\r
- * @author n.hoffmann\r
- */\r
-public class CreateSynonymInNewGroupOperation extends AbstractPostOperation {\r
-       \r
-       // TODO replace this with TaxonNameBase\r
-       private TaxonNameBase newSynonymName;\r
-       private SynonymRelationship newSynonymRelationship;\r
-\r
-       public CreateSynonymInNewGroupOperation(String label,\r
-                       IUndoContext undoContext, Taxon taxon, TaxonNameBase newSynonymName, IPostOperationEnabled postOperationEnabled) {\r
-               super(label, undoContext, taxon, postOperationEnabled);\r
-               \r
-               this.newSynonymName = newSynonymName;\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
-        */\r
-       @Override\r
-       public IStatus execute(IProgressMonitor monitor, IAdaptable info)\r
-                       throws ExecutionException {\r
-               \r
-               // Add name to new homotypic group\r
-               HomotypicalGroup.NewInstance().addTypifiedName(newSynonymName);\r
-               monitor.worked(20);\r
-               \r
-               // Create a new synonym for the taxon\r
-               newSynonymRelationship = taxon.addHeterotypicSynonymName(newSynonymName);\r
-               monitor.worked(40);\r
-\r
-               return postExecute(newSynonymRelationship.getSynonym());\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
-        */\r
-       @Override\r
-       public IStatus redo(IProgressMonitor monitor, IAdaptable info)\r
-                       throws ExecutionException {\r
-               return execute(monitor, info);\r
-       }\r
-\r
-       /* (non-Javadoc)\r
-        * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)\r
-        */\r
-       @Override\r
-       public IStatus undo(IProgressMonitor monitor, IAdaptable info)\r
-                       throws ExecutionException {\r
-               \r
-               // Remove the synonym \r
-               taxon.removeSynonymRelation(newSynonymRelationship);\r
-               newSynonymRelationship = null;\r
-               \r
-               return postExecute(null);\r
-       }\r
-}\r
+/**
+* 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;
+
+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;
+
+/**
+ * <ol>
+ *     <li>Create synonym name using newSynonymText</li>
+ *     <li>Add name to new homotypic group</li>
+ *     <li>Create a new synonym for the taxon</li>
+ * </ol>
+ *
+ * @author p.ciardelli
+ * @author n.hoffmann
+ * @created 16.01.2009
+ * @version 1.0
+ */
+public class CreateSynonymInNewGroupOperation extends AbstractPostOperation {
+       
+       // TODO replace this with TaxonNameBase
+       private TaxonNameBase newSynonymName;
+       private SynonymRelationship newSynonymRelationship;
+
+       /**
+        * <p>Constructor for CreateSynonymInNewGroupOperation.</p>
+        *
+        * @param label a {@link java.lang.String} object.
+        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+        * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
+        * @param newSynonymName a {@link eu.etaxonomy.cdm.model.name.TaxonNameBase} object.
+        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
+        */
+       public CreateSynonymInNewGroupOperation(String label,
+                       IUndoContext undoContext, Taxon taxon, TaxonNameBase newSynonymName, IPostOperationEnabled postOperationEnabled) {
+               super(label, undoContext, taxon, postOperationEnabled);
+               
+               this.newSynonymName = newSynonymName;
+       }
+
+       /* (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 {
+               
+               // Add name to new homotypic group
+               HomotypicalGroup.NewInstance().addTypifiedName(newSynonymName);
+               monitor.worked(20);
+               
+               // Create a new synonym for the taxon
+               newSynonymRelationship = taxon.addHeterotypicSynonymName(newSynonymName);
+               monitor.worked(40);
+
+               return postExecute(newSynonymRelationship.getSynonym());
+       }
+
+       /* (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 {
+               return execute(monitor, info);
+       }
+
+       /* (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 {
+               
+               // Remove the synonym 
+               taxon.removeSynonymRelation(newSynonymRelationship);
+               newSynonymRelationship = null;
+               
+               return postExecute(null);
+       }
+}