1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.taxeditor.editor.view.descriptive.operation;
|
11
|
|
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;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.description.TaxonDescription;
|
19
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
20
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
21
|
|
22
|
/**
|
23
|
* <p>DeleteTaxonDescriptionOperation class.</p>
|
24
|
*
|
25
|
* @author p.ciardelli
|
26
|
* @author n.hoffmann
|
27
|
* @created 05.02.2009
|
28
|
* @version 1.0
|
29
|
*/
|
30
|
public class DeleteTaxonDescriptionOperation extends AbstractPostOperation {
|
31
|
|
32
|
private TaxonDescription description;
|
33
|
|
34
|
/**
|
35
|
* <p>Constructor for DeleteTaxonDescriptionOperation.</p>
|
36
|
*
|
37
|
* @param label a {@link java.lang.String} object.
|
38
|
* @param undoContext a {@link org.eclipse.core.commands.operations.IUndoContext} object.
|
39
|
* @param description a {@link eu.etaxonomy.cdm.model.description.TaxonDescription} object.
|
40
|
* @param postOperationEnabled a {@link eu.etaxonomy.taxeditor.operation.IPostOperationEnabled} object.
|
41
|
*/
|
42
|
public DeleteTaxonDescriptionOperation(String label, IUndoContext undoContext,
|
43
|
TaxonDescription description, IPostOperationEnabled postOperationEnabled) {
|
44
|
super(label, undoContext, postOperationEnabled);
|
45
|
|
46
|
this.description = description;
|
47
|
taxon = description.getTaxon();
|
48
|
}
|
49
|
|
50
|
/* (non-Javadoc)
|
51
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
52
|
*/
|
53
|
/** {@inheritDoc} */
|
54
|
@Override
|
55
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
56
|
throws ExecutionException {
|
57
|
|
58
|
monitor.worked(20);
|
59
|
taxon.removeDescription(description);
|
60
|
monitor.worked(40);
|
61
|
|
62
|
return postExecute(description);
|
63
|
}
|
64
|
|
65
|
/* (non-Javadoc)
|
66
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
67
|
*/
|
68
|
/** {@inheritDoc} */
|
69
|
@Override
|
70
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
71
|
throws ExecutionException {
|
72
|
return execute(monitor, info);
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
77
|
*/
|
78
|
/** {@inheritDoc} */
|
79
|
@Override
|
80
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
81
|
throws ExecutionException {
|
82
|
|
83
|
taxon.addDescription(description);
|
84
|
|
85
|
return postExecute(null);
|
86
|
}
|
87
|
}
|