3 * Copyright (C) 2013 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.operation
;
12 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.IStatus
;
15 import org
.eclipse
.core
.runtime
.Status
;
17 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
18 import eu
.etaxonomy
.cdm
.model
.common
.ICdmBase
;
25 public abstract class AbstractPostOperation
<T
extends ICdmBase
> extends AbstractOperation
{
29 * A reference to the {@link ICdmBase} element the concrete operation is working on
36 protected IPostOperationEnabled postOperationEnabled
;
40 * <p>Constructor for AbstractPostOperation.</p>
42 * @param label a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
45 protected AbstractPostOperation(String label
, IUndoContext undoContext
) {
47 addContext(undoContext
);
51 * <p>Constructor for AbstractPostOperation.</p>
53 * @param label a {@link java.lang.String} object.
54 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
55 * @param element a {@link ICdmBase} object on which this operation is working.
57 public AbstractPostOperation(String label
, IUndoContext undoContext
, T element
) {
58 this(label
, undoContext
);
59 this.element
= element
;
65 * @param postOperationEnabled
67 public AbstractPostOperation(String label
, IUndoContext undoContext
,
68 T element
, IPostOperationEnabled postOperationEnabled
) {
69 this(label
, undoContext
);
70 this.element
= element
;
71 this.postOperationEnabled
= postOperationEnabled
;
75 * This method will try to call the post operation on a possibly registered
76 * IPostOperationEnabled implementor. Objects that were affected by the operation
77 * may be passed to the registered IPostOperationEnabled implementor.
79 * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
80 * @return a {@link org.eclipse.core.runtime.IStatus} object.
82 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
83 if(postOperationEnabled
!= null){
84 return postOperationEnabled
.postOperation(objectAffectedByOperation
) ? Status
.OK_STATUS
: Status
.CANCEL_STATUS
;
86 return Status
.OK_STATUS
;
90 * <p>Getter for the field <code>postOperationEnabled</code>.</p>
92 * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
94 public IPostOperationEnabled
getPostOperationEnabled() {
95 return postOperationEnabled
;