commit 9f8cd3680c8b602f09ffef4a9e08e5ddf0689188
Author: Patrick Plitzner <p.plitzner@bgbm.org>
Date:   Fri Oct 5 08:32:47 2018 +0200

    ref #7806 Sort result list

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
index 8161446bd..f289af751 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/GfBioTerminologyImportPresenter.java
@@ -10,7 +10,10 @@ package eu.etaxonomy.taxeditor.view.webimport.termimport;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Iterator;
+import java.util.List;
 import java.util.stream.Collectors;
 
 import org.eclipse.jface.util.LocalSelectionTransfer;
@@ -35,7 +38,6 @@ import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.ColorResources;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.preference.Resources;
-import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.ParserUtil;
 import eu.etaxonomy.taxeditor.view.webimport.termimport.parser.TermParser;
 import eu.etaxonomy.taxeditor.view.webimport.termimport.requests.RequestSearch;
 import eu.etaxonomy.taxeditor.view.webimport.termimport.wrapper.OntologyTermWrapper;
@@ -184,14 +186,6 @@ public class GfBioTerminologyImportPresenter {
         }
     }
 
-    private void loadTermDetails(){
-        OntologyTermWrapper selectedWrapper = getSelectedTerm((IStructuredSelection) composite.getTreeTermHierarchy().getSelection());
-        if(selectedWrapper!=null){
-            ParserUtil.loadDetails(selectedWrapper);
-            updateDetails(new StructuredSelection(selectedWrapper));
-        }
-    }
-
     private void search(){
         //clear result count
         composite.getLblResultCount().setText("");
@@ -205,11 +199,41 @@ public class GfBioTerminologyImportPresenter {
             MessagingUtils.informationDialog(NO_CONNECTION_TITLE, NO_CONNECTION_MESSAGE);
             return;
         }
-        Collection<OntologyTermWrapper> wrapperList = new ArrayList<>();
+        List<OntologyTermWrapper> wrapperList = new ArrayList<>();
         wrapperList = TermParser.parse(response);
         if(wrapperList.isEmpty()){
             MessagingUtils.informationDialog(Messages.GfBioTerminologyImportPresenter_NO_RESULTS_TITLE, Messages.GfBioTerminologyImportPresenter_NO_RESULTS_MESSAGE);
         }
+        //sort list
+        Collections.sort(wrapperList, new Comparator<OntologyTermWrapper>() {
+            @Override
+            public int compare(OntologyTermWrapper o1, OntologyTermWrapper o2) {
+                String label1 = o1.getLabel();
+                String label2 = o2.getLabel();
+                //1. search string at the beginning
+                if(label1.startsWith(searchString)){
+                    if(!label2.startsWith(searchString)){
+                        return -1;
+                    }
+                    else{
+                        return label1.compareTo(label2);
+                    }
+                }
+                else if(label2.startsWith(searchString)){
+                    return 1;
+                }
+                //2. label that contains search string
+                if(label1.contains(searchString)){
+                    if(!label2.contains(searchString)){
+                        return -1;
+                    }
+                }
+                else if(label2.contains(searchString)){
+                    return 1;
+                }
+                return label1.compareTo(label2);
+            }
+        });
         composite.getTreeTermHierarchy().setInput(wrapperList);
 
         composite.getLblResultCount().setText(Integer.toString(wrapperList.size()));
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/TermParser.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/TermParser.java
index f6d30de67..36c13c83d 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/TermParser.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/webimport/termimport/parser/TermParser.java
@@ -9,7 +9,6 @@
 package eu.etaxonomy.taxeditor.view.webimport.termimport.parser;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 
 import org.json.JSONArray;
@@ -38,7 +37,7 @@ public class TermParser {
         return null;
     }
 
-    public static Collection<OntologyTermWrapper> parse(String response){
+    public static List<OntologyTermWrapper> parse(String response){
         List<OntologyTermWrapper> wrapperList = new ArrayList<>();
         try {
             JSONObject jsonResponse = new JSONObject(response);
