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
;
12 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
14 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
15 import eu
.etaxonomy
.cdm
.api
.service
.DeleteResult
;
16 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
17 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
18 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
19 import eu
.etaxonomy
.taxeditor
.bulkeditor
.internal
.TaxeditorBulkeditorPlugin
;
20 import eu
.etaxonomy
.taxeditor
.model
.MessagingUtils
;
21 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
22 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
23 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
29 public class DeleteNodeOperation
extends AbstractPostTaxonOperation
{
31 private final PolytomousKeyNode parent
;
32 private final PolytomousKeyNode node
;
34 public DeleteNodeOperation(String label
, IUndoContext undoContext
,
35 PolytomousKeyNode node
, IPostOperationEnabled postOperationEnabled
) {
36 super(label
, undoContext
, postOperationEnabled
);
38 this.parent
= node
.getParent();
45 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
46 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
49 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
50 throws ExecutionException
{
52 //parent.removeChild(node);
53 ICdmApplicationConfiguration controller
;
55 controller
= (ICdmApplicationConfiguration
) CdmStore
.getCurrentApplicationConfiguration();
57 IPolytomousKeyNodeService service
= controller
.getPolytomousKeyNodeService();
59 if (node
.getChildren().size()>0){
60 if(! MessageDialog
.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
61 result
= service
.delete(node
.getUuid(), false);
63 result
= service
.delete(node
.getUuid(), true);
66 result
= service
.delete(node
.getUuid(), true);
69 if (!result
.isOk() || result
.getExceptions().size() > 0){
70 Exception t
= new Exception();
71 if (result
.getExceptions().size() >1){
72 for (Exception e
:result
.getExceptions()){
76 t
= result
.getExceptions().iterator().next();
78 MessagingUtils
.errorDialog("Exception occured. Delete not possible", getClass(),null, TaxeditorBulkeditorPlugin
.PLUGIN_ID
, t
, true);
80 return postExecute(null);
87 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
88 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
91 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
92 throws ExecutionException
{
93 return execute(monitor
, info
);
100 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
101 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
104 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
105 throws ExecutionException
{
106 // TODO Auto-generated method stub