add the possibility to configure the deletion of taxon nodes
authork.luther <k.luther@bgbm.org>
Mon, 13 Jul 2015 11:30:20 +0000 (13:30 +0200)
committerk.luther <k.luther@bgbm.org>
Mon, 13 Jul 2015 11:30:20 +0000 (13:30 +0200)
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/handler/DeleteHandler.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteConfiguratorDialog.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNodeConfiguratorComposite.java [new file with mode: 0644]

index 55df02ba26580f05fa4cc09d74df9336257d6b6e..5a8650098b30cf91fe380d90fb7f994e7be7fc87 100644 (file)
@@ -87,6 +87,7 @@ public class DeleteHandler extends AbstractHandler{
                                ITaxonTreeNode treeNode = treeNodes.iterator().next();
                                ITaxonTreeNode taxonNode =treeNode;
                                TaxonNodeDeletionConfigurator configNodes = new TaxonNodeDeletionConfigurator();
+                               //configNodes.setDeleteTaxon(false);
                                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 null;
@@ -122,9 +123,10 @@ public class DeleteHandler extends AbstractHandler{
 
                                                }
                                        }else{
-                                               if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(config, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
+                                               if(!DeleteConfiguratorDialog.openConfirmWithConfigurator(configNodes, HandlerUtil.getActiveShell(event), "Confirm Deletion", "Do you really want to delete the selected node?")){
                                                        return null;
-                                               }
+                                               } 
+                                               config.setTaxonNodeConfig(configNodes);
                                        }
                                }
 
index eb36edac26f314ac4853c445ef28331754b62449..647addd10ccaea42b89725ac4b201456b51c25e5 100644 (file)
@@ -20,6 +20,7 @@ import org.eclipse.swt.widgets.Shell;
 import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
 import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
 
 /**
  * Abstract subclass of MessageDialog providing the functionality to configure
@@ -49,7 +50,10 @@ public class DeleteConfiguratorDialog extends MessageDialog{
         }
         else if(configurator instanceof SpecimenDeleteConfigurator){
             composite.addConfiguratorComposite(new DeleteSpecimenConfiguratorComposite((SpecimenDeleteConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
+        } else if(configurator instanceof TaxonNodeDeletionConfigurator){
+            composite.addConfiguratorComposite(new DeleteNodeConfiguratorComposite((TaxonNodeDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
         }
+        
         return composite;
     }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNodeConfiguratorComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNodeConfiguratorComposite.java
new file mode 100644 (file)
index 0000000..4901526
--- /dev/null
@@ -0,0 +1,76 @@
+package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
+/**
+* Copyright (C) 2015 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+import org.eclipse.core.databinding.DataBindingContext;
+import org.eclipse.core.databinding.beans.PojoProperties;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.jface.databinding.swt.WidgetProperties;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.RowLayout;
+
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonNodeDeletionConfigurator;
+/**
+ * @author kluther
+ * @date Jul 13, 2015
+ *
+ */
+public class DeleteNodeConfiguratorComposite extends Composite {
+       // $Id$
+       
+       private final DataBindingContext m_bindingContext;
+
+       private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+       private final TaxonNodeDeletionConfigurator configurator;
+       private final Button btnDeleteTaxon;
+
+
+           /**
+            * Create the composite.
+            * @param parent
+            * @param style
+            */
+           public DeleteNodeConfiguratorComposite(TaxonNodeDeletionConfigurator configurator, Composite parent, int style) {
+               super(parent, style);
+               this.configurator = configurator;
+               addDisposeListener(new DisposeListener() {
+                   @Override
+                   public void widgetDisposed(DisposeEvent e) {
+                       toolkit.dispose();
+                   }
+               });
+               toolkit.paintBordersFor(this);
+               setLayout(new RowLayout(SWT.VERTICAL));
+               setBackground(getBackground());
+
+               btnDeleteTaxon = new Button(this, SWT.CHECK);
+               btnDeleteTaxon.setText("Delete taxon if possible");
+            
+               m_bindingContext = initDataBindings();
+
+           }
+
+           protected DataBindingContext initDataBindings() {
+               DataBindingContext bindingContext = new DataBindingContext();
+               //
+               IObservableValue observeSelectionBtnDeleteTaxonObserveWidget = WidgetProperties.selection().observe(btnDeleteTaxon);
+               IObservableValue deleteTaxonIfPossibleConfiguratorObserveValue = PojoProperties.value("deleteTaxon").observe(configurator);
+               bindingContext.bindValue(observeSelectionBtnDeleteTaxonObserveWidget, deleteTaxonIfPossibleConfiguratorObserveValue, null, null);
+               //
+               return bindingContext;
+           }
+       }
+
+