Revision 343457b6
Added by Patrick Plitzner over 10 years ago
- extracted super class from AbstractPostOperation (same name)
- created sub class AbstractPost Taxon/Describable Operation
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java | ||
---|---|---|
1 |
// $Id$ |
|
1 | 2 |
/** |
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 |
|
|
3 |
* Copyright (C) 2013 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
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. |
|
9 |
*/ |
|
10 | 10 |
package eu.etaxonomy.taxeditor.operation; |
11 | 11 |
|
12 |
import java.util.UUID; |
|
13 |
|
|
14 | 12 |
import org.eclipse.core.commands.operations.AbstractOperation; |
15 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
16 | 13 |
import org.eclipse.core.runtime.IStatus; |
17 | 14 |
import org.eclipse.core.runtime.Status; |
18 | 15 |
|
19 | 16 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
20 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
|
21 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
22 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
23 | 17 |
|
24 | 18 |
/** |
25 |
* <p>Abstract AbstractPostOperation class.</p> |
|
19 |
* @author pplitzner |
|
20 |
* @date 03.12.2013 |
|
26 | 21 |
* |
27 |
* @author p.ciardelli |
|
28 |
* @author n.hoffmann |
|
29 |
* @created 14.01.2009 |
|
30 |
* @version 1.0 |
|
31 | 22 |
*/ |
32 | 23 |
public abstract class AbstractPostOperation extends AbstractOperation { |
33 |
|
|
34 |
/** |
|
35 |
* |
|
36 |
*/ |
|
37 |
protected IPostOperationEnabled postOperationEnabled; |
|
38 |
|
|
39 |
/** |
|
40 |
* A reference to the taxon the concrete operation is working on |
|
41 |
*/ |
|
42 |
protected Taxon taxon; |
|
43 |
|
|
44 |
/** |
|
45 |
* A reference to the taxons TaxonNode |
|
46 |
*/ |
|
47 |
protected ITaxonTreeNode taxonNode; |
|
48 |
|
|
49 |
protected UUID parentNodeUuid; |
|
50 |
|
|
51 |
/** |
|
52 |
* <p>Constructor for AbstractPostOperation.</p> |
|
53 |
* |
|
54 |
* @param label a {@link java.lang.String} object. |
|
55 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
56 |
*/ |
|
57 |
protected AbstractPostOperation(String label, IUndoContext undoContext) { |
|
58 |
super(label); |
|
59 |
addContext(undoContext); |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* <p>Constructor for AbstractPostOperation.</p> |
|
64 |
* |
|
65 |
* @param label a {@link java.lang.String} object. |
|
66 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
67 |
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. |
|
68 |
*/ |
|
69 |
public AbstractPostOperation(String label, IUndoContext undoContext, |
|
70 |
Taxon taxon) { |
|
71 |
this(label, undoContext); |
|
72 |
|
|
73 |
this.taxon = taxon; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* <p>Constructor for AbstractPostOperation.</p> |
|
78 |
* |
|
79 |
* @param label a {@link java.lang.String} object. |
|
80 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
81 |
* @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object. |
|
82 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
|
83 |
*/ |
|
84 |
public AbstractPostOperation(String label, IUndoContext undoContext, |
|
85 |
Taxon taxon, IPostOperationEnabled postOperationEnabled) { |
|
86 |
this(label, undoContext, taxon); |
|
87 |
this.postOperationEnabled = postOperationEnabled; |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* <p>Constructor for AbstractPostOperation.</p> |
|
92 |
* |
|
93 |
* @param label a {@link java.lang.String} object. |
|
94 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
95 |
* @param taxonNode a {@link eu.etaxonomy.cdm.model.taxon.TaxonNode} object. |
|
96 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
|
97 |
*/ |
|
98 |
public AbstractPostOperation(String label, IUndoContext undoContext, TaxonNode taxonNode, IPostOperationEnabled postOperationEnabled){ |
|
99 |
this(label, undoContext, taxonNode.getTaxon(), postOperationEnabled); |
|
100 |
this.taxonNode = taxonNode; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* <p>Constructor for AbstractPostOperation.</p> |
|
105 |
* |
|
106 |
* @param label a {@link java.lang.String} object. |
|
107 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
108 |
* @param parentNodeUuid a {@link java.util.UUID} object. |
|
109 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
|
110 |
*/ |
|
111 |
public AbstractPostOperation(String label, IUndoContext undoContext, UUID parentNodeUuid, IPostOperationEnabled postOperationEnabled){ |
|
112 |
this(label, undoContext); |
|
113 |
|
|
114 |
this.parentNodeUuid = parentNodeUuid; |
|
115 |
this.postOperationEnabled = postOperationEnabled; |
|
116 |
} |
|
117 |
|
|
118 |
/** |
|
119 |
* <p>Constructor for AbstractPostOperation.</p> |
|
120 |
* |
|
121 |
* @param label a {@link java.lang.String} object. |
|
122 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
123 |
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
|
124 |
*/ |
|
125 |
public AbstractPostOperation(String label, IUndoContext undoContext, |
|
126 |
IPostOperationEnabled postOperationEnabled) { |
|
127 |
this(label, undoContext); |
|
128 |
this.postOperationEnabled = postOperationEnabled; |
|
129 |
} |
|
130 | 24 |
|
131 |
/** |
|
132 |
* This method will try to call the post operation on a possibly registered |
|
133 |
* IPostOperationEnabled implementor. Objects that were affected by the operation |
|
134 |
* may be passed to the registered IPostOperationEnabled implementor. |
|
135 |
* |
|
136 |
* @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed |
|
137 |
* @return a {@link org.eclipse.core.runtime.IStatus} object. |
|
138 |
*/ |
|
139 |
protected IStatus postExecute(CdmBase objectAffectedByOperation) { |
|
140 |
if(postOperationEnabled != null){ |
|
141 |
return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS; |
|
142 |
} |
|
143 |
return Status.OK_STATUS; |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* <p>Getter for the field <code>postOperationEnabled</code>.</p> |
|
148 |
* |
|
149 |
* @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
|
150 |
*/ |
|
151 |
public IPostOperationEnabled getPostOperationEnabled() { |
|
152 |
return postOperationEnabled; |
|
153 |
} |
|
154 |
|
|
155 |
|
|
156 |
} |
|
25 |
/** |
|
26 |
* |
|
27 |
*/ |
|
28 |
protected IPostOperationEnabled postOperationEnabled; |
|
29 |
|
|
30 |
/** |
|
31 |
* @param label |
|
32 |
*/ |
|
33 |
public AbstractPostOperation(String label) { |
|
34 |
super(label); |
|
35 |
} |
|
36 |
|
|
37 |
/** |
|
38 |
* This method will try to call the post operation on a possibly registered |
|
39 |
* IPostOperationEnabled implementor. Objects that were affected by the operation |
|
40 |
* may be passed to the registered IPostOperationEnabled implementor. |
|
41 |
* |
|
42 |
* @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed |
|
43 |
* @return a {@link org.eclipse.core.runtime.IStatus} object. |
|
44 |
*/ |
|
45 |
protected IStatus postExecute(CdmBase objectAffectedByOperation) { |
|
46 |
if(postOperationEnabled != null){ |
|
47 |
return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS; |
|
48 |
} |
|
49 |
return Status.OK_STATUS; |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* <p>Getter for the field <code>postOperationEnabled</code>.</p> |
|
54 |
* |
|
55 |
* @return a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object. |
|
56 |
*/ |
|
57 |
public IPostOperationEnabled getPostOperationEnabled() { |
|
58 |
return postOperationEnabled; |
|
59 |
} |
|
60 |
|
|
61 |
} |
Also available in: Unified diff