15 |
15 |
import org.eclipse.core.runtime.IProgressMonitor;
|
16 |
16 |
import org.eclipse.core.runtime.IStatus;
|
17 |
17 |
import org.eclipse.core.runtime.Status;
|
|
18 |
import org.eclipse.jface.viewers.TreeNode;
|
18 |
19 |
import org.eclipse.ui.ISaveablePart;
|
19 |
20 |
|
20 |
21 |
import eu.etaxonomy.cdm.api.service.DeleteResult;
|
21 |
22 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
22 |
23 |
import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
|
23 |
24 |
import eu.etaxonomy.cdm.model.common.CdmBase;
|
|
25 |
import eu.etaxonomy.cdm.model.molecular.Sequence;
|
|
26 |
import eu.etaxonomy.cdm.model.molecular.SingleRead;
|
24 |
27 |
import eu.etaxonomy.taxeditor.editor.view.derivate.DerivateView;
|
25 |
28 |
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
26 |
29 |
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
... | ... | |
38 |
41 |
public class DeleteDerivateOperation extends AbstractPostOperation<CdmBase> {
|
39 |
42 |
|
40 |
43 |
private final SpecimenDeleteConfigurator deleteConfigurator;
|
|
44 |
private final TreeNode treeNode;
|
41 |
45 |
|
42 |
|
public DeleteDerivateOperation(String label, IUndoContext undoContext, CdmBase element,
|
|
46 |
public DeleteDerivateOperation(String label, IUndoContext undoContext, CdmBase element, TreeNode treeNode,
|
43 |
47 |
IPostOperationEnabled postOperationEnabled) {
|
44 |
|
this(label, undoContext, element, postOperationEnabled, new SpecimenDeleteConfigurator());
|
|
48 |
this(label, undoContext, element, treeNode, postOperationEnabled, new SpecimenDeleteConfigurator());
|
45 |
49 |
}
|
46 |
50 |
|
47 |
|
public DeleteDerivateOperation(String label, IUndoContext undoContext, CdmBase element,
|
|
51 |
public DeleteDerivateOperation(String label, IUndoContext undoContext, CdmBase element, TreeNode treeNode,
|
48 |
52 |
IPostOperationEnabled postOperationEnabled, SpecimenDeleteConfigurator config) {
|
49 |
53 |
super(label, undoContext, element, postOperationEnabled);
|
50 |
54 |
this.deleteConfigurator = config;
|
|
55 |
this.treeNode = treeNode;
|
51 |
56 |
}
|
52 |
57 |
|
53 |
58 |
|
54 |
|
/*
|
55 |
|
* (non-Javadoc)
|
56 |
|
*
|
57 |
|
* @see
|
58 |
|
* org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
|
59 |
|
* .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
60 |
|
*/
|
61 |
59 |
/** {@inheritDoc} */
|
62 |
60 |
@Override
|
63 |
61 |
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
... | ... | |
75 |
73 |
return Status.CANCEL_STATUS;
|
76 |
74 |
}
|
77 |
75 |
}
|
78 |
|
DeleteResult deleteResult = CdmStore.getService(IOccurrenceService.class).deleteDerivateHierarchy(element, deleteConfigurator);
|
|
76 |
DeleteResult deleteResult;
|
|
77 |
if(element instanceof SingleRead && treeNode!=null
|
|
78 |
&& treeNode.getValue().equals(element)
|
|
79 |
&& treeNode.getParent()!=null
|
|
80 |
&& treeNode.getParent().getValue() instanceof Sequence){
|
|
81 |
deleteResult = CdmStore.getService(IOccurrenceService.class).deleteSingleRead((SingleRead)element, (Sequence) treeNode.getParent().getValue());
|
|
82 |
}
|
|
83 |
else{
|
|
84 |
deleteResult = CdmStore.getService(IOccurrenceService.class).deleteDerivateHierarchy(element, deleteConfigurator);
|
|
85 |
}
|
79 |
86 |
if(deleteResult.isOk()){
|
80 |
87 |
if(getPostOperationEnabled() instanceof DerivateView){
|
81 |
88 |
DerivateView derivateView = (DerivateView) getPostOperationEnabled();
|
... | ... | |
96 |
103 |
return Status.OK_STATUS;
|
97 |
104 |
}
|
98 |
105 |
|
99 |
|
/*
|
100 |
|
* (non-Javadoc)
|
101 |
|
*
|
102 |
|
* @see
|
103 |
|
* org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
|
104 |
|
* .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
105 |
|
*/
|
106 |
106 |
/** {@inheritDoc} */
|
107 |
107 |
@Override
|
108 |
108 |
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
... | ... | |
110 |
110 |
return Status.CANCEL_STATUS ;
|
111 |
111 |
}
|
112 |
112 |
|
113 |
|
/*
|
114 |
|
* (non-Javadoc)
|
115 |
|
*
|
116 |
|
* @see
|
117 |
|
* org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
|
118 |
|
* .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
119 |
|
*/
|
120 |
113 |
/** {@inheritDoc} */
|
121 |
114 |
@Override
|
122 |
115 |
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
|
Fix deletion of single reads in Derivative Editor