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
|
if (node.getChildren().size()>0){
|
54
|
if(! MessageDialog.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
|
55
|
service.delete(node.getUuid(), false);
|
56
|
} else{
|
57
|
service.delete(node.getUuid(), true);
|
58
|
}
|
59
|
} else{
|
60
|
service.delete(node.getUuid(), true);
|
61
|
}
|
62
|
return postExecute(null);
|
63
|
}
|
64
|
|
65
|
/*
|
66
|
* (non-Javadoc)
|
67
|
*
|
68
|
* @see
|
69
|
* org.eclipse.core.commands.operations.AbstractOperation#redo(org.eclipse
|
70
|
* .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
71
|
*/
|
72
|
@Override
|
73
|
public IStatus redo(IProgressMonitor monitor, IAdaptable info)
|
74
|
throws ExecutionException {
|
75
|
return execute(monitor, info);
|
76
|
}
|
77
|
|
78
|
/*
|
79
|
* (non-Javadoc)
|
80
|
*
|
81
|
* @see
|
82
|
* org.eclipse.core.commands.operations.AbstractOperation#undo(org.eclipse
|
83
|
* .core.runtime.IProgressMonitor, org.eclipse.core.runtime.IAdaptable)
|
84
|
*/
|
85
|
@Override
|
86
|
public IStatus undo(IProgressMonitor monitor, IAdaptable info)
|
87
|
throws ExecutionException {
|
88
|
// TODO Auto-generated method stub
|
89
|
return null;
|
90
|
}
|
91
|
|
92
|
}
|