String plural = selection.size() > 1 ? "s" : "";
// Prompt user for confirmation
- if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Are you sure you want to delete the selected node" + plural +"?")){
- return null;
- }
+
+
Iterator selectionIterator = selection.iterator();
Set<ITaxonTreeNode> treeNodes = new HashSet<ITaxonTreeNode>();
if (treeNodes.size() == 1 ){
try {
+ ITaxonTreeNode treeNode = treeNodes.iterator().next();
+ ITaxonTreeNode taxonNode =treeNode;
+
+ if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
+ if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too")){
+ return null;
+ }
+ } else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
+ if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
+ return null;
+ }
+ } else {
+ if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
+ return null;
+ }
+ }
if (allEditorsClosed){
- ITaxonTreeNode treeNode = treeNodes.iterator().next();
- /*if (treeNode instanceof Classification){
- operation = new DeleteOperation(
- event.getCommand().getName(), NavigationUtil.getUndoContext(),
- treeNodes, new TaxonDeletionConfigurator(), taxonNavigator, taxonNavigator);
-
- NavigationUtil.executeOperation(operation);
- }else {*/
- ITaxonTreeNode taxonNode =treeNode;
+ /*if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
+ return null;
+ }*/
operation = new DeleteOperation(
event.getCommand().getName(), NavigationUtil.getUndoContext(),
taxonNode, new TaxonDeletionConfigurator(), taxonNavigator, taxonNavigator);
}
} else{
try{
+ if(! MessageDialog.openConfirm(HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected nodes?")){
+ return null;
+ }
if (allEditorsClosed){
operation = new DeleteOperation(
event.getCommand().getName(), NavigationUtil.getUndoContext(),
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
}else if(taxonNode != null && taxonNode instanceof Classification){
Classification taxonomicTree = (Classification) taxonNode;
- if(taxonomicTree.hasChildNodes()){
- StoreUtil.warningDialog("Tree is not empty", this, "It is not possible to delete a Taxonomic Tree that " +
- "is not empty. Please delete included taxa first");
- }else{
+ /*if(taxonomicTree.hasChildNodes()){
+ if(! MessageDialog.openConfirm(null, "Confirm Deletion", "The selected tree has children, do yu realy want to delete the whole tree with its children?")){
+ return null;
+ }
+ }*/
+ try{
+ CdmStore.getService(IClassificationService.class).delete(taxonomicTree);
+ }catch(ReferencedObjectUndeletableException e){
+ throw new ExecutionException(e.getMessage());
+ }
+
+
+ /*}else{
try{
CdmStore.getService(IClassificationService.class).delete(taxonomicTree);
}catch(ReferencedObjectUndeletableException e){
throw new ExecutionException(e.getMessage());
}
- }
+ }*/
} else {
try {
service.deleteTaxonNodes(treeNodes, config);