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
.CdmApplicationController
;
15 import eu
.etaxonomy
.cdm
.api
.service
.IPolytomousKeyNodeService
;
16 import eu
.etaxonomy
.cdm
.api
.service
.ITaxonService
;
17 import eu
.etaxonomy
.cdm
.model
.description
.PolytomousKeyNode
;
18 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostTaxonOperation
;
19 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
20 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
26 public class DeleteNodeOperation
extends AbstractPostTaxonOperation
{
28 private final PolytomousKeyNode parent
;
29 private final PolytomousKeyNode node
;
31 public DeleteNodeOperation(String label
, IUndoContext undoContext
,
32 PolytomousKeyNode node
, IPostOperationEnabled postOperationEnabled
) {
33 super(label
, undoContext
, postOperationEnabled
);
35 this.parent
= node
.getParent();
42 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
43 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
46 public IStatus
execute(IProgressMonitor monitor
, IAdaptable info
)
47 throws ExecutionException
{
49 //parent.removeChild(node);
50 CdmApplicationController controller
;
52 controller
= (CdmApplicationController
) CdmStore
.getCurrentApplicationConfiguration();
54 IPolytomousKeyNodeService service
= controller
.getPolytomousKeyNodeService();
55 if (node
.getChildren().size()>0){
56 if(! MessageDialog
.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
57 service
.delete(node
, false);
60 service
.delete(node
, true);
62 return postExecute(null);
69 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
70 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
73 public IStatus
redo(IProgressMonitor monitor
, IAdaptable info
)
74 throws ExecutionException
{
75 return execute(monitor
, info
);
82 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
83 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
86 public IStatus
undo(IProgressMonitor monitor
, IAdaptable info
)
87 throws ExecutionException
{
88 // TODO Auto-generated method stub