Change order of controls
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / key / polytomous / operation / DeleteNodeOperation.java
1 /**
2 *
3 */
4 package eu.etaxonomy.taxeditor.editor.key.polytomous.operation;
5
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;
13
14 import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
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;
21
22 /**
23 * @author n.hoffmann
24 *
25 */
26 public class DeleteNodeOperation extends AbstractPostTaxonOperation {
27
28 private final PolytomousKeyNode parent;
29 private final PolytomousKeyNode node;
30
31 public DeleteNodeOperation(String label, IUndoContext undoContext,
32 PolytomousKeyNode node, IPostOperationEnabled postOperationEnabled) {
33 super(label, undoContext, postOperationEnabled);
34 this.node = node;
35 this.parent = node.getParent();
36 }
37
38 /*
39 * (non-Javadoc)
40 *
41 * @see
42 * org.eclipse.core.commands.operations.AbstractOperation#execute(org.eclipse
43 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
44 */
45 @Override
46 public IStatus execute(IProgressMonitor monitor, IAdaptable info)
47 throws ExecutionException {
48
49 //parent.removeChild(node);
50 ICdmApplicationConfiguration controller;
51
52 controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
53
54 IPolytomousKeyNodeService service = controller.getPolytomousKeyNodeService();
55
56 if (node.getChildren().size()>0){
57 if(! MessageDialog.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
58 service.delete(node.getUuid(), false);
59 } else{
60 service.delete(node.getUuid(), true);
61 }
62 } else{
63 service.delete(node.getUuid(), true);
64 }
65 return postExecute(null);
66 }
67
68 /*
69 * (non-Javadoc)
70 *
71 * @see
72 * org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
73 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
74 */
75 @Override
76 public IStatus redo(IProgressMonitor monitor, IAdaptable info)
77 throws ExecutionException {
78 return execute(monitor, info);
79 }
80
81 /*
82 * (non-Javadoc)
83 *
84 * @see
85 * org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
86 * .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
87 */
88 @Override
89 public IStatus undo(IProgressMonitor monitor, IAdaptable info)
90 throws ExecutionException {
91 // TODO Auto-generated method stub
92 return null;
93 }
94
95 }