From: Katja Luther Date: Fri, 1 Apr 2016 12:53:49 +0000 (+0200) Subject: don't allow delete a taxon used in a classification X-Git-Tag: 4.0.0^2~50 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/aafe36c5cf0df247211c811617950217ce03e6bf don't allow delete a taxon used in a classification --- diff --git a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java index feb73fbe8..ff196c718 100644 --- a/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java +++ b/eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java @@ -130,7 +130,7 @@ public class DeleteHandler extends AbstractHandler { if (object != null){ NameDeletionConfigurator config = new NameDeletionConfigurator(); - DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", null, "Do you really want to delete the name", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); + DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", null, "Do you really want to delete the name?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); int result_dialog= dialog.open(); if (result_dialog == 1){ return null; @@ -142,15 +142,22 @@ public class DeleteHandler extends AbstractHandler { ITaxonService service = controller.getTaxonService(); if (object != null){ if (object instanceof Taxon){ - TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); + TaxonDeletionConfigurator config = new TaxonDeletionConfigurator(); config.setDeleteInAllClassifications(true); - DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", null, "Do you really want to delete the taxon", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); - int result_dialog= dialog.open(); - if (result_dialog == 1){ - return null; + DeleteConfiguratorDialog dialog; + if (((Taxon)object).getTaxonNodes().isEmpty()){ + dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", null, "Do you really want to delete the taxon?", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); + int result_dialog= dialog.open(); + if (result_dialog == 1){ + return null; + } + result = service.deleteTaxon(((TaxonBase) object).getUuid(), config, null); + errorMessage = "The taxon "; + } else{ + MessagingUtils.messageDialog("Delete not possible", getClass(), "The taxon can not be deleted in bulk editor. It is used in a classification.", null); + return null; } - result = service.deleteTaxon(((TaxonBase) object).getUuid(), config, null); - errorMessage = "The taxon "; + }else{ SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();