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
.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>
33 public class DeleteDescriptionElementOperation
extends AbstractPostTaxonOperation
{
35 private final DescriptionElementBase element
;
36 private DescriptionBase description
= null;
39 * <p>Constructor for DeleteDescriptionElementOperation.</p>
41 * @param label a {@link java.lang.String} object.
42 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
43 * @param element a {@link eu.etaxonomy.cdm.model.description.DescriptionElementBase} object.
44 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
46 public DeleteDescriptionElementOperation(String label
, IUndoContext undoContext
,
47 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
,
48 ICdmEntitySessionEnabled cdmEntitySessionEnabled
) {
49 super(label
, undoContext
, postOperationEnabled
, cdmEntitySessionEnabled
);
51 this.element
= element
;
55 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
59 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
60 throws ExecutionException
{
62 description
= element
.getInDescription();
66 // Remove element from description
67 if (description
== null) {
68 MessagingUtils
.error(this.getClass(), Messages
.DeleteDescriptionElementOperation_DESC_NOT_FOUND
, null);
70 description
.removeElement(element
);
74 // Redraw editor if exists
75 return postExecute(description
);
79 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
83 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
84 throws ExecutionException
{
85 return execute(monitor
, info
);
89 * @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
.addElement(element
);
98 return postExecute(element
);