1 package eu
.etaxonomy
.taxeditor
.editor
.view
.uses
.operation
;
3 import org
.eclipse
.core
.commands
.ExecutionException
;
4 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
5 import org
.eclipse
.core
.runtime
.IAdaptable
;
6 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
7 import org
.eclipse
.core
.runtime
.IStatus
;
9 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
10 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
11 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
12 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
13 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
14 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
15 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
19 * CreateUseSummaryOperation Class
21 * @created mar 13, 2012
24 public class CreateUseSummaryOperation
extends AbstractPostOperation
{
26 public static final String ID
= "eu.etaxonomy.taxeditor.editor.use.createUseRecord";
28 private TaxonDescription description
;
29 private Feature feature
;
30 private DescriptionElementBase element
;
34 * <p>Constructor for CreateUseSummaryOperation.</p>
36 * @param label a {@link java.lang.String} object.
37 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
38 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
39 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
40 * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
41 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
43 public CreateUseSummaryOperation(String label
, IUndoContext undoContext
,
44 Taxon taxon
, TaxonDescription description
, Feature feature
, IPostOperationEnabled postOperationEnabled
) {
45 super(label
, undoContext
, taxon
, postOperationEnabled
);
47 this.description
= description
;
48 this.feature
= feature
;
52 * <p>Constructor for CreateUseSummaryOperation.</p>
54 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
55 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
56 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
57 * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
58 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
59 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
60 * @param label a {@link java.lang.String} object.
62 public CreateUseSummaryOperation(String label
,
63 IUndoContext undoContext
, Taxon taxon
,
64 TaxonDescription description
, Feature feature
,
65 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
66 this(label
, undoContext
, taxon
, description
, feature
, postOperationEnabled
);
68 this.element
= element
;
73 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
76 if (element
== null) {
78 element
= TextData
.NewInstance();
82 element
.setFeature(feature
);
83 description
.addElement(element
);
86 return postExecute(element
);
90 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
93 description
.addElement(element
);
95 return postExecute(element
);
99 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
100 throws ExecutionException
{
101 description
.removeElement(element
);
103 return postExecute(null);