Correct versions
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / operation / AbstractPostOperation.java
index e1559c3be6d430f4fbc157625d52871e39c918c9..5b7c68ec8230074a7de6ef72c0fd5ae812bb3636 100644 (file)
+// $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.
-*/
-
+ * Copyright (C) 2013 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.operation;
 
-import java.util.UUID;
-
 import org.eclipse.core.commands.operations.AbstractOperation;
 import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Status;
 
 import eu.etaxonomy.cdm.model.common.CdmBase;
-import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
-import eu.etaxonomy.cdm.model.taxon.Taxon;
-import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.model.common.ICdmBase;
 
 /**
- * <p>Abstract AbstractPostOperation class.</p>
+ * @author pplitzner
+ * @date 03.12.2013
  *
- * @author p.ciardelli
- * @author n.hoffmann
- * @created 14.01.2009
- * @version 1.0
  */
-public abstract class AbstractPostOperation extends AbstractOperation {
-       
-       /**
-        * 
-        */
-       protected IPostOperationEnabled postOperationEnabled;
-       
-       /** 
-        * A reference to the taxon the concrete operation is working on 
-        */
-       protected Taxon taxon;
+public abstract class AbstractPostOperation<T extends ICdmBase> extends AbstractOperation {
+
+
+    /**
+     * A reference to the {@link ICdmBase} element the concrete operation is working on
+     */
+    protected T element;
+
+    /**
+     *
+     */
+    protected IPostOperationEnabled postOperationEnabled;
+
+
+    /**
+     * <p>Constructor for AbstractPostOperation.</p>
+     *
+     * @param label a {@link java.lang.String} object.
+     * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+     */
+    protected AbstractPostOperation(String label, IUndoContext undoContext) {
+        super(label);
+        addContext(undoContext);
+    }
+
+    /**
+     * <p>Constructor for AbstractPostOperation.</p>
+     *
+     * @param label a {@link java.lang.String} object.
+     * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
+     * @param element a {@link ICdmBase} object on which this operation is working.
+     */
+    public AbstractPostOperation(String label, IUndoContext undoContext, T element) {
+        this(label, undoContext);
+        this.element = element;
+    }
 
-       /**
-        * A reference to the taxons TaxonNode
-        */
-       protected ITaxonTreeNode taxonNode;
+    /**
+     * @param label
+     * @param element
+     * @param postOperationEnabled
+     */
+    public AbstractPostOperation(String label, IUndoContext undoContext,
+            T element, IPostOperationEnabled postOperationEnabled) {
+        this(label, undoContext);
+        this.element = element;
+        this.postOperationEnabled = postOperationEnabled;
+    }
 
-       protected UUID parentNodeUuid;
+    /**
+     * This method will try to call the post operation on a possibly registered
+     * IPostOperationEnabled implementor. Objects that were affected by the operation
+     * may be passed to the registered IPostOperationEnabled implementor.
+     *
+     * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
+     * @return a {@link org.eclipse.core.runtime.IStatus} object.
+     */
+    protected IStatus postExecute(CdmBase objectAffectedByOperation) {
+       if(postOperationEnabled != null){
+               return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
+       }
+       return Status.OK_STATUS;
+    }
 
-       /**
-        * <p>Constructor for AbstractPostOperation.</p>
-        *
-        * @param label a {@link java.lang.String} object.
-        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
-        */
-       protected AbstractPostOperation(String label, IUndoContext undoContext) {
-               super(label);
-               addContext(undoContext);
-       }
-       
-       /**
-        * <p>Constructor for AbstractPostOperation.</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.
-        */
-       public AbstractPostOperation(String label, IUndoContext undoContext,
-                       Taxon taxon) {
-               this(label, undoContext);
-               
-               this.taxon = taxon;
-       }
-       
-       /**
-        * <p>Constructor for AbstractPostOperation.</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 postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
-        */
-       public AbstractPostOperation(String label, IUndoContext undoContext,
-                       Taxon taxon, IPostOperationEnabled postOperationEnabled) {
-               this(label, undoContext, taxon);
-               this.postOperationEnabled = postOperationEnabled;
-       }
-       
-       /**
-        * <p>Constructor for AbstractPostOperation.</p>
-        *
-        * @param label a {@link java.lang.String} object.
-        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
-        * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
-        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
-        */
-       public AbstractPostOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled){
-               this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled);
-               this.taxonNode = taxonNode;
-       }
-       
-       /**
-        * <p>Constructor for AbstractPostOperation.</p>
-        *
-        * @param label a {@link java.lang.String} object.
-        * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
-        * @param parentNodeUuid a {@link java.util.UUID} object.
-        * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
-        */
-       public AbstractPostOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){
-               this(label, undoContext);
-               
-               this.parentNodeUuid = parentNodeUuid;
-               this.postOperationEnabled = postOperationEnabled;
-       }
-       
-       /**
-        * <p>Constructor for AbstractPostOperation.</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.
-        */
-       public AbstractPostOperation(String label, IUndoContext undoContext,
-                       IPostOperationEnabled postOperationEnabled) {
-               this(label, undoContext);
-               this.postOperationEnabled = postOperationEnabled;
-       }
+    /**
+     * <p>Getter for the field <code>postOperationEnabled</code>.</p>
+     *
+     * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
+     */
+    public IPostOperationEnabled getPostOperationEnabled() {
+       return postOperationEnabled;
+    }
 
-       /**
-        * This method will try to call the post operation on a possibly registered
-        * IPostOperationEnabled implementor. Objects that were affected by the operation
-        * may be passed to the registered IPostOperationEnabled implementor.
-        *
-        * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
-        * @return a {@link org.eclipse.core.runtime.IStatus} object.
-        */
-       protected IStatus postExecute(CdmBase objectAffectedByOperation) {      
-               if(postOperationEnabled != null){
-                       return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
-               }
-               return Status.OK_STATUS;
-       }
-       
-       /**
-        * <p>Getter for the field <code>postOperationEnabled</code>.</p>
-        *
-        * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
-        */
-       public IPostOperationEnabled getPostOperationEnabled() {
-               return postOperationEnabled;
-       }
-       
-       
-}
+}
\ No newline at end of file