Revision 0a534d09
Added by Patrick Plitzner over 10 years ago
- adapted sub classes of AbstractPostOperation
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/operation/AbstractPostOperation.java | ||
---|---|---|
10 | 10 |
package eu.etaxonomy.taxeditor.operation; |
11 | 11 |
|
12 | 12 |
import org.eclipse.core.commands.operations.AbstractOperation; |
13 |
import org.eclipse.core.commands.operations.IUndoContext; |
|
13 | 14 |
import org.eclipse.core.runtime.IStatus; |
14 | 15 |
import org.eclipse.core.runtime.Status; |
15 | 16 |
|
16 | 17 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
18 |
import eu.etaxonomy.cdm.model.common.ICdmBase; |
|
17 | 19 |
|
18 | 20 |
/** |
19 | 21 |
* @author pplitzner |
20 | 22 |
* @date 03.12.2013 |
21 | 23 |
* |
22 | 24 |
*/ |
23 |
public abstract class AbstractPostOperation extends AbstractOperation { |
|
25 |
public abstract class AbstractPostOperation<T extends ICdmBase> extends AbstractOperation { |
|
26 |
|
|
24 | 27 |
|
25 | 28 |
/** |
26 |
* |
|
29 |
* A reference to the {@link ICdmBase} element the concrete operation is working on |
|
30 |
*/ |
|
31 |
protected T element; |
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
27 | 35 |
*/ |
28 | 36 |
protected IPostOperationEnabled postOperationEnabled; |
29 | 37 |
|
38 |
|
|
30 | 39 |
/** |
31 |
* @param label |
|
40 |
* <p>Constructor for AbstractPostOperation.</p> |
|
41 |
* |
|
42 |
* @param label a {@link java.lang.String} object. |
|
43 |
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object. |
|
32 | 44 |
*/ |
33 |
public AbstractPostOperation(String label) {
|
|
45 |
protected AbstractPostOperation(String label, IUndoContext undoContext) {
|
|
34 | 46 |
super(label); |
47 |
addContext(undoContext); |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* <p>Constructor for AbstractPostOperation.</p> |
|
52 |
* |
|
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. |
|
56 |
*/ |
|
57 |
public AbstractPostOperation(String label, IUndoContext undoContext, T element) { |
|
58 |
this(label, undoContext); |
|
59 |
this.element = element; |
|
60 |
} |
|
61 |
|
|
62 |
/** |
|
63 |
* @param label |
|
64 |
* @param element |
|
65 |
* @param postOperationEnabled |
|
66 |
*/ |
|
67 |
public AbstractPostOperation(String label, IUndoContext undoContext, |
|
68 |
T element, IPostOperationEnabled postOperationEnabled) { |
|
69 |
this(label, undoContext); |
|
70 |
this.element = element; |
|
71 |
this.postOperationEnabled = postOperationEnabled; |
|
35 | 72 |
} |
36 | 73 |
|
37 | 74 |
/** |
... | ... | |
42 | 79 |
* @param objectAffectedByOperation the affected object. Should be <code>null</code> if not needed |
43 | 80 |
* @return a {@link org.eclipse.core.runtime.IStatus} object. |
44 | 81 |
*/ |
45 |
protected IStatus postExecute(CdmBase objectAffectedByOperation) {
|
|
82 |
protected IStatus postExecute(CdmBase objectAffectedByOperation) { |
|
46 | 83 |
if(postOperationEnabled != null){ |
47 | 84 |
return postOperationEnabled.postOperation(objectAffectedByOperation) ? Status.OK_STATUS : Status.CANCEL_STATUS; |
48 | 85 |
} |
Also available in: Unified diff