performed javacscript:fix and worked on documentation
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / operations / CreateDescriptionElementOperation.java
index 96c24846907b7796de14159907a320169c6fcaac..57209a3eee3b30da1e5ef30ce55da7d640e68fa8 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.description.CategoricalData;\r
-import eu.etaxonomy.cdm.model.description.CommonTaxonName;\r
-import eu.etaxonomy.cdm.model.description.DescriptionElementBase;\r
-import eu.etaxonomy.cdm.model.description.Distribution;\r
-import eu.etaxonomy.cdm.model.description.Feature;\r
-import eu.etaxonomy.cdm.model.description.IndividualsAssociation;\r
-import eu.etaxonomy.cdm.model.description.QuantitativeData;\r
-import eu.etaxonomy.cdm.model.description.TaxonDescription;\r
-import eu.etaxonomy.cdm.model.description.TaxonInteraction;\r
-import eu.etaxonomy.cdm.model.description.TextData;\r
-import eu.etaxonomy.cdm.model.taxon.Taxon;\r
-\r
-/**\r
- * @author p.ciardelli\r
- * @created 05.02.2009\r
- * @version 1.0\r
- * @author n.hoffmann\r
- */\r
-public class CreateDescriptionElementOperation extends AbstractPostOperation {\r
-       \r
-       public static final String ID = "eu.etaxonomy.taxeditor.editor.description.createDescriptionElement";\r
-       \r
-       private TaxonDescription description;\r
-       private Feature feature;\r
-       private DescriptionElementBase element;\r
-\r
-       public CreateDescriptionElementOperation(String label, IUndoContext undoContext,\r
-                       Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {\r
-               super(label, undoContext, taxon, postOperationEnabled);\r
-               \r
-               this.description = description;\r
-               this.feature = feature;\r
-       }\r
-\r
-       /**\r
-        * @param name\r
-        * @param undoContext\r
-        * @param taxon\r
-        * @param description\r
-        * @param feature\r
-        * @param element\r
-        * @param postOperationEnabled\r
-        */\r
-       public CreateDescriptionElementOperation(String label,\r
-                       IUndoContext undoContext, Taxon taxon,\r
-                       TaxonDescription description, Feature feature,\r
-                       DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {\r
-               this(label, undoContext, taxon, description, feature, postOperationEnabled);\r
-               \r
-               this.element = element;\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
-               monitor.worked(20);\r
-               if (element == null) {\r
-                       if (feature.isSupportsCommonTaxonName()) {\r
-                               element = CommonTaxonName.NewInstance("", null);\r
-                       } \r
-                       else if (feature.isSupportsDistribution()) {\r
-                               element = Distribution.NewInstance();\r
-                       } \r
-                       else if(feature.isSupportsTaxonInteraction()){\r
-                               element = TaxonInteraction.NewInstance();\r
-                       }\r
-                       else if(feature.isSupportsIndividualAssociation()){\r
-                               element = IndividualsAssociation.NewInstance();\r
-                       }\r
-                       else if(feature.isSupportsCategoricalData()){\r
-                               element = CategoricalData.NewInstance();\r
-                       }\r
-                       else if(feature.isSupportsQuantitativeData()){\r
-                               element = QuantitativeData.NewInstance();\r
-                       }\r
-                       else {\r
-                               element = TextData.NewInstance();\r
-                       }\r
-               }\r
-\r
-               element.setFeature(feature);\r
-               description.addElement(element);\r
-               monitor.worked(40);\r
-\r
-               return postExecute(element);\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
-               \r
-               description.addElement(element);\r
-               \r
-               return postExecute(element);\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
-               description.removeElement(element);\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.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.CommonTaxonName;
+import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
+import eu.etaxonomy.cdm.model.description.Distribution;
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
+import eu.etaxonomy.cdm.model.description.QuantitativeData;
+import eu.etaxonomy.cdm.model.description.TaxonDescription;
+import eu.etaxonomy.cdm.model.description.TaxonInteraction;
+import eu.etaxonomy.cdm.model.description.TextData;
+import eu.etaxonomy.cdm.model.taxon.Taxon;
+
+/**
+ * <p>CreateDescriptionElementOperation class.</p>
+ *
+ * @author p.ciardelli
+ * @author n.hoffmann
+ * @created 05.02.2009
+ * @version 1.0
+ */
+public class CreateDescriptionElementOperation extends AbstractPostOperation {
+       
+       /** Constant <code>ID="eu.etaxonomy.taxeditor.editor.descripti"{trunked}</code> */
+       public static final String ID = "eu.etaxonomy.taxeditor.editor.description.createDescriptionElement";
+       
+       private TaxonDescription description;
+       private Feature feature;
+       private DescriptionElementBase element;
+
+       /**
+        * <p>Constructor for CreateDescriptionElementOperation.</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 description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
+        * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
+        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
+        */
+       public CreateDescriptionElementOperation(String label, IUndoContext undoContext,
+                       Taxon taxon, TaxonDescription description, Feature feature, IPostOperationEnabled postOperationEnabled) {
+               super(label, undoContext, taxon, postOperationEnabled);
+               
+               this.description = description;
+               this.feature = feature;
+       }
+
+       /**
+        * <p>Constructor for CreateDescriptionElementOperation.</p>
+        *
+        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+        * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
+        * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
+        * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
+        * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
+        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
+        * @param label a {@link java.lang.String} object.
+        */
+       public CreateDescriptionElementOperation(String label,
+                       IUndoContext undoContext, Taxon taxon,
+                       TaxonDescription description, Feature feature,
+                       DescriptionElementBase element, IPostOperationEnabled postOperationEnabled) {
+               this(label, undoContext, taxon, description, feature, postOperationEnabled);
+               
+               this.element = element;
+       }
+
+       /* (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);
+               if (element == null) {
+                       if (feature.isSupportsCommonTaxonName()) {
+                               element = CommonTaxonName.NewInstance("", null);
+                       } 
+                       else if (feature.isSupportsDistribution()) {
+                               element = Distribution.NewInstance();
+                       } 
+                       else if(feature.isSupportsTaxonInteraction()){
+                               element = TaxonInteraction.NewInstance();
+                       }
+                       else if(feature.isSupportsIndividualAssociation()){
+                               element = IndividualsAssociation.NewInstance();
+                       }
+                       else if(feature.isSupportsCategoricalData()){
+                               element = CategoricalData.NewInstance();
+                       }
+                       else if(feature.isSupportsQuantitativeData()){
+                               element = QuantitativeData.NewInstance();
+                       }
+                       else {
+                               element = TextData.NewInstance();
+                       }
+               }
+
+               element.setFeature(feature);
+               description.addElement(element);
+               monitor.worked(40);
+
+               return postExecute(element);
+       }
+
+       /* (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 {
+               
+               description.addElement(element);
+               
+               return postExecute(element);
+       }
+
+       /* (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 {
+               
+               description.removeElement(element);
+               
+               return postExecute(null);
+       }
+}