Do not show taxon-specific deletion options when deleting
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 13 Sep 2016 06:08:16 +0000 (08:08 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 13 Sep 2016 09:28:22 +0000 (11:28 +0200)
classifications

eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/RemotingDeleteTaxonNodeHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java

index 374ca7e..c6d53ad 100644 (file)
@@ -23,10 +23,9 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.handlers.HandlerUtil;
 
 import eu.etaxonomy.cdm.api.application.CdmApplicationState;
+import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
-import eu.etaxonomy.cdm.api.service.config.NodeDeletionConfigurator.ChildHandling;
-import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
@@ -47,21 +46,15 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
     private TaxonDeletionConfigurator config;
     private Set<ITaxonTreeNode> treeNodes;
 
-    /**
-     * @param label
-     */
     public RemotingDeleteTaxonNodeHandler() {
         super(TaxonNavigatorLabels.DELETE_TAXON_NODE_LABEL);
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#allowOperations(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
     public IStatus allowOperations(ExecutionEvent event) {
         TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
 
-        Iterator selectionIterator = selection.iterator();
+        Iterator<?> selectionIterator = selection.iterator();
         treeNodes = new HashSet<ITaxonTreeNode>();
 
         while (selectionIterator.hasNext()){
@@ -99,15 +92,20 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
 
             }
             TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
-            if (taxonNode instanceof Classification && taxonNode.hasChildNodes()){
-                if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification? The tree has children, they will be deleted, too.")){
-                    return Status.CANCEL_STATUS;
-                }
-            } else if (taxonNode instanceof Classification && !taxonNode.hasChildNodes()){
-                if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the classification?")){
-                    return Status.CANCEL_STATUS;
-                }
-            } else {
+                       if (taxonNode instanceof Classification) {
+                               String message;
+                               if (taxonNode.hasChildNodes()) {
+                                       message = "Do you really want to delete the classification? The tree has children, they will be deleted, too.";
+                               } else {
+                                       message = "Do you really want to delete the classification?";
+                               }
+                               if (!DeleteConfiguratorDialog.openConfirm(
+                                               HandlerUtil.getActiveShell(event), "Confirm Deletion",
+                                               message)) {
+                                       return Status.CANCEL_STATUS;
+                               }
+                       }
+            else {
 
                 if (taxonNode.hasChildNodes()){
                     DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(
@@ -142,9 +140,6 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
         return Status.OK_STATUS;
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#prepareOperation(org.eclipse.core.commands.ExecutionEvent)
-     */
     @Override
     public AbstractOperation prepareOperation(ExecutionEvent event) {
         return new RemotingDeleteTaxonNodeOperation(event.getTrigger(),
@@ -153,13 +148,8 @@ public class RemotingDeleteTaxonNodeHandler extends RemotingCdmHandler {
                 config);
     }
 
-    /* (non-Javadoc)
-     * @see eu.etaxonomy.taxeditor.operation.RemotingCdmHandler#onComplete()
-     */
     @Override
     public void onComplete() {
-        // TODO Auto-generated method stub
-
     }
 
 }
index a3988f6..9347712 100644 (file)
@@ -41,9 +41,6 @@ public class DeleteConfiguratorDialog extends MessageDialog{
         this.configurator = configurator;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
-     */
     @Override
     protected Control createCustomArea(Composite parent) {
         DeleteConfiguratorComposite composite = new DeleteConfiguratorComposite(parent, NONE);
@@ -67,19 +64,12 @@ public class DeleteConfiguratorDialog extends MessageDialog{
         return dialog.open() == 0;
     }
 
-    /* (non-Javadoc)
-     * @see org.eclipse.jface.dialogs.Dialog#isResizable()
-     */
     @Override
     protected boolean isResizable() {
         return true;
     }
 
 
-    /**
-     * @param kind
-     * @return
-     */
     protected static String[] getButtonLabels(int kind) {
         String[] dialogButtonLabels;
         switch (kind) {