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
.operation
.AbstractPostOperation
;
21 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
22 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
25 * <p>DeleteDescriptionElementOperation class.</p>
31 public class DeleteDescriptionElementOperation
extends AbstractPostOperation
{
33 private DescriptionElementBase element
;
34 private DescriptionBase description
= null;
37 * <p>Constructor for DeleteDescriptionElementOperation.</p>
39 * @param label a {@link java.lang.String} object.
40 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
41 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
42 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
44 public DeleteDescriptionElementOperation(String label
, IUndoContext undoContext
,
45 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
46 super(label
, undoContext
, postOperationEnabled
);
48 this.element
= element
;
52 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
56 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
57 throws ExecutionException
{
59 description
= element
.getInDescription();
63 // Remove element from description
64 if (description
== null) {
65 StoreUtil
.error(this.getClass(), "Couldn't find element's description!", null);
67 description
.removeElement(element
);
71 // Redraw editor if exists
72 return postExecute(null);
76 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
80 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
81 throws ExecutionException
{
82 return execute(monitor
, info
);
86 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
90 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
91 throws ExecutionException
{
93 description
.addElement(element
);
95 return postExecute(element
);