add delete configurator dialog for taxa and names bulkeditor
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / deleteConfigurator / DeleteTaxonConfiguratorComposite.java
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
+       
+}
 }