1 package eu
.etaxonomy
.taxeditor
.editor
.view
.uses
.operation
;
4 import org
.eclipse
.core
.commands
.ExecutionException
;
5 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
6 import org
.eclipse
.core
.runtime
.IAdaptable
;
7 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
8 import org
.eclipse
.core
.runtime
.IStatus
;
10 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
11 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
12 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
13 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
14 import eu
.etaxonomy
.taxeditor
.store
.StoreUtil
;
17 * The context manager mediates context start/stop and workbench shutdowns to all registered listeners.
20 * @created mar 13, 2012
23 public class DeleteUseRecordOperation
extends AbstractPostOperation
{
24 private DescriptionElementBase element
;
25 private DescriptionBase description
= null;
28 public DeleteUseRecordOperation(String label
, IUndoContext undoContext
,
29 DescriptionElementBase element
, IPostOperationEnabled postOperationEnabled
) {
30 super(label
, undoContext
, postOperationEnabled
);
32 this.element
= element
;
37 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
38 throws ExecutionException
{
39 description
= element
.getInDescription();
43 // Remove element from description
44 if (description
== null) {
45 StoreUtil
.error(this.getClass(), "Couldn't find element's description!", null);
47 description
.removeElement(element
);
51 // Redraw editor if exists
52 return postExecute(null);
57 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
58 throws ExecutionException
{
59 return execute(monitor
, info
);
64 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
65 throws ExecutionException
{
67 description
.addElement(element
);
69 return postExecute(element
);