2 * Copyright (C) 2017 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
9 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.categorical
;
11 import org
.eclipse
.nebula
.widgets
.nattable
.edit
.editor
.ComboBoxCellEditor
;
12 import org
.eclipse
.nebula
.widgets
.nattable
.widget
.NatCombo
;
13 import org
.eclipse
.swt
.events
.SelectionEvent
;
14 import org
.eclipse
.swt
.events
.SelectionListener
;
15 import org
.eclipse
.swt
.widgets
.Composite
;
16 import org
.eclipse
.swt
.widgets
.Control
;
18 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RowWrapperDTO
;
19 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
20 import eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
.CharacterMatrix
;
23 * Cell editor for CategoricalData
28 public class CategoricalDataCellEditor
extends ComboBoxCellEditor
{
30 private CharacterMatrix matrix
;
32 public CategoricalDataCellEditor(CharacterMatrix matrix
, CategoricalComboBoxDataProvider categoricalComboBoxDataProvider
) {
33 super(categoricalComboBoxDataProvider
, 10);
40 public void setCanonicalValue(Object canonicalValue
) {
41 if(canonicalValue
==null){
42 Object rowWrapper
= matrix
.getBodyDataProvider().getRowObject(this.getRowIndex());
43 if(rowWrapper
instanceof RowWrapperDTO
){
44 Feature feature
= matrix
.getIndexToCharacterMap().get(getColumnIndex());
45 ((RowWrapperDTO
) rowWrapper
).addCategoricalData(feature
);
48 super.setCanonicalValue(canonicalValue
);
52 protected Control
activateCell(Composite parent
, Object originalCanonicalValue
) {
53 if(matrix
.getBodyDataProvider().getRowObject(this.getRowIndex()) instanceof RowWrapperDTO
){
54 NatCombo natCombo
= (NatCombo
) super.activateCell(parent
, originalCanonicalValue
);
55 natCombo
.addSelectionListener(new SelectionListener() {
57 public void widgetSelected(SelectionEvent e
) {
61 public void widgetDefaultSelected(SelectionEvent e
) {