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 774f66b4614dee6ed7ad3594982dc54bb9b462ea..b1d5c05d7292f010e810bd20d89281dccf79a43a 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 4985a9a0fff6412069e061b7532777570f411d94..feb256ca93d200502fb754b52339022f5f534215 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 f29abe64d74fefcc7ceaeb20a6a73fbad0d064e6..6435880a0757cd10369780575fdff51c02683dd6 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);