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
.editor
.view
.descriptive
.operation
;
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
.DescriptionBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
22 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
23 import eu
.etaxonomy
.taxeditor
.session
.ICdmEntitySessionEnabled
;
26 * <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 cdmEntitySessionEnabled
) {
48 super(label
, undoContext
, postOperationEnabled
, cdmEntitySessionEnabled
);
50 this.element
= element
;
54 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
58 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
59 throws ExecutionException
{
61 description
= element
.getInDescription();
65 // Remove element from description
66 if (description
== null) {
67 MessagingUtils
.error(this.getClass(), "Couldn't find element's description!", null);
69 description
.removeElement(element
);
73 // Redraw editor if exists
74 return postExecute(description
);
78 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
82 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
83 throws ExecutionException
{
84 return execute(monitor
, info
);
88 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
92 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
93 throws ExecutionException
{
95 description
.addElement(element
);
97 return postExecute(element
);