import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
import org.eclipse.swt.graphics.Point;
-import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalComboBoxDataProvider;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataCellEditor;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical.CategoricalDataDisplayConverter;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.quantitative.QuantitativeDataDialogEditor;
DisplayMode.NORMAL,
CharacterMatrixConfigLabelAccumulator.CATEGORICAL
);
+ //register categorical editor
+ configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
+ new CategoricalDataCellEditor(matrix, new CategoricalComboBoxDataProvider(matrix)),
+ DisplayMode.EDIT,
+ CharacterMatrixConfigLabelAccumulator.CATEGORICAL
+ );
/**
editDialogSettings,
DisplayMode.EDIT,
CharacterMatrixConfigLabelAccumulator.QUANTITATIVE);
-
-
- //TODO: this for loop can maybe be avoided
- matrix.getFeatures().forEach(feature->registerColumnConfiguration(feature, configRegistry));
}
- private void registerColumnConfiguration(Feature feature, IConfigRegistry configRegistry) {
- if(feature.isSupportsCategoricalData()){
- //add combo box cell editor
- //register editor
- configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR,
- new CategoricalDataCellEditor(matrix.getSupportedStatesForCategoricalFeature(feature), matrix, feature),
- DisplayMode.EDIT,
- MatrixUtility.getProperty(feature));
-
- }
- }
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2018 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical;
+
+import java.util.List;
+
+import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
+
+import eu.etaxonomy.cdm.model.description.Feature;
+import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix;
+
+/**
+ * @author pplitzner
+ * @date 24.07.2018
+ *
+ */
+public class CategoricalComboBoxDataProvider implements IComboBoxDataProvider {
+
+ private CharacterMatrix matrix;
+ private int maxVisibleItems;
+
+ public CategoricalComboBoxDataProvider(CharacterMatrix matrix) {
+ super();
+ this.matrix = matrix;
+ }
+
+ @Override
+ public List<?> getValues(int columnIndex, int rowIndex) {
+ Feature feature = matrix.getIndexToFeatureMap().get(columnIndex);
+ List<State> supportedStatesForCategoricalFeature = matrix.getSupportedStatesForCategoricalFeature(feature);
+ maxVisibleItems = Math.max(3, Math.min(supportedStatesForCategoricalFeature.size()-1, 10));
+ return supportedStatesForCategoricalFeature;
+ }
+
+ int getMaxVisibleItems(){
+ return maxVisibleItems;
+ }
+}
*/
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.categorical;
-import java.util.List;
-
import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
import org.eclipse.nebula.widgets.nattable.widget.NatCombo;
import org.eclipse.swt.events.SelectionEvent;
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO;
import eu.etaxonomy.cdm.model.description.Feature;
-import eu.etaxonomy.cdm.model.description.State;
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.CharacterMatrix;
/**
public class CategoricalDataCellEditor extends ComboBoxCellEditor{
private CharacterMatrix matrix;
- private Feature feature;
- public CategoricalDataCellEditor(List<State> list, CharacterMatrix matrix, Feature feature) {
- super(list, Math.max(3, Math.min(list.size()-1, 10)));
+ public CategoricalDataCellEditor(CharacterMatrix matrix, CategoricalComboBoxDataProvider categoricalComboBoxDataProvider) {
+ super(categoricalComboBoxDataProvider, categoricalComboBoxDataProvider.getMaxVisibleItems());
this.matrix = matrix;
- this.feature = feature;
setUseCheckbox(true);
setMultiselect(true);
}
if(canonicalValue==null){
Object rowWrapper = matrix.getBodyDataProvider().getRowObject(this.getRowIndex());
if(rowWrapper instanceof RowWrapperDTO){
+ Feature feature = matrix.getIndexToFeatureMap().get(getColumnIndex());
((RowWrapperDTO) rowWrapper).addCategoricalData(feature);
}
}
super.setCanonicalValue(canonicalValue);
}
- /**
- * {@inheritDoc}
- */
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue) {
if(matrix.getBodyDataProvider().getRowObject(this.getRowIndex()) instanceof RowWrapperDTO){