Project

General

Profile

« Previous | Next » 

Revision c85838fb

Added by pplitzner over 4 years ago

ref #8450 Set config labels according to default values

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixConfigLabelAccumulator.java
11 11
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
12 12
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
13 13

  
14
import com.sun.org.apache.xalan.internal.utils.FeatureManager.Feature;
15

  
16
import eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO;
14 17
import eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO;
15
import eu.etaxonomy.cdm.model.description.Feature;
16 18
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
17 19

  
18 20
/**
......
22 24
 */
23 25
public class CharacterMatrixConfigLabelAccumulator implements IConfigLabelAccumulator {
24 26

  
27
    public static final String HAS_DEFAULT = "HAS_DEFAULT";
28
    public static final String DEFAULT_OVERRIDDEN = "DEFAULT_OVERRIDDEN";
25 29
    public static final String QUANTITATIVE = "QUANTITATIVE";
26 30
    public static final String CATEGORICAL = "CATEGORICAL";
27 31
    public static final String CATEGORICAL_EDITABLE = CATEGORICAL+"_EDITABLE";
......
85 89
        else{
86 90
            Feature feature = matrix.getFeatures().get(columnPosition-CharacterMatrix.LEADING_COLUMN_COUNT);
87 91
            configLabels.addLabel(MatrixUtility.getProperty(feature));
92
            // check for default values
93
            if(rowObject instanceof SpecimenRowWrapperDTO){
94
                SpecimenRowWrapperDTO specimenRowWrapper = (SpecimenRowWrapperDTO)rowObject;
95
                if(hasDefaultValue(feature, specimenRowWrapper)){
96
                    configLabels.addLabel(HAS_DEFAULT);
97
                }
98
                if(specimenRowWrapper.getDataValueForFeature(feature)!=null){
99
                    configLabels.addLabel(DEFAULT_OVERRIDDEN);
100
                }
101
            }
102

  
88 103
            if(feature.isSupportsCategoricalData()){
89 104
                configLabels.addLabel(CATEGORICAL);
90 105
                if(isEditable){
......
99 114
            }
100 115
        }
101 116
    }
117

  
118
    private boolean hasDefaultValue(Feature feature, SpecimenRowWrapperDTO specimenRowWrapper) {
119
        TaxonRowWrapperDTO defaultDescription = specimenRowWrapper.getDefaultDescription();
120
        return defaultDescription.getDescription().getElements().stream().anyMatch(element->element.getFeature().equals(feature));
121
    }
102 122
}
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CharacterMatrixLabelStyleConfiguration.java
71 71
                DisplayMode.NORMAL,
72 72
                CharacterMatrix.LABEL_TAXON_LITERATURE_DESCRIPTION);
73 73

  
74
        Style hasDefaultValueStyle = new Style();
75
        hasDefaultValueStyle.setAttributeValue(
76
                CellStyleAttributes.BACKGROUND_COLOR,
77
                GUIHelper.COLOR_GRAY);
78
        configRegistry.registerConfigAttribute(
79
                CellConfigAttributes.CELL_STYLE,
80
                hasDefaultValueStyle,
81
                DisplayMode.NORMAL,
82
                CharacterMatrixConfigLabelAccumulator.HAS_DEFAULT);
83

  
84
        Style defaultOverriddenStyle = new Style();
85
        defaultOverriddenStyle.setAttributeValue(
86
                CellStyleAttributes.BACKGROUND_COLOR,
87
                GUIHelper.COLOR_RED);
88
        configRegistry.registerConfigAttribute(
89
                CellConfigAttributes.CELL_STYLE,
90
                defaultOverriddenStyle,
91
                DisplayMode.NORMAL,
92
                CharacterMatrixConfigLabelAccumulator.DEFAULT_OVERRIDDEN);
93

  
74 94
        //cell painter for supplemental data
75 95
        configRegistry.registerConfigAttribute(
76 96
                CellConfigAttributes.CELL_PAINTER,

Also available in: Unified diff