add drop down for countries in specimen search wizard
authorKatja Luther <k.luther@bgbm.org>
Thu, 2 Nov 2017 15:00:56 +0000 (16:00 +0100)
committerKatja Luther <k.luther@bgbm.org>
Thu, 2 Nov 2017 15:00:56 +0000 (16:00 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/specimenSearch/SpecimenSearchComposite.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/specimenSearch/SpecimenSearchController.java

index 98f8c09de36d6366bf39d6c1edf5b1b2c8b2b679..76b11620ccd7ab1478022d1cdce125b59f6aa1fb 100644 (file)
@@ -8,8 +8,11 @@
 */
 package eu.etaxonomy.taxeditor.view.specimenSearch;
 
+import java.util.List;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.DateTime;
 import org.eclipse.swt.widgets.Display;
@@ -19,6 +22,10 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
+import eu.etaxonomy.cdm.model.location.Country;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
+
 /**
  * @author pplitzner
  * @date 03.09.2013
@@ -32,7 +39,7 @@ public class SpecimenSearchComposite extends Composite {
     private final Text textAccessionNumber;
     private final Text textLocality;
     private final Text textHerbarium;
-    private final Text textCountry;
+    private final Combo textCountry;
     private final DateTime dateFrom;
     private final DateTime dateTo;
     private final Button btnShowDate;
@@ -50,7 +57,7 @@ public class SpecimenSearchComposite extends Composite {
             tableWrapLayout.numColumns = 2;
             setLayout(tableWrapLayout);
         }
-
+        CdmFormFactory formFactory = new CdmFormFactory(parent.getDisplay());
         Label lblTaxonName = new Label(this, SWT.NONE);
         lblTaxonName.setText("Taxon Name");
 
@@ -87,8 +94,17 @@ public class SpecimenSearchComposite extends Composite {
         Label lblCountry = new Label(this, SWT.NONE);
         lblCountry.setText("Country");
 
-        textCountry = new Text(this, SWT.NONE);
+        textCountry = new Combo(this, SWT.NONE);
         textCountry.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP, 1, 1));
+        List<Country> items = CdmStore.getTermManager().getPreferredTerms(Country.class);
+        String[] itemsArray = new String[items.size()];
+        int i = 0;
+        for (Country country: items){
+            itemsArray[i]= country.getIso3166_A2() + " - " + country.getLabel();
+            i++;
+        }
+
+        textCountry.setItems(itemsArray);
 
 
 
@@ -142,7 +158,7 @@ public class SpecimenSearchComposite extends Composite {
     public Text getTextHerbarium() {
         return textHerbarium;
     }
-    public Text getTextCountry() {
+    public Combo getTextCountry() {
         return textCountry;
     }
     public Text getTextLocality() {
index 120eea4c02faf6ba06e8cd875b2ae6c88fd407e8..1cb0997e9907de4480a9fec28580989accb419ef 100644 (file)
@@ -154,7 +154,12 @@ public class SpecimenSearchController implements Listener{
      * @see eu.etaxonomy.taxeditor.view.specimenSearch.SpecimenSearchComposite#getComboCountry()
      */
     public String getCountry() {
-        return specimenSearchComposite.getTextCountry().getText();
+        String result = specimenSearchComposite.getTextCountry().getText();
+        if (result.contains("-")){
+            result = result.substring(4).trim();
+        }
+        return result;
+
 //        return specimenSearchComposite.getComboCountry().getItem(specimenSearchComposite.getComboCountry().getSelectionIndex());
     }