2 * Copyright (C) 2011 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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.uses
.operation
;
11 import org
.eclipse
.core
.commands
.ExecutionException
;
12 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
13 import org
.eclipse
.core
.runtime
.IAdaptable
;
14 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
15 import org
.eclipse
.core
.runtime
.IStatus
;
17 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
18 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
20 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
21 import eu
.etaxonomy
.cdm
.model
.description
.TextData
;
22 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
23 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
24 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
27 * CreateUseSummaryOperation Class
29 * @created mar 13, 2012
31 public class CreateUseSummaryOperation
extends AbstractPostOperation
<Taxon
> {
33 public static final String ID
= "eu.etaxonomy.taxeditor.editor.use.createUseRecord"; //$NON-NLS-1$
35 private final DescriptionBase
<?
> description
;
36 private final Feature feature
;
37 private DescriptionElementBase element
;
40 * <p>Constructor for CreateUseSummaryOperation.</p>
42 * @param label a {@link java.lang.String} object.
43 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
44 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
45 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
46 * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
47 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
49 public CreateUseSummaryOperation(String label
, IUndoContext undoContext
, DescriptionBase
<?
> description
, Feature feature
, IPostOperationEnabled postOperationEnabled
) {
50 super(label
, undoContext
, (Taxon
)null, postOperationEnabled
);
52 this.description
= description
;
53 this.feature
= feature
;
57 * <p>Constructor for CreateUseSummaryOperation.</p>
59 public CreateUseSummaryOperation(String label
,
60 IUndoContext undoContext
, Taxon taxon
,
61 TaxonDescription description
, Feature feature
,
62 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
64 this(label
, undoContext
, description
, feature
, postOperationEnabled
);
65 this.element
= element
;
69 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
70 throws ExecutionException
{
72 if (element
== null) {
73 element
= TextData
.NewInstance();
76 element
.setFeature(feature
);
77 description
.addElement(element
);
80 return postExecute(element
);
84 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
85 throws ExecutionException
{
87 description
.addElement(element
);
89 return postExecute(element
);
93 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
94 throws ExecutionException
{
95 description
.removeElement(element
);
97 return postExecute(null);