(no commit message)
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / view / uses / operation / DeleteTaxonUseOperation.java
1 package eu.etaxonomy.taxeditor.editor.view.uses.operation;
2
3 import org.eclipse.core.commands.ExecutionException;
4 import org.eclipse.core.commands.operations.IUndoContext;
5 import org.eclipse.core.runtime.IAdaptable;
6 import org.eclipse.core.runtime.IProgressMonitor;
7 import org.eclipse.core.runtime.IStatus;
8
9 import eu.etaxonomy.cdm.model.description.TaxonDescription;
10 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
11 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
12
13 public class DeleteTaxonUseOperation extends AbstractPostOperation {
14
15 private TaxonDescription description;
16
17 /**
18 * <p>Constructor for DeleteTaxonDescriptionOperation.</p>
19 *
20 * @param label a {@link java.lang.String} object.
21 * @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
22 * @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
23 * @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
24 */
25 public DeleteTaxonUseOperation(String label, IUndoContext undoContext,
26 TaxonDescription description, IPostOperationEnabled postOperationEnabled) {
27 super(label, undoContext, postOperationEnabled);
28
29 this.description = description;
30 taxon = description.getTaxon();
31 }
32
33 /* (non-Javadoc)
34 * @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
35 */
36 /** {@inheritDoc} */
37 @Override
38 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
39 throws ExecutionException {
40
41 monitor.worked(20);
42 taxon.removeDescription(description);
43 monitor.worked(40);
44
45 return postExecute(description);
46 }
47
48 /* (non-Javadoc)
49 * @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
50 */
51 /** {@inheritDoc} */
52 @Override
53 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
54 throws ExecutionException {
55 return execute(monitor, info);
56 }
57
58 /* (non-Javadoc)
59 * @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
60 */
61 /** {@inheritDoc} */
62 @Override
63 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
64 throws ExecutionException {
65
66 taxon.addDescription(description);
67
68 return postExecute(null);
69 }
70 }