Project

General

Profile

Download (3.06 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.isEntityComputed(((TaxonRowWrapperDTO) rowObject).getDescription())){
47
                configLabels.addLabel(CharacterMatrix.LABEL_TAXON_AGGREGATED_DESCRIPTION);
48
                isEditable = false;
49
            }
50
            else{
51
                configLabels.addLabel(CharacterMatrix.LABEL_TAXON_DESCRIPTION);
52
            }
53
        }
54

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