performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / DeleteConceptRelationOperation.java
index 1519bb598076a722e6972cffbf61a6a423730e05..504c3f3082b50f2df0155b1e433a3f06d1efbd4d 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 java.util.Set;\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.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;\r
-import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;\r
-import eu.etaxonomy.taxeditor.store.StoreUtil;\r
-\r
-/**\r
- * Deletes a relation between two taxa. \r
- * \r
- * TODO we assume that there is only one kind of relation between two taxa. \r
- * If there are more, this operation breaks\r
- * \r
- * @author p.ciardelli\r
- * @author n.hoffmann\r
- * @created 29.01.2009\r
- * @version 1.0\r
- */\r
-public class DeleteConceptRelationOperation extends AbstractPostOperation {\r
-       \r
-       private Taxon relatedTaxon;\r
-       private TaxonRelationshipType relationshipType;\r
-       private ReferenceBase<?> citation;\r
-       private String microcitation;\r
-       private TaxonRelationship taxonRelationship;    \r
-\r
-       public DeleteConceptRelationOperation(String label,\r
-                       IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon,\r
-                       IPostOperationEnabled postOperationEnabled) {\r
-               super(label, undoContext, taxon, postOperationEnabled);\r
-               \r
-               this.relatedTaxon = relatedTaxon;\r
-               \r
-               Set<TaxonRelationship> taxonRelationships = taxon.getTaxonRelations(relatedTaxon);\r
-               \r
-               if(taxonRelationships.size() > 1){\r
-                       StoreUtil.warningDialog("Multiple relations between taxa", "There are multiple relations between the " +\r
-                                       "accepted and the related taxon. This case is not handled by the software yet");\r
-                       return;\r
-               }\r
-               \r
-               taxonRelationship = taxonRelationships.iterator().next();\r
-\r
-               relationshipType = taxonRelationship.getType();\r
-               \r
-               citation = taxonRelationship.getCitation();\r
-               microcitation = taxonRelationship.getCitationMicroReference();\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
-               // Find relation, save citation information\r
-               for (TaxonRelationship relationship : taxon.getTaxonRelations()) {\r
-                       if (relationship.getType().equals(relationshipType)\r
-                                       && relationship.getFromTaxon().equals(relatedTaxon)) {\r
-                               citation = relationship.getCitation();\r
-                               microcitation = relationship.getCitationMicroReference();\r
-                               taxonRelationship = relationship; \r
-                       }\r
-               }\r
-               monitor.worked(20);\r
-               \r
-               // Remove relation from taxon\r
-               taxon.removeTaxonRelation(taxonRelationship);\r
-               monitor.worked(40);\r
-\r
-               return postExecute(taxon);\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
-//             relatedTaxon.addTaxonRelation(relationship); // don't do nothin'\r
-               taxon.addTaxonRelation(relatedTaxon, relationshipType, citation, microcitation);\r
-               \r
-               return postExecute(relatedTaxon);\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 java.util.Set;
+
+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.reference.ReferenceBase;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
+import eu.etaxonomy.taxeditor.store.StoreUtil;
+
+/**
+ * Deletes a relation between two taxa.
+ *
+ * TODO we assume that there is only one kind of relation between two taxa.
+ * If there are more, this operation breaks
+ *
+ * @author p.ciardelli
+ * @author n.hoffmann
+ * @created 29.01.2009
+ * @version 1.0
+ */
+public class DeleteConceptRelationOperation extends AbstractPostOperation {
+       
+       private Taxon relatedTaxon;
+       private TaxonRelationshipType relationshipType;
+       private ReferenceBase<?> citation;
+       private String microcitation;
+       private TaxonRelationship taxonRelationship;    
+
+       /**
+        * <p>Constructor for DeleteConceptRelationOperation.</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 relatedTaxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
+        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
+        */
+       public DeleteConceptRelationOperation(String label,
+                       IUndoContext undoContext, Taxon taxon, Taxon relatedTaxon,
+                       IPostOperationEnabled postOperationEnabled) {
+               super(label, undoContext, taxon, postOperationEnabled);
+               
+               this.relatedTaxon = relatedTaxon;
+               
+               Set<TaxonRelationship> taxonRelationships = taxon.getTaxonRelations(relatedTaxon);
+               
+               if(taxonRelationships.size() > 1){
+                       StoreUtil.warningDialog("Multiple relations between taxa", this, "There are multiple relations between the " +
+                                       "accepted and the related taxon. This case is not handled by the software yet");
+                       return;
+               }
+               
+               taxonRelationship = taxonRelationships.iterator().next();
+
+               relationshipType = taxonRelationship.getType();
+               
+               citation = taxonRelationship.getCitation();
+               microcitation = taxonRelationship.getCitationMicroReference();
+       }
+
+       /* (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 {
+               
+               // Find relation, save citation information
+               for (TaxonRelationship relationship : taxon.getTaxonRelations()) {
+                       if (relationship.getType().equals(relationshipType)
+                                       && relationship.getFromTaxon().equals(relatedTaxon)) {
+                               citation = relationship.getCitation();
+                               microcitation = relationship.getCitationMicroReference();
+                               taxonRelationship = relationship; 
+                       }
+               }
+               monitor.worked(20);
+               
+               // Remove relation from taxon
+               taxon.removeTaxonRelation(taxonRelationship);
+               monitor.worked(40);
+
+               return postExecute(taxon);
+       }
+
+       /* (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 {
+               
+//             relatedTaxon.addTaxonRelation(relationship); // don't do nothin'
+               taxon.addTaxonRelation(relatedTaxon, relationshipType, citation, microcitation);
+               
+               return postExecute(relatedTaxon);
+       }
+}