ref #8242 Set max items for dropdown to 10 + sort items
authorPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 16 Apr 2019 13:56:45 +0000 (15:56 +0200)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Tue, 16 Apr 2019 13:56:45 +0000 (15:56 +0200)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrix.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/categorical/CategoricalComboBoxDataProvider.java
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/categorical/CategoricalDataCellEditor.java

index 774f66b..b1d5c05 100644 (file)
@@ -11,6 +11,7 @@ package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -291,6 +292,7 @@ public class CharacterMatrix extends Composite {
             if(character.isSupportsCategoricalData()){
                 List<State> supportedStates = new ArrayList<>();
                 character.getSupportedCategoricalEnumerations().forEach(voc->supportedStates.addAll(voc.getTerms()));
+                Collections.sort(supportedStates, (state1, state2)->state1.getLabel().compareTo(state2.getLabel()));
                 categoricalFeatureToStateMap.put(character, supportedStates);
             }
         });
index 4985a9a..feb256c 100644 (file)
@@ -25,7 +25,6 @@ import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix;
 public class CategoricalComboBoxDataProvider implements IComboBoxDataProvider {
 
     private CharacterMatrix matrix;
-    private int maxVisibleItems;
 
     public CategoricalComboBoxDataProvider(CharacterMatrix matrix) {
         super();
@@ -36,11 +35,7 @@ public class CategoricalComboBoxDataProvider implements IComboBoxDataProvider {
     public List<?> getValues(int columnIndex, int rowIndex) {
         Feature feature = matrix.getIndexToCharacterMap().get(columnIndex);
         List<State> supportedStatesForCategoricalFeature = matrix.getSupportedStatesForCategoricalFeature(feature);
-        maxVisibleItems = Math.max(3, Math.min(supportedStatesForCategoricalFeature.size()-1, 10));
         return supportedStatesForCategoricalFeature;
     }
 
-    int getMaxVisibleItems(){
-        return maxVisibleItems;
-    }
 }
index f29abe6..6435880 100644 (file)
@@ -30,7 +30,7 @@ public class CategoricalDataCellEditor extends ComboBoxCellEditor{
     private CharacterMatrix matrix;
 
     public CategoricalDataCellEditor(CharacterMatrix matrix, CategoricalComboBoxDataProvider categoricalComboBoxDataProvider) {
-        super(categoricalComboBoxDataProvider, categoricalComboBoxDataProvider.getMaxVisibleItems());
+        super(categoricalComboBoxDataProvider, 10);
         this.matrix = matrix;
         setUseCheckbox(true);
         setMultiselect(true);