Added code that cancels this action when the taxon has taxonomic children and informs...
authorp.ciardelli <p.ciardelli@localhost>
Tue, 25 Nov 2008 13:22:24 +0000 (13:22 +0000)
committerp.ciardelli <p.ciardelli@localhost>
Tue, 25 Nov 2008 13:22:24 +0000 (13:22 +0000)
eclipseprojects/eu.etaxonomy.taxeditor/src/eu/etaxonomy/taxeditor/actions/cdm/DeleteTaxonAction.java

index b6eb6e734aeb31a72c98d8852f2506246ed253ea..1b4ba7959429f0aea48e5a51bd9f626a974746a7 100644 (file)
@@ -18,6 +18,7 @@ import java.util.UUID;
 \r
 import org.apache.log4j.Logger;\r
 import org.eclipse.jface.action.Action;\r
+import org.eclipse.jface.dialogs.MessageDialog;\r
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.eclipse.ui.PartInitException;\r
 \r
@@ -27,6 +28,7 @@ import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType;
 import eu.etaxonomy.taxeditor.ITaxEditorConstants;\r
 import eu.etaxonomy.taxeditor.TaxEditorPlugin;\r
 import eu.etaxonomy.taxeditor.UiUtil;\r
+import eu.etaxonomy.taxeditor.model.CdmUtil;\r
 \r
 /**\r
  * Delete this taxon from the CDM\r
@@ -57,6 +59,15 @@ public class DeleteTaxonAction extends Action {
 \r
        public void run() {\r
 \r
+               // If the taxon has children, cancel operation\r
+               // TODO add option to continue, and delete children\r
+               if (taxon.hasTaxonomicChildren()) {\r
+                       MessageDialog.openInformation(UiUtil.getShell(), "Cannot delete taxon", \r
+                                       "'" + CdmUtil.getDisplayName(taxon) + "' has taxonomic children. " +\r
+                                       "These must be manually deleted before their parent.");\r
+                       return;\r
+               }\r
+               \r
                TaxEditorPlugin.getDefault().removeSessionTaxon(taxon);\r
 \r
                // Close taxon's editor, if any is active\r