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 374ca7e0eadd4f450e0f190621e37fe2bf501e42..c6d53ad380c51dde0abcb01d6db72cd1bfd42831 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 a3988f6c18e05dee7d0eba260436eb022ce03ae0..93477123e2bdfb02dbbf4551a5289a2cb695749a 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) {