ref #7086 Allow drag and drop for taxon filter from taxon navigator
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / workingSet / WorkingSetComposite.java
index 7c9cd9e05ef44142c75fac9992ea973ff25fe7a4..7a8123d1bca9a90d11b0d612b0201b0ca59d33d0 100644 (file)
@@ -8,28 +8,21 @@
  */
 package eu.etaxonomy.taxeditor.editor.workingSet;
 
-import java.util.List;
-
 import org.eclipse.jface.viewers.TreeViewer;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.swt.widgets.Tree;
 
-import eu.etaxonomy.cdm.api.service.IClassificationService;
 import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.description.FeatureTree;
 import eu.etaxonomy.cdm.model.location.NamedArea;
-import eu.etaxonomy.cdm.model.taxon.Classification;
-import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.cdm.model.name.Rank;
+import eu.etaxonomy.taxeditor.featuretree.e4.FeatureTreeEditorComposite;
 import eu.etaxonomy.taxeditor.ui.combo.TermUuidComboViewer;
-import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
 import eu.etaxonomy.taxeditor.util.TaxonTreeNodeContentProvider;
 import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
 
@@ -39,17 +32,25 @@ import eu.etaxonomy.taxeditor.util.TaxonTreeNodeLabelProvider;
  *
  */
 public class WorkingSetComposite extends Composite {
-    private Text txt_label;
+    private Text txtWorkingSet;
+    private TermUuidComboViewer comboRankMin;
+    private TermUuidComboViewer comboRankMax;
+    private FeatureTreeEditorComposite featureTreeEditorComposite;
+    private TreeViewer taxonNodeTree;
+    private NamedArea area;
+    private Text textAreaText;
 
     public WorkingSetComposite(Composite parent, int style) {
         super(parent, style);
+
         setLayout(new GridLayout(3, false));
 
         Label lblNewLabel = new Label(this, SWT.NONE);
-        lblNewLabel.setText("Working set label");
+        lblNewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+        lblNewLabel.setText("Label");
 
-        txt_label = new Text(this, SWT.BORDER);
-        txt_label.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
+        txtWorkingSet = new Text(this, SWT.BORDER);
+        txtWorkingSet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
 
         Label lblNewLabel_1 = new Label(this, SWT.NONE);
         lblNewLabel_1.setText("Taxon filter");
@@ -58,56 +59,37 @@ public class WorkingSetComposite extends Composite {
         lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
         lblNewLabel_2.setText("Rank min");
 
-        TermUuidComboViewer combo = new TermUuidComboViewer(this, SWT.NONE);
-        combo.setInput(TermType.Rank);
-        combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
-
-        Composite composite = new Composite(this, SWT.NONE);
-        composite.setLayout(new FillLayout(SWT.HORIZONTAL));
-        composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
+        comboRankMin = new TermUuidComboViewer(this, SWT.NONE);
+        comboRankMin.setInput(TermType.Rank);
+        comboRankMin.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+        Tree tree = new Tree(this, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
+        tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
+        taxonNodeTree = new TreeViewer(tree);
 
-        TreeViewer viewer = new TreeViewer(new Tree(composite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION));
-
-        viewer.setContentProvider(new TaxonTreeNodeContentProvider());
-        viewer.setLabelProvider(new TaxonTreeNodeLabelProvider());
-        List<Classification> list = CdmStore.getService(IClassificationService.class).list(Classification.class, null, null, null, null);
-        viewer.setInput(list);
+        taxonNodeTree.setContentProvider(new TaxonTreeNodeContentProvider());
+        taxonNodeTree.setLabelProvider(new TaxonTreeNodeLabelProvider());
 
         Label lblNewLabel_3 = new Label(this, SWT.NONE);
         lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
         lblNewLabel_3.setText("Rank max");
 
-        TermUuidComboViewer combo_1 = new TermUuidComboViewer(this, SWT.NONE);
-        combo_1.setInput(TermType.Rank);
-        combo_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
+        comboRankMax = new TermUuidComboViewer(this, SWT.NONE);
+        comboRankMax.setInput(TermType.Rank);
+        comboRankMax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
 
         Label lblNewLabel_4 = new Label(this, SWT.NONE);
-        lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
+        lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
         lblNewLabel_4.setText("Area");
 
-        Composite composite_1 = new Composite(this, SWT.NONE);
-        composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
-        composite_1.setLayout(new GridLayout(2, false));
-
-        Label lblNewLabel_5 = new Label(composite_1, SWT.NONE);
-        lblNewLabel_5.setText("New Label");
-
+        textAreaText = new Text(this, SWT.BORDER);
+        textAreaText.setEditable(false);
+        textAreaText.setText("Choose...");
+        textAreaText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
 
-        Button btnNewButton = new Button(composite_1, SWT.NONE);
-        btnNewButton.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
-        btnNewButton.setText("Choose");
-        btnNewButton.addSelectionListener(new SelectionListener() {
+        featureTreeEditorComposite = new FeatureTreeEditorComposite(this, SWT.NONE);
+        featureTreeEditorComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
+        featureTreeEditorComposite.init(null, null, null, null);
 
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                NamedArea area = NamedAreaSelectionDialog.select(parent.getShell(), null, null, null);
-                lblNewLabel_5.setText(area.getLabel());
-            }
-
-            @Override
-            public void widgetDefaultSelected(SelectionEvent e) {
-            }
-        });
 
 
     }
@@ -117,6 +99,42 @@ public class WorkingSetComposite extends Composite {
         // Disable the check that prevents subclassing of SWT components
     }
     public Text getTxt_label() {
-        return txt_label;
+        return txtWorkingSet;
+    }
+
+    public TermUuidComboViewer getRankMin() {
+        return comboRankMin;
+    }
+    public TermUuidComboViewer getRankMax() {
+        return comboRankMax;
+    }
+
+    public void setRankMin(Rank min) {
+        comboRankMin.setTerm(min);
+    }
+    public void setRankMax(Rank max) {
+        comboRankMax.setTerm(max);
+    }
+
+    public FeatureTree getCharacters(){
+        return featureTreeEditorComposite.getFeatureTree();
+    }
+    public void setCharacters(FeatureTree characters) {
+        featureTreeEditorComposite.setSelectedTree(characters, null);
+    }
+
+    public TreeViewer getTaxonNodeTree() {
+        return taxonNodeTree;
+    }
+
+    public NamedArea getArea(){
+        return area;
+    }
+    public void setArea(NamedArea area) {
+        this.area = area;
+        textAreaText.setText(area.getLabel());
+    }
+    public Text getTextAreaText() {
+        return textAreaText;
     }
 }