fix delete of classifications
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / operation / AbstractPostOperation.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.taxeditor.operation;
11
12 import java.util.UUID;
13
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;
18
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;
24
25 /**
26 * <p>Abstract AbstractPostOperation class.</p>
27 *
28 * @author p.ciardelli
29 * @author n.hoffmann
30 * @created 14.01.2009
31 * @version 1.0
32 */
33 public abstract class AbstractPostOperation extends AbstractOperation {
34
35 /**
36 *
37 */
38 protected IPostOperationEnabled postOperationEnabled;
39
40 /**
41 * A reference to the taxon the concrete operation is working on
42 */
43 protected Taxon taxon;
44
45 /**
46 * A reference to the taxons TaxonNode
47 */
48 protected ITaxonTreeNode taxonNode;
49
50 protected UUID parentNodeUuid;
51
52 /**
53 * <p>Constructor for AbstractPostOperation.</p>
54 *
55 * @param label a {@link java.lang.String} object.
56 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
57 */
58 protected AbstractPostOperation(String label, IUndoContext undoContext) {
59 super(label);
60 addContext(undoContext);
61 }
62
63 /**
64 * <p>Constructor for AbstractPostOperation.</p>
65 *
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.
69 */
70 public AbstractPostOperation(String label, IUndoContext undoContext,
71 Taxon taxon) {
72 this(label, undoContext);
73
74 this.taxon = taxon;
75 }
76
77 /**
78 * <p>Constructor for AbstractPostOperation.</p>
79 *
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.
84 */
85 public AbstractPostOperation(String label, IUndoContext undoContext,
86 Taxon taxon, IPostOperationEnabled postOperationEnabled) {
87 this(label, undoContext, taxon);
88 this.postOperationEnabled = postOperationEnabled;
89 }
90
91 /**
92 * <p>Constructor for AbstractPostOperation.</p>
93 *
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.
98 */
99 public AbstractPostOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled){
100 this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled);
101 this.taxonNode = taxonNode;
102 }
103
104 /**
105 * <p>Constructor for AbstractPostOperation.</p>
106 *
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.
111 */
112 public AbstractPostOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){
113 this(label, undoContext);
114
115 this.parentNodeUuid = parentNodeUuid;
116 this.postOperationEnabled = postOperationEnabled;
117 }
118
119 /**
120 * <p>Constructor for AbstractPostOperation.</p>
121 *
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.
125 */
126 public AbstractPostOperation(String label, IUndoContext undoContext,
127 IPostOperationEnabled postOperationEnabled) {
128 this(label, undoContext);
129 this.postOperationEnabled = postOperationEnabled;
130 }
131
132 /**
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.
136 *
137 * @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed
138 * @return a {@link org.eclipse.core.runtime.IStatus} object.
139 */
140 protected IStatus postExecute(CdmBase objectAffectedByOperation) {
141 if(postOperationEnabled != null){
142 return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS;
143 }
144 return Status.OK_STATUS;
145 }
146
147 /**
148 * <p>Getter for the field <code>postOperationEnabled</code>.</p>
149 *
150 * @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
151 */
152 public IPostOperationEnabled getPostOperationEnabled() {
153 return postOperationEnabled;
154 }
155
156
157 }