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