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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.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
.taxon
.Taxon
;
20 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
21 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
22 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
23 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
24 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
27 * <p>DeleteDescriptionElementOperation class.</p>
32 public class DeleteDescriptionElementOperation
extends AbstractPostTaxonOperation
{
34 private final DescriptionElementBase element
;
35 private DescriptionBase
<?
> description
= null;
38 * <p>Constructor for DeleteDescriptionElementOperation.</p>
40 * @param label a {@link java.lang.String} object.
41 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
42 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
43 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
45 public DeleteDescriptionElementOperation(String label
, IUndoContext undoContext
,
46 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
,
47 ICdmEntitySessionEnabled
<Taxon
> cdmEntitySessionEnabled
) {
48 super(label
, undoContext
, postOperationEnabled
, cdmEntitySessionEnabled
);
50 this.element
= element
;
54 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
55 throws ExecutionException
{
57 description
= element
.getInDescription();
61 // Remove element from description
62 if (description
== null) {
63 MessagingUtils
.error(this.getClass(), Messages
.DeleteDescriptionElementOperation_DESC_NOT_FOUND
, null);
65 description
.removeElement(element
);
69 // Redraw editor if exists
70 return postExecute(description
);
74 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
75 throws ExecutionException
{
76 return execute(monitor
, info
);
80 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
81 throws ExecutionException
{
83 description
.addElement(element
);
85 return postExecute(element
);