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.api.service.IDescriptionService;
|
19
|
import eu.etaxonomy.cdm.model.description.SpecimenDescription;
|
20
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
21
|
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
|
22
|
import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
|
23
|
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
|
24
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
25
|
|
26
|
/**
|
27
|
*
|
28
|
* @author pplitzner
|
29
|
* @date Jan 15, 2015
|
30
|
*
|
31
|
*/
|
32
|
public class DeleteSpecimenDescriptionOperation extends AbstractPostOperation<SpecimenOrObservationBase<?>> {
|
33
|
|
34
|
private final SpecimenDescription description;
|
35
|
|
36
|
public DeleteSpecimenDescriptionOperation(String label,
|
37
|
IUndoContext undoContext,
|
38
|
SpecimenDescription description,
|
39
|
IPostOperationEnabled postOperationEnabled,
|
40
|
ICdmEntitySessionEnabled cdmEntitySessionEnabled) {
|
41
|
super(label, undoContext, description.getDescribedSpecimenOrObservation(), postOperationEnabled, cdmEntitySessionEnabled);
|
42
|
this.description = description;
|
43
|
}
|
44
|
|
45
|
/* (non-Javadoc)
|
46
|
* @see org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
47
|
*/
|
48
|
/** {@inheritDoc} */
|
49
|
@Override
|
50
|
public IStatus execute(IProgressMonitor monitor, IAdaptable info)
|
51
|
throws ExecutionException {
|
52
|
|
53
|
monitor.worked(20);
|
54
|
element.removeDescription(description);
|
55
|
monitor.worked(40);
|
56
|
CdmStore.getService(IDescriptionService.class).delete(description);
|
57
|
|
58
|
return postExecute(description);
|
59
|
}
|
60
|
|
61
|
/* (non-Javadoc)
|
62
|
* @see org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
63
|
*/
|
64
|
/** {@inheritDoc} */
|
65
|
@Override
|
66
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
67
|
throws ExecutionException {
|
68
|
return execute(monitor, info);
|
69
|
}
|
70
|
|
71
|
/* (non-Javadoc)
|
72
|
* @see org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
73
|
*/
|
74
|
/** {@inheritDoc} */
|
75
|
@Override
|
76
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
77
|
throws ExecutionException {
|
78
|
|
79
|
element.addDescription(description);
|
80
|
|
81
|
return postExecute(null);
|
82
|
}
|
83
|
}
|