Project

General

Profile

Download (3.41 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
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.
8
*/
9
package eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix;
10

    
11
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
12
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
13

    
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;
17

    
18
/**
19
 * @author pplitzner
20
 * @since Jul 6, 2018
21
 *
22
 */
23
public class CharacterMatrixConfigLabelAccumulator implements IConfigLabelAccumulator {
24

    
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";
29

    
30
    private CharacterMatrix matrix;
31

    
32
    public CharacterMatrixConfigLabelAccumulator(CharacterMatrix matrix) {
33
        super();
34
        this.matrix = matrix;
35
    }
36

    
37
    @Override
38
    public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
39
        boolean isEditable = true;
40

    
41
        Object rowObject = matrix.getBodyDataProvider().getRowObject(rowPosition);
42
        if(rowObject instanceof TaxonNode){
43
            configLabels.addLabel(CharacterMatrix.LABEL_TAXON_ROW);
44
        }
45
        else if(rowObject instanceof TaxonRowWrapperDTO){
46
            if(MatrixUtility.isAggregatedTaxonDescription((TaxonRowWrapperDTO) rowObject)){
47
                configLabels.addLabel(CharacterMatrix.LABEL_TAXON_AGGREGATED_DESCRIPTION);
48
                isEditable = false;
49
            }
50
            else if(MatrixUtility.isDefaultTaxonDescription((TaxonRowWrapperDTO) rowObject)){
51
                configLabels.addLabel(CharacterMatrix.LABEL_TAXON_DEFAULT_DESCRIPTION);
52
            }
53
            else if(MatrixUtility.isLiteratureTaxonDescription((TaxonRowWrapperDTO) rowObject)){
54
                configLabels.addLabel(CharacterMatrix.LABEL_TAXON_LITERATURE_DESCRIPTION);
55
            }
56
            configLabels.addLabel(CharacterMatrix.LABEL_TAXON_DESCRIPTION);
57
        }
58

    
59
        if(columnPosition==0){
60
            configLabels.addLabel(CharacterMatrix.TAXON_COLUMN);
61
        }
62
        else if(columnPosition==1){
63
            configLabels.addLabel(CharacterMatrix.COLLECTOR_COLUMN);
64
        }
65
        else if(columnPosition==2){
66
            configLabels.addLabel(CharacterMatrix.IDENTIFIER_COLUMN);
67
        }
68
        else if(columnPosition==3){
69
            configLabels.addLabel(CharacterMatrix.COUNTRY_COLUMN);
70
        }
71
        else{
72
            Feature feature = matrix.getFeatures().get(columnPosition-CharacterMatrix.LEADING_COLUMN_COUNT);
73
            configLabels.addLabel(MatrixUtility.getProperty(feature));
74
            if(feature.isSupportsCategoricalData()){
75
                configLabels.addLabel(CATEGORICAL);
76
                if(isEditable){
77
                    configLabels.addLabel(CATEGORICAL_EDITABLE);
78
                }
79
            }
80
            else if(feature.isSupportsQuantitativeData()){
81
                configLabels.addLabel(QUANTITATIVE);
82
                if(isEditable){
83
                    configLabels.addLabel(QUANTITATIVE_EDITABLE);
84
                }
85
            }
86
        }
87
    }
88
}
(8-8/19)