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
.api
.service
.dto
.SpecimenRowWrapperDTO
;
15 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonRowWrapperDTO
;
16 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
19 * Property accesor class which maps setting and getting data for
20 * each row in the character matrix
25 public class SpecimenColumnPropertyAccessor
implements IColumnPropertyAccessor
<Object
>{
27 private CharacterMatrix matrix
;
29 public SpecimenColumnPropertyAccessor(CharacterMatrix matrix
) {
38 public Object
getDataValue(Object rowObject
, int columnIndex
) {
39 if(rowObject
instanceof SpecimenRowWrapperDTO
){
40 SpecimenRowWrapperDTO rowWrapper
= (SpecimenRowWrapperDTO
) rowObject
;
41 switch (columnIndex
) {
43 if(matrix
.isTreeView()){
44 return "#"+rowWrapper
.getSpecimen().getId();
47 return rowWrapper
.getTaxonNode();
50 return rowWrapper
.getFieldUnit();
52 return rowWrapper
.getIdentifier();
54 return rowWrapper
.getCountry();
59 Feature feature
= matrix
.getIndexToFeatureMap().get(columnIndex
);
60 return rowWrapper
.getDataValueForFeature(feature
);
61 } else if(rowObject
instanceof TaxonRowWrapperDTO
){
62 TaxonRowWrapperDTO taxonWrapper
= (TaxonRowWrapperDTO
)rowObject
;
64 return taxonWrapper
.getDescription();
66 Feature feature
= matrix
.getIndexToFeatureMap().get(columnIndex
);
67 return taxonWrapper
.getDataValueForFeature(feature
);
70 else if (columnIndex
== 0) {
80 public void setDataValue(Object rowObject
, int columnIndex
, Object newValue
) {
81 if(rowObject
instanceof RowWrapperDTO
){
82 RowWrapperDTO rowWrapper
= (RowWrapperDTO
)rowObject
;
83 Feature feature
= matrix
.getIndexToFeatureMap().get(columnIndex
);
84 rowWrapper
.setDataValueForFeature(feature
, newValue
);
92 public int getColumnCount() {
93 return matrix
.getPropertyToLabelMap().size();
100 public String
getColumnProperty(int columnIndex
) {
101 return matrix
.getPropertyToLabelMap().get(columnIndex
);
108 public int getColumnIndex(String propertyName
){
109 return matrix
.getPropertyToLabelMap().indexOf(propertyName
);