4985a9a0fff6412069e061b7532777570f411d94
[taxeditor.git] / eu.etaxonomy.taxeditor.editor / src / main / java / eu / etaxonomy / taxeditor / editor / descriptiveDataSet / matrix / categorical / CategoricalComboBoxDataProvider.java
1 // $Id$
2 /**
3 * Copyright (C) 2018 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical;
11
12 import java.util.List;
13
14 import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
15
16 import eu.etaxonomy.cdm.model.description.Feature;
17 import eu.etaxonomy.cdm.model.description.State;
18 import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix;
19
20 /**
21 * @author pplitzner
22 * @date 24.07.2018
23 *
24 */
25 public class CategoricalComboBoxDataProvider implements IComboBoxDataProvider {
26
27 private CharacterMatrix matrix;
28 private int maxVisibleItems;
29
30 public CategoricalComboBoxDataProvider(CharacterMatrix matrix) {
31 super();
32 this.matrix = matrix;
33 }
34
35 @Override
36 public List<?> getValues(int columnIndex, int rowIndex) {
37 Feature feature = matrix.getIndexToCharacterMap().get(columnIndex);
38 List<State> supportedStatesForCategoricalFeature = matrix.getSupportedStatesForCategoricalFeature(feature);
39 maxVisibleItems = Math.max(3, Math.min(supportedStatesForCategoricalFeature.size()-1, 10));
40 return supportedStatesForCategoricalFeature;
41 }
42
43 int getMaxVisibleItems(){
44 return maxVisibleItems;
45 }
46 }