ref #7040 Fix addition of empty element in combos
authorPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 2 Nov 2017 13:56:39 +0000 (14:56 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Thu, 2 Nov 2017 13:57:46 +0000 (14:57 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/combo/TermComboElement.java

index d5dee1d87637afa13985dd1d5ed1adc1ac402675..7bd6f3b71497dd9de4618b301d626ad173d26147 100644 (file)
@@ -172,12 +172,6 @@ public class TermComboElement<T extends DefinedTermBase>
                int i = 1;
                int index = 0;
 
-               if(addEmptyElement){
-                   // Add an empty element for when nothing was selected yet
-                   combo.add(EMPTY_ELEMENT_LABEL);
-                   terms.add(emptyElement);
-               }
-
                if (termComparator != null) {
                        Collections.sort(preferredTerms, termComparator);
                }
@@ -213,7 +207,13 @@ public class TermComboElement<T extends DefinedTermBase>
 
                String[] items = labels.toArray(new String[0]);
         combo.setItems(items);
-       
+
+        if(addEmptyElement){
+            // Add an empty element for when nothing was selected yet
+            combo.add(EMPTY_ELEMENT_LABEL, 0);
+            terms.add(0, emptyElement);
+        }
+
         if (selection != null && index == 0) {
                        createTermNotInPreferredTerms(selection);
                }