add delete configurator dialog for taxa and names bulkeditor
authorKatja Luther <k.luther@bgbm.org>
Tue, 24 Nov 2015 13:19:38 +0000 (14:19 +0100)
committerKatja Luther <k.luther@bgbm.org>
Tue, 24 Nov 2015 13:19:38 +0000 (14:19 +0100)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/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/DeleteNameConfiguratorComposite.java [new file with mode: 0644]
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteTaxonConfiguratorComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElement.java [new file with mode: 0644]

index 3c7e7e9e24a1477bdb544cd17cecc36ca92fcec7..08d0355e8182c4d4e24aaea1bce282a77ba50b35 100644 (file)
@@ -128,6 +128,12 @@ public class DeleteHandler extends AbstractHandler {
                                                INameService service = controller.getNameService();
                                                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); 
+                                                       int result_dialog= dialog.open();
+                                                       if (result_dialog == 1){
+                                                               return null;
+                                                       }
                                                        result = service.delete(((TaxonNameBase) object).getUuid(), config);
                                                        errorMessage = "The name ";
                                                }
@@ -146,11 +152,7 @@ public class DeleteHandler extends AbstractHandler {
                                                                errorMessage = "The taxon ";
                                                        }else{
                                                                SynonymDeletionConfigurator config = new SynonymDeletionConfigurator();
-                                                               DeleteConfiguratorDialog dialog = new DeleteConfiguratorDialog(config, HandlerUtil.getActiveShell(event), "Confirm Deletion",  null,  "Do you really want to delete the synonym", MessageDialog.WARNING, new String[] { "Delete", "Skip" }, 0); 
-                                                               int result_dialog= dialog.open();
-                                                               if (result_dialog == 1){
-                                                                       return null;
-                                                               }
+                                                               
                                                                result = service.deleteSynonym(((Synonym)object).getUuid(), config);
                                                                errorMessage = "The synonym ";
                                                        }
index c2d947ab535051a9e5c02a730c76343077b82203..eb1b62d6ce804753ca8d322d580f95d7b4dc0269 100644 (file)
@@ -18,6 +18,7 @@ import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 
 import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase;
+import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonBaseDeletionConfigurator;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
@@ -53,6 +54,8 @@ public class DeleteConfiguratorDialog extends MessageDialog{
             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));
+        }  else if(configurator instanceof NameDeletionConfigurator){
+            composite.addConfiguratorComposite(new DeleteNameConfiguratorComposite((NameDeletionConfigurator) configurator, composite.getSectionConfigure(), SWT.NONE));
         }
         
         return composite;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNameConfiguratorComposite.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/deleteConfigurator/DeleteNameConfiguratorComposite.java
new file mode 100644 (file)
index 0000000..ed1fd4d
--- /dev/null
@@ -0,0 +1,127 @@
+package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
+
+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.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+import eu.etaxonomy.cdm.api.service.config.NameDeletionConfigurator;
+import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
+/**
+ * @author kluther
+ * @date Nov 2, 2015
+ *
+ */
+public class DeleteNameConfiguratorComposite extends Composite {
+       private final DataBindingContext m_bindingContext;
+
+    private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
+    private final NameDeletionConfigurator configurator;
+    private final Button btnRemoveAllNameRelationships;
+    private final Button btnIgnoreIsBasionym;
+    private final Button btnIgnoreIsReplacedSynonymFor;
+    private final Button btnIgnoreHasBasionym;
+    private final Button btnIgnoreHasReplacedSynonym;
+    private final Button btnRemoveAllTypeDesignations;
+  
+    /*
+     * private boolean removeAllNameRelationships = false;
+       
+       private boolean ignoreIsBasionymFor = false;
+       
+       private boolean ignoreIsReplacedSynonymFor = false;
+
+       private boolean ignoreHasBasionym = true;
+       
+       private boolean ignoreHasReplacedSynonym = true;
+       
+       private boolean removeAllNameTypeDesignations = true;
+     */
+    
+
+    /**
+     * Create the composite.
+     * @param parent
+     * @param style
+     */
+    public DeleteNameConfiguratorComposite(NameDeletionConfigurator 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());
+
+        btnRemoveAllNameRelationships = new Button(this, SWT.CHECK);
+        btnRemoveAllNameRelationships.setText("Remove all Name Relationships");
+        btnRemoveAllNameRelationships.setSelection(true);
+        
+        btnIgnoreIsBasionym = new Button(this, SWT.CHECK);
+        btnIgnoreIsBasionym.setText("Ignore is Basionym");
+        btnIgnoreIsBasionym.setSelection(true);
+        
+        btnIgnoreIsReplacedSynonymFor = new Button(this, SWT.CHECK);
+        btnIgnoreIsReplacedSynonymFor.setText("Ignore is Replaced Synonym");
+        btnIgnoreIsReplacedSynonymFor.setSelection(true);
+        
+        btnIgnoreHasBasionym = new Button(this, SWT.CHECK);
+        btnIgnoreHasBasionym.setText("Ignore has Basionym");
+        btnIgnoreHasBasionym.setSelection(true);
+        
+        btnIgnoreHasReplacedSynonym = new Button(this, SWT.CHECK);
+        btnIgnoreHasReplacedSynonym.setText("Ignore has Replaced Synonym");
+        btnIgnoreHasReplacedSynonym.setSelection(true);
+        
+        btnRemoveAllTypeDesignations = new Button(this, SWT.CHECK);
+        btnRemoveAllTypeDesignations.setText("Remove all Type Designations");
+        btnRemoveAllTypeDesignations.setSelection(true);
+        
+        m_bindingContext = initDataBindings();
+
+    }
+
+    protected DataBindingContext initDataBindings() {
+        DataBindingContext bindingContext = new DataBindingContext();
+        //
+        IObservableValue observeSelectionBtnRemoveAllNameRelationshipsWidget = WidgetProperties.selection().observe(btnRemoveAllNameRelationships);
+        IObservableValue removeAllNameRelationshipsConfiguratorObserveValue = PojoProperties.value("removeAllNameRelationships").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnRemoveAllNameRelationshipsWidget, removeAllNameRelationshipsConfiguratorObserveValue, null, null);
+        
+        IObservableValue observeSelectionBtnbtnIgnoreIsBasionymObserveWidget = WidgetProperties.selection().observe(btnIgnoreIsBasionym);
+        IObservableValue ignoreIsBasionymConfiguratorObserveValue = PojoProperties.value("ignoreIsBasionymFor").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnbtnIgnoreIsBasionymObserveWidget, ignoreIsBasionymConfiguratorObserveValue, null, null);
+      
+        IObservableValue observeSelectionBtnIgnoreIsReplacedSynonymForWidget = WidgetProperties.selection().observe(btnIgnoreIsReplacedSynonymFor);
+        IObservableValue ignoreIsReplacedSynonymForConfiguratorObserveValue = PojoProperties.value("ignoreIsReplacedSynonymFor").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnIgnoreIsReplacedSynonymForWidget, ignoreIsReplacedSynonymForConfiguratorObserveValue, null, null);
+        
+        IObservableValue observeSelectionBtnIgnoreHasBasionymWidget = WidgetProperties.selection().observe(btnIgnoreHasBasionym);
+        IObservableValue ignoreHasBasionymConfiguratorObserveValue = PojoProperties.value("ignoreHasBasionym").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnIgnoreHasBasionymWidget, ignoreHasBasionymConfiguratorObserveValue, null, null);
+        
+        IObservableValue observeSelectionBtnIgnoreHasReplacedSynonymWidget = WidgetProperties.selection().observe(btnIgnoreHasReplacedSynonym);
+        IObservableValue ignoreHasReplacedSynonymConfiguratorObserveValue = PojoProperties.value("ignoreHasReplacedSynonym").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnIgnoreHasReplacedSynonymWidget, ignoreHasReplacedSynonymConfiguratorObserveValue, null, null);
+
+        IObservableValue observeSelectionBtnRemoveAllTypeDesignationsWidget = WidgetProperties.selection().observe(btnRemoveAllTypeDesignations);
+        IObservableValue removeAllNameTypeDesignationsConfiguratorObserveValue = PojoProperties.value("removeAllNameTypeDesignations").observe(configurator);
+        bindingContext.bindValue(observeSelectionBtnRemoveAllTypeDesignationsWidget, removeAllNameTypeDesignationsConfiguratorObserveValue, null, null);
+
+        //
+        return bindingContext;
+    }
+}
index aaa06118ce520a0aeb9bfebe1c0c04dfea536b66..158752aa248d7f1b52742086829a7f7f4ca1a99a 100644 (file)
@@ -9,6 +9,8 @@
 */
 package eu.etaxonomy.taxeditor.ui.dialog.deleteConfigurator;
 
+import java.util.List;
+
 import org.eclipse.core.databinding.DataBindingContext;
 import org.eclipse.core.databinding.beans.PojoProperties;
 import org.eclipse.core.databinding.observable.value.IObservableValue;
@@ -16,8 +18,11 @@ import org.eclipse.jface.databinding.swt.WidgetProperties;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.DisposeEvent;
 import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
+
 import org.eclipse.swt.layout.RowLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Combo;
@@ -27,9 +32,11 @@ import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
+import eu.etaxonomy.cdm.api.service.IClassificationService;
 import eu.etaxonomy.cdm.api.service.config.TaxonDeletionConfigurator;
-import eu.etaxonomy.cdm.common.CdmUtils;
+
 import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.store.CdmStore;
 
 
 /**
@@ -37,7 +44,7 @@ import eu.etaxonomy.cdm.model.taxon.Classification;
  * @date Feb 18, 2015
  *
  */
-public class DeleteTaxonConfiguratorComposite extends Composite {
+public class DeleteTaxonConfiguratorComposite extends Composite implements SelectionListener{
     private final DataBindingContext m_bindingContext;
 
     private final FormToolkit toolkit = new FormToolkit(Display.getCurrent());
@@ -45,7 +52,10 @@ public class DeleteTaxonConfiguratorComposite extends Composite {
     private final Button btnDeleteTaxonName;
     private final Button btnDeleteInAllClassifications;
     private Combo classificationSelectionCombo;
-  
+    private 
+    
+    Classification selectedClassification;
+    private List<Classification> classifications;
     
 
     /**
@@ -63,7 +73,7 @@ public class DeleteTaxonConfiguratorComposite extends Composite {
             }
         });
         toolkit.paintBordersFor(this);
-        setLayout(new RowLayout(SWT.VERTICAL));
+        setLayout(new GridLayout());
         setBackground(getBackground());
 
         btnDeleteTaxonName = new Button(this, SWT.CHECK);
@@ -74,6 +84,8 @@ public class DeleteTaxonConfiguratorComposite extends Composite {
         btnDeleteInAllClassifications.setText("Delete taxon in all classifications");
         btnDeleteInAllClassifications.setSelection(true);
         
+       // createClassificationSelectionCombo(this);
+        
         m_bindingContext = initDataBindings();
 
     }
@@ -88,15 +100,18 @@ public class DeleteTaxonConfiguratorComposite extends Composite {
         IObservableValue deleteInAllClassificationsConfiguratorObserveValue = PojoProperties.value("deleteInAllClassifications").observe(configurator);
         bindingContext.bindValue(observeSelectionBtnDeleteTaxonNameObserveWidget, deleteNameIfPossibleConfiguratorObserveValue, null, null);
         bindingContext.bindValue(observeSelectionBtnDeleteInAllClassificationObserveWidget, deleteInAllClassificationsConfiguratorObserveValue, null, null);
+        
+        
+        
         //
         return bindingContext;
     }
     
-   /* private Control createClassificationSelectionCombo(Composite parent){
+  /* private Control createClassificationSelectionCombo(Composite parent){
 //             classifications = CdmStore.getTaxonTreeService().list(null, null, null, null, null);
 
                Composite classificationSelection = new Composite(parent, SWT.NULL);
-               classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+               classificationSelection.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
 
                GridLayout layout = new GridLayout();
                classificationSelection.setLayout(layout);
@@ -106,20 +121,27 @@ public class DeleteTaxonConfiguratorComposite extends Composite {
                label.setText("Select Classification");
                classificationSelectionCombo = new Combo(classificationSelection, SWT.BORDER | SWT.READ_ONLY);
                classificationSelectionCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
-               List<Classification> classifications = 
+               classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
 
                for(Classification tree : classifications){
                        classificationSelectionCombo.add(tree.getName().getText(), classifications.indexOf(tree));
 
                }
 
-               classificationSelectionCombo.select(classifications.indexOf(selectedClassification));
-
-               // TODO remember last selection
+               classificationSelectionCombo.select(0);
                classificationSelectionCombo.addSelectionListener(this);
-
-
-
+               
                return classificationSelection;
        }*/
+
+@Override
+public void widgetSelected(SelectionEvent e) {
+       selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
+}
+
+@Override
+public void widgetDefaultSelected(SelectionEvent e) {
+       // TODO Auto-generated method stub
+       
+}
 }
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/selection/ClassificationSelectionElement.java
new file mode 100644 (file)
index 0000000..6650b83
--- /dev/null
@@ -0,0 +1,19 @@
+package eu.etaxonomy.taxeditor.ui.selection;
+
+import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
+import eu.etaxonomy.cdm.model.taxon.Classification;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
+
+public class ClassificationSelectionElement extends EntitySelectionElement<Classification> {
+
+       public ClassificationSelectionElement(CdmFormFactory formFactory,
+                       ConversationHolder conversation, ICdmFormElement parentElement,
+                       Class<Classification> clazz, String labelString,
+                       Classification entity, int mode, int style) {
+               super(formFactory, conversation, parentElement, clazz, labelString, entity,
+                               mode, style);
+               
+       }
+
+}