don't allow delete a taxon used in a classification
authorKatja Luther <k.luther@bgbm.org>
Fri, 1 Apr 2016 12:53:49 +0000 (14:53 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 1 Apr 2016 12:53:49 +0000 (14:53 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/handler/DeleteHandler.java

index feb73fbe85423ac34b3ed842a69a90266e250e43..ff196c718880975052924e8d41a54078eef34f6d 100644 (file)
@@ -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();