package eu.etaxonomy.taxeditor.operation;
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.common.ICdmBase;
/**
* @author pplitzner
* @date 03.12.2013
*
*/
-public abstract class AbstractPostOperation extends AbstractOperation {
+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;
+
/**
- * @param label
+ * <p>Constructor for AbstractPostOperation.</p>
+ *
+ * @param label a {@link java.lang.String} object.
+ * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
*/
- public AbstractPostOperation(String label) {
+ 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;
+ }
+
+ /**
+ * @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;
}
/**
* @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) {
+ protected IStatus postExecute(CdmBase objectAffectedByOperation) {
if(postOperationEnabled != null){
return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
}