2 * Copyright (C) 2007 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.
10 package eu
.etaxonomy
.taxeditor
.store
.operations
;
12 import org
.eclipse
.core
.commands
.ExecutionException
;
13 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
14 import org
.eclipse
.core
.runtime
.IAdaptable
;
15 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
16 import org
.eclipse
.core
.runtime
.IStatus
;
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
;
30 public class CreateDescriptionElementOperation
extends AbstractPostOperation
{
32 private TaxonDescription description
;
33 private Feature feature
;
34 private DescriptionElementBase element
;
36 public CreateDescriptionElementOperation(String label
, IUndoContext undoContext
,
37 Taxon taxon
, TaxonDescription description
, Feature feature
, IPostOperationEnabled postOperationEnabled
) {
38 super(label
, undoContext
, taxon
, postOperationEnabled
);
40 this.description
= description
;
41 this.feature
= feature
;
51 * @param postOperationEnabled
53 public CreateDescriptionElementOperation(String label
,
54 IUndoContext undoContext
, Taxon taxon
,
55 TaxonDescription description
, Feature feature
,
56 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
57 this(label
, undoContext
, taxon
, description
, feature
, postOperationEnabled
);
59 this.element
= element
;
63 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
66 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
67 throws ExecutionException
{
69 if (element
== null) {
70 element
= TextData
.NewInstance(feature
);
72 description
.addElement(element
);
74 return postExecute(element
);
78 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
81 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
82 throws ExecutionException
{
84 description
.addElement(element
);
86 return postExecute(element
);
90 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
93 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
94 throws ExecutionException
{
96 description
.removeElement(element
);
98 return postExecute(null);