import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
+import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
+import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
+import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
import eu.etaxonomy.cdm.model.description.PolytomousKeyNode;
import eu.etaxonomy.taxeditor.editor.EditorUtil;
import eu.etaxonomy.taxeditor.editor.key.KeyEditor;
import eu.etaxonomy.taxeditor.editor.key.polytomous.operation.DeleteNodeOperation;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
+import eu.etaxonomy.taxeditor.store.CdmStore;
/**
* @author n.hoffmann
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
+ if (editor.isDirty()){
+ boolean proceed = MessageDialog.openQuestion(null,
+ "Save changes", "You have made changes that must be saved before you can delete the node. Would you like to proceed?");
+ if (!proceed) {
+ return null;
+ }else{
+ editor.doSave(EditorUtil.getMonitor());
+ }
+ }
if (editor instanceof KeyEditor) {
IPolytomousKeyEditorPage editorPage = (IPolytomousKeyEditorPage) ((KeyEditor) editor)
.getActiveEditor();
IUndoContext undoContext = EditorUtil.getUndoContext();
for (Object element : selection.toArray()) {
- PolytomousKeyNode keyNode = (PolytomousKeyNode) element;
-
+ PolytomousKeyNode keyNode = HibernateProxyHelper.deproxy(element, PolytomousKeyNode.class);
+
AbstractPostOperation operation = new DeleteNodeOperation(
label, undoContext, keyNode, editorPage);
EditorUtil.executeOperation(operation);
controller = (ICdmApplicationConfiguration) CdmStore.getCurrentApplicationConfiguration();
IPolytomousKeyNodeService service = controller.getPolytomousKeyNodeService();
+
if (node.getChildren().size()>0){
if(! MessageDialog.openQuestion(null, "Confirm deletion of children", "The selected node has children, do you want to delete them, too?")) {
- service.delete(node, false);
+ service.delete(node.getUuid(), false);
} else{
- service.delete(node, true);
+ service.delete(node.getUuid(), true);
}
} else{
- service.delete(node, true);
+ service.delete(node.getUuid(), true);
}
return postExecute(null);
}