2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.operation
;
12 import java
.util
.UUID
;
14 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
15 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
17 import org
.eclipse
.core
.runtime
.Status
;
19 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.ITreeNode
;
21 import eu
.etaxonomy
.cdm
.model
.taxon
.ITaxonTreeNode
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
26 * <p>Abstract AbstractPostOperation class.</p>
33 public abstract class AbstractPostOperation
extends AbstractOperation
{
38 protected IPostOperationEnabled postOperationEnabled
;
41 * A reference to the taxon the concrete operation is working on
43 protected Taxon taxon
;
46 * A reference to the taxons TaxonNode
48 protected ITaxonTreeNode taxonNode
;
50 protected UUID parentNodeUuid
;
53 * <p>Constructor for AbstractPostOperation.</p>
55 * @param label a {@link java.lang.String} object.
56 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
58 protected AbstractPostOperation(String label
, IUndoContext undoContext
) {
60 addContext(undoContext
);
64 * <p>Constructor for AbstractPostOperation.</p>
66 * @param label a {@link java.lang.String} object.
67 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
68 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
70 public AbstractPostOperation(String label
, IUndoContext undoContext
,
72 this(label
, undoContext
);
78 * <p>Constructor for AbstractPostOperation.</p>
80 * @param label a {@link java.lang.String} object.
81 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
82 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
83 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
85 public AbstractPostOperation(String label
, IUndoContext undoContext
,
86 Taxon taxon
, IPostOperationEnabled postOperationEnabled
) {
87 this(label
, undoContext
, taxon
);
88 this.postOperationEnabled
= postOperationEnabled
;
92 * <p>Constructor for AbstractPostOperation.</p>
94 * @param label a {@link java.lang.String} object.
95 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
96 * @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object.
97 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
99 public AbstractPostOperation(String label
, IUndoContext undoContext
, TaxonNode taxonNode
, IPostOperationEnabled postOperationEnabled
){
100 this(label
, undoContext
, taxonNode
.getTaxon(), postOperationEnabled
);
101 this.taxonNode
= taxonNode
;
105 * <p>Constructor for AbstractPostOperation.</p>
107 * @param label a {@link java.lang.String} object.
108 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
109 * @param parentNodeUuid a {@link java.util.UUID} object.
110 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
112 public AbstractPostOperation(String label
, IUndoContext undoContext
, UUID parentNodeUuid
, IPostOperationEnabled postOperationEnabled
){
113 this(label
, undoContext
);
115 this.parentNodeUuid
= parentNodeUuid
;
116 this.postOperationEnabled
= postOperationEnabled
;
120 * <p>Constructor for AbstractPostOperation.</p>
122 * @param label a {@link java.lang.String} object.
123 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
124 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
126 public AbstractPostOperation(String label
, IUndoContext undoContext
,
127 IPostOperationEnabled postOperationEnabled
) {
128 this(label
, undoContext
);
129 this.postOperationEnabled
= postOperationEnabled
;
133 * This method will try to call the post operation on a possibly registered
134 * IPostOperationEnabled implementor. Objects that were affected by the operation
135 * may be passed to the registered IPostOperationEnabled implementor.
137 * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
138 * @return a {@link org.eclipse.core.runtime.IStatus} object.
140 protected IStatus
postExecute(CdmBase objectAffectedByOperation
) {
141 if(postOperationEnabled
!= null){
142 return postOperationEnabled
.postOperation(objectAffectedByOperation
) ? Status
.OK_STATUS
: Status
.CANCEL_STATUS
;
144 return Status
.OK_STATUS
;
148 * <p>Getter for the field <code>postOperationEnabled</code>.</p>
150 * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
152 public IPostOperationEnabled
getPostOperationEnabled() {
153 return postOperationEnabled
;