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
.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
.DescriptionBase
;
19 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
20 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
23 * <p>DeleteDescriptionElementOperation class.</p>
29 public class DeleteDescriptionElementOperation
extends AbstractPostOperation
{
31 private DescriptionElementBase element
;
32 private DescriptionBase description
= null;
35 * <p>Constructor for DeleteDescriptionElementOperation.</p>
37 * @param label a {@link java.lang.String} object.
38 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
39 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
40 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operations.IPostOperationEnabled} object.
42 public DeleteDescriptionElementOperation(String label
, IUndoContext undoContext
,
43 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
44 super(label
, undoContext
, postOperationEnabled
);
46 this.element
= element
;
50 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
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 StoreUtil
.error(this.getClass(), "Couldn't find element's description!", null);
65 description
.removeElement(element
);
69 // Redraw editor if exists
70 return postExecute(null);
74 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
78 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
79 throws ExecutionException
{
80 return execute(monitor
, info
);
84 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
88 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
89 throws ExecutionException
{
91 description
.addElement(element
);
93 return postExecute(element
);