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
;
28 * CreateUseSummaryOperation Class
30 * @created mar 13, 2012
33 public class CreateUseSummaryOperation
extends AbstractPostOperation
{
35 public static final String ID
= "eu.etaxonomy.taxeditor.editor.use.createUseRecord";
37 private final DescriptionBase
<?
> description
;
38 private final Feature feature
;
39 private DescriptionElementBase element
;
43 * <p>Constructor for CreateUseSummaryOperation.</p>
45 * @param label a {@link java.lang.String} object.
46 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
47 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
48 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
49 * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
50 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
52 public CreateUseSummaryOperation(String label
, IUndoContext undoContext
, DescriptionBase
<?
> description
, Feature feature
, IPostOperationEnabled postOperationEnabled
) {
53 super(label
, undoContext
, (Taxon
)null, postOperationEnabled
);
55 this.description
= description
;
56 this.feature
= feature
;
60 * <p>Constructor for CreateUseSummaryOperation.</p>
62 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
63 * @param taxon a {@link eu.etaxonomy.cdm.model.taxon.Taxon} object.
64 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
65 * @param feature a {@link eu.etaxonomy.cdm.model.description.Feature} object.
66 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
67 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
68 * @param label a {@link java.lang.String} object.
70 public CreateUseSummaryOperation(String label
,
71 IUndoContext undoContext
, Taxon taxon
,
72 TaxonDescription description
, Feature feature
,
73 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
74 this(label
, undoContext
, description
, feature
, postOperationEnabled
);
76 this.element
= element
;
81 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
82 throws ExecutionException
{
84 if (element
== null) {
86 element
= TextData
.NewInstance();
90 element
.setFeature(feature
);
91 description
.addElement(element
);
94 return postExecute(element
);
98 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
99 throws ExecutionException
{
101 description
.addElement(element
);
103 return postExecute(element
);
107 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
108 throws ExecutionException
{
109 description
.removeElement(element
);
111 return postExecute(null);