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
;
11 import org
.eclipse
.nebula
.widgets
.nattable
.data
.IColumnPropertyAccessor
;
13 import eu
.etaxonomy
.cdm
.api
.service
.dto
.RowWrapperDTO
;
14 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
17 * Property accesor class which maps setting and getting data for
18 * each row in the character matrix
23 public class SpecimenColumnPropertyAccessor
implements IColumnPropertyAccessor
<Object
>{
25 private CharacterMatrix matrix
;
27 public SpecimenColumnPropertyAccessor(CharacterMatrix matrix
) {
36 public Object
getDataValue(Object rowObject
, int columnIndex
) {
37 if(rowObject
instanceof RowWrapperDTO
){
38 RowWrapperDTO rowWrapper
= (RowWrapperDTO
)rowObject
;
39 switch (columnIndex
) {
41 if(matrix
.isTreeView()){
42 return "#"+rowWrapper
.getSpecimen().getId();
45 return rowWrapper
.getTaxonNode();
48 return rowWrapper
.getFieldUnit();
50 return rowWrapper
.getIdentifier();
52 return rowWrapper
.getCountry();
57 Feature feature
= matrix
.getIndexToFeatureMap().get(columnIndex
);
58 return rowWrapper
.getDataValueForFeature(feature
);
59 } else if (columnIndex
== 0) {
69 public void setDataValue(Object rowObject
, int columnIndex
, Object newValue
) {
70 if(rowObject
instanceof RowWrapperDTO
){
71 RowWrapperDTO rowWrapper
= (RowWrapperDTO
)rowObject
;
72 Feature feature
= matrix
.getIndexToFeatureMap().get(columnIndex
);
73 rowWrapper
.setDataValueForFeature(feature
, newValue
);
81 public int getColumnCount() {
82 return matrix
.getPropertyToLabelMap().size();
89 public String
getColumnProperty(int columnIndex
) {
90 return matrix
.getPropertyToLabelMap().get(columnIndex
);
97 public int getColumnIndex(String propertyName
){
98 return matrix
.getPropertyToLabelMap().indexOf(propertyName
);