Project

General

Profile

Download (2.9 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.common.MarkerType;
16
import eu.etaxonomy.cdm.model.description.Feature;
17
import eu.etaxonomy.cdm.model.description.TaxonDescription;
18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19

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

    
27
    public static final String QUANTITATIVE = "QUANTITATIVE";
28
    public static final String CATEGORICAL = "CATEGORICAL";
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
        Object rowObject = matrix.getBodyDataProvider().getRowObject(rowPosition);
40
        if(rowObject instanceof TaxonNode){
41
            configLabels.addLabel(CharacterMatrix.LABEL_TAXON_ROW);
42
        }
43
        else if(rowObject instanceof TaxonRowWrapperDTO){
44
            TaxonDescription taxonDescription = ((TaxonRowWrapperDTO) rowObject).getDescription();
45
            boolean isComputed = taxonDescription.getMarkers().stream()
46
            .anyMatch(marker->marker.getMarkerType().equals(MarkerType.COMPUTED()));
47
            if(isComputed){
48
                configLabels.addLabel(CharacterMatrix.LABEL_TAXON_AGGREGATED_DESCRIPTION);
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
            }
73
            else if(feature.isSupportsQuantitativeData()){
74
                configLabels.addLabel(QUANTITATIVE);
75
            }
76
        }
77
    }
78
}
(8-8/20)