2 * Copyright (C) 2018 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
.layer
.LabelStack
;
12 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.cell
.IConfigLabelAccumulator
;
14 import eu
.etaxonomy
.cdm
.api
.service
.dto
.TaxonRowWrapperDTO
;
15 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
23 public class CharacterMatrixConfigLabelAccumulator
implements IConfigLabelAccumulator
{
25 public static final String QUANTITATIVE
= "QUANTITATIVE";
26 public static final String CATEGORICAL
= "CATEGORICAL";
27 public static final String CATEGORICAL_EDITABLE
= CATEGORICAL
+"_EDITABLE";
28 public static final String QUANTITATIVE_EDITABLE
= QUANTITATIVE
+"_EDITABLE";
30 private CharacterMatrix matrix
;
32 public CharacterMatrixConfigLabelAccumulator(CharacterMatrix matrix
) {
38 public void accumulateConfigLabels(LabelStack configLabels
, int columnPosition
, int rowPosition
) {
39 boolean isEditable
= true;
41 Object rowObject
= matrix
.getBodyDataProvider().getRowObject(rowPosition
);
42 if(rowObject
instanceof TaxonNode
){
43 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_ROW
);
45 else if(rowObject
instanceof TaxonRowWrapperDTO
){
46 TaxonRowWrapperDTO taxonRowWrapper
= (TaxonRowWrapperDTO
) rowObject
;
47 if(MatrixUtility
.isAggregatedTaxonDescription(taxonRowWrapper
)){
48 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_AGGREGATED_DESCRIPTION
);
50 if(columnPosition
==0){
51 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_AGGREGATED_DESCRIPTION_ICON
);
54 else if(MatrixUtility
.isDefaultTaxonDescription(taxonRowWrapper
)){
55 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_DEFAULT_DESCRIPTION
);
56 if(columnPosition
==0){
57 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_DEFAULT_DESCRIPTION_ICON
);
60 else if(MatrixUtility
.isLiteratureTaxonDescription(taxonRowWrapper
)){
61 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_LITERATURE_DESCRIPTION
);
62 if(columnPosition
==0){
63 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_LITERATURE_DESCRIPTION_ICON
);
66 //check for supplemental data
67 if(!taxonRowWrapper
.getDescription().getSources().isEmpty() && columnPosition
==0){
68 configLabels
.addLabel(CharacterMatrix
.LABEL_DESCRIPTION_HAS_SUPPLEMENTAL_DATA
);
70 configLabels
.addLabel(CharacterMatrix
.LABEL_TAXON_DESCRIPTION
);
73 if(columnPosition
==0){
74 configLabels
.addLabel(CharacterMatrix
.TAXON_COLUMN
);
76 else if(columnPosition
==1){
77 configLabels
.addLabel(CharacterMatrix
.COLLECTOR_COLUMN
);
79 else if(columnPosition
==2){
80 configLabels
.addLabel(CharacterMatrix
.IDENTIFIER_COLUMN
);
82 else if(columnPosition
==3){
83 configLabels
.addLabel(CharacterMatrix
.COUNTRY_COLUMN
);
86 Feature feature
= matrix
.getFeatures().get(columnPosition
-CharacterMatrix
.LEADING_COLUMN_COUNT
);
87 configLabels
.addLabel(MatrixUtility
.getProperty(feature
));
88 if(feature
.isSupportsCategoricalData()){
89 configLabels
.addLabel(CATEGORICAL
);
91 configLabels
.addLabel(CATEGORICAL_EDITABLE
);
94 else if(feature
.isSupportsQuantitativeData()){
95 configLabels
.addLabel(QUANTITATIVE
);
97 configLabels
.addLabel(QUANTITATIVE_EDITABLE
);