4 package eu
.etaxonomy
.taxeditor
.editor
.key
.polytomous
.operation
;
6 import org
.eclipse
.core
.commands
.ExecutionException
;
7 import org
.eclipse
.core
.commands
.operations
.IUndoContext
;
8 import org
.eclipse
.core
.runtime
.IAdaptable
;
9 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
10 import org
.eclipse
.core
.runtime
.IStatus
;
11 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
13 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
14 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
16 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
17 import eu
.etaxonomy
.taxeditor
.bulkeditor
.internal
.TaxeditorBulkeditorPlugin
;
18 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
19 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
20 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
21 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
27 public class DeleteNodeOperation
extends AbstractPostTaxonOperation
{
29 private final PolytomousKeyNode parent
;
30 private final PolytomousKeyNode node
;
32 public DeleteNodeOperation(String label
, IUndoContext undoContext
,
33 PolytomousKeyNode node
, IPostOperationEnabled postOperationEnabled
) {
34 super(label
, undoContext
, postOperationEnabled
);
36 this.parent
= node
.getParent();
43 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
44 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
47 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
48 throws ExecutionException
{
50 //parent.removeChild(node);
51 ICdmApplicationConfiguration controller
;
53 controller
= CdmStore
.getCurrentApplicationConfiguration();
55 IPolytomousKeyNodeService service
= controller
.getPolytomousKeyNodeService();
57 if (node
.getChildren().size()>0){
58 if(! MessageDialog
.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
59 result
= service
.delete(node
.getUuid(), false);
61 result
= service
.delete(node
.getUuid(), true);
64 result
= service
.delete(node
.getUuid(), true);
67 if (!result
.isOk() || result
.getExceptions().size() > 0){
68 Exception t
= new Exception();
69 if (result
.getExceptions().size() >1){
70 for (Exception e
:result
.getExceptions()){
74 t
= result
.getExceptions().iterator().next();
76 MessagingUtils
.errorDialog("Exception occured. Delete not possible", getClass(),null, TaxeditorBulkeditorPlugin
.PLUGIN_ID
, t
, true);
78 return postExecute(null);
85 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
86 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
89 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
90 throws ExecutionException
{
91 return execute(monitor
, info
);
98 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
99 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
102 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
103 throws ExecutionException
{
104 // TODO Auto-generated method stub