Project

General

Profile

Download (7.48 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.config.AbstractRegistryConfiguration;
12
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes;
13
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
14
import org.eclipse.nebula.widgets.nattable.painter.cell.ImagePainter;
15
import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
16
import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.CellPainterDecorator;
17
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
18
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
19
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
20
import org.eclipse.nebula.widgets.nattable.style.Style;
21
import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum;
22
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
23

    
24
/**
25
 * @author pplitzner
26
 * @since Jul 6, 2018
27
 *
28
 */
29
public final class CharacterMatrixLabelStyleConfiguration extends AbstractRegistryConfiguration {
30
    @Override
31
    public void configureRegistry(IConfigRegistry configRegistry) {
32
        //different background color styles
33
        Style taxonRowStyle = new Style();
34
        taxonRowStyle.setAttributeValue(
35
                CellStyleAttributes.BACKGROUND_COLOR,
36
                GUIHelper.COLOR_WIDGET_BACKGROUND);
37
        configRegistry.registerConfigAttribute(
38
                CellConfigAttributes.CELL_STYLE,
39
                taxonRowStyle,
40
                DisplayMode.NORMAL,
41
                CharacterMatrix.LABEL_TAXON_ROW);
42

    
43
        Style taxonAggregationStyle = new Style();
44
        taxonAggregationStyle.setAttributeValue(
45
                CellStyleAttributes.BACKGROUND_COLOR,
46
                GUIHelper.getColor(255, 255, 153));
47
        configRegistry.registerConfigAttribute(
48
                CellConfigAttributes.CELL_STYLE,
49
                taxonAggregationStyle,
50
                DisplayMode.NORMAL,
51
                CharacterMatrix.LABEL_TAXON_AGGREGATED_DESCRIPTION);
52

    
53
        Style taxonDefaultDescriptionStyle = new Style();
54
        taxonDefaultDescriptionStyle.setAttributeValue(
55
                CellStyleAttributes.BACKGROUND_COLOR,
56
                GUIHelper.COLOR_WIDGET_BACKGROUND);
57
        configRegistry.registerConfigAttribute(
58
                CellConfigAttributes.CELL_STYLE,
59
                taxonDefaultDescriptionStyle,
60
                DisplayMode.NORMAL,
61
                CharacterMatrix.LABEL_TAXON_DEFAULT_DESCRIPTION);
62

    
63
        Style hasDefaultValueStyle = new Style();
64
        hasDefaultValueStyle.setAttributeValue(
65
                CellStyleAttributes.BACKGROUND_COLOR,
66
                GUIHelper.COLOR_WIDGET_LIGHT_SHADOW);
67
        configRegistry.registerConfigAttribute(
68
                CellConfigAttributes.CELL_STYLE,
69
                hasDefaultValueStyle,
70
                DisplayMode.NORMAL,
71
                CharacterMatrixConfigLabelAccumulator.HAS_DEFAULT);
72
        
73
        Style notEditableValueStyle = new Style();
74
        notEditableValueStyle.setAttributeValue(
75
                CellStyleAttributes.BACKGROUND_COLOR,
76
                GUIHelper.COLOR_GRAY);
77
        configRegistry.registerConfigAttribute(
78
                CellConfigAttributes.CELL_STYLE,
79
                notEditableValueStyle,
80
                DisplayMode.NORMAL,
81
                CharacterMatrixConfigLabelAccumulator.NOT_EDITABLE);
82
        
83
        Style notApplicableValueStyle = new Style();
84
        notApplicableValueStyle.setAttributeValue(
85
                CellStyleAttributes.BACKGROUND_COLOR,
86
                GUIHelper.COLOR_GRAY);
87
        notApplicableValueStyle.setAttributeValue(
88
                CellStyleAttributes.FOREGROUND_COLOR,
89
                GUIHelper.COLOR_GRAY);
90
        configRegistry.registerConfigAttribute(
91
                CellConfigAttributes.CELL_STYLE,
92
                notApplicableValueStyle,
93
                DisplayMode.NORMAL,
94
                CharacterMatrixConfigLabelAccumulator.NOT_APPLICABLE);
95

    
96
        Style defaultOverriddenStyle = new Style();
97
        defaultOverriddenStyle.setAttributeValue(
98
                CellStyleAttributes.BACKGROUND_COLOR,
99
                GUIHelper.getColor(255, 128, 0));
100
        configRegistry.registerConfigAttribute(
101
                CellConfigAttributes.CELL_STYLE,
102
                defaultOverriddenStyle,
103
                DisplayMode.NORMAL,
104
                CharacterMatrixConfigLabelAccumulator.DEFAULT_OVERRIDDEN);
105

    
106
        //cell painter for supplemental data
107
        configRegistry.registerConfigAttribute(
108
                CellConfigAttributes.CELL_PAINTER,
109
                new CellPainterDecorator(
110
                        new TextPainter(),
111
                        CellEdgeEnum.BOTTOM_RIGHT,
112
                        new ImagePainter(GUIHelper.getImage("plus")),
113
                        false),
114
                DisplayMode.NORMAL,
115
                CharacterMatrix.LABEL_DESCRIPTION_HAS_SUPPLEMENTAL_DATA);
116

    
117
        Style style = new Style();
118

    
119
        style.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, HorizontalAlignmentEnum.LEFT);
120
        configRegistry.registerConfigAttribute(
121
                CellConfigAttributes.CELL_STYLE,
122
                style,
123
                DisplayMode.NORMAL,
124
                CharacterMatrix.IDENTIFIER_COLUMN);
125
        configRegistry.registerConfigAttribute(
126
                CellConfigAttributes.CELL_STYLE,
127
                style,
128
                DisplayMode.NORMAL,
129
                CharacterMatrix.COLLECTOR_COLUMN);
130
        configRegistry.registerConfigAttribute(
131
                CellConfigAttributes.CELL_STYLE,
132
                style,
133
                DisplayMode.NORMAL,
134
                CharacterMatrix.COUNTRY_COLUMN);
135
        configRegistry.registerConfigAttribute(
136
                CellConfigAttributes.CELL_STYLE,
137
                style,
138
                DisplayMode.NORMAL,
139
                CharacterMatrix.TAXON_COLUMN);
140

    
141

    
142
        /*
143
         * cell painter for description icons
144
         */
145
        //literature
146
        configRegistry.registerConfigAttribute(
147
                CellConfigAttributes.CELL_PAINTER,
148
                new CellPainterDecorator(
149
                        new TextPainter(),
150
                        CellEdgeEnum.LEFT,
151
                        new ImagePainter(MatrixUtility.getLiteratureDescriptionIcon()),
152
                        true),
153
                DisplayMode.NORMAL,
154
                CharacterMatrix.LABEL_TAXON_LITERATURE_DESCRIPTION_ICON);
155
        //aggregation
156
        configRegistry.registerConfigAttribute(
157
                CellConfigAttributes.CELL_PAINTER,
158
                new CellPainterDecorator(
159
                        new TextPainter(),
160
                        CellEdgeEnum.LEFT,
161
                        new ImagePainter(MatrixUtility.getAggregatedDescriptionIcon()),
162
                        true),
163
                DisplayMode.NORMAL,
164
                CharacterMatrix.LABEL_TAXON_AGGREGATED_DESCRIPTION_ICON);
165
        //default
166
        configRegistry.registerConfigAttribute(
167
                CellConfigAttributes.CELL_PAINTER,
168
                new CellPainterDecorator(
169
                        new TextPainter(),
170
                        CellEdgeEnum.LEFT,
171
                        new ImagePainter(MatrixUtility.getDefaultDescriptionIcon()),
172
                        true),
173
                DisplayMode.NORMAL,
174
                CharacterMatrix.LABEL_TAXON_DEFAULT_DESCRIPTION_ICON);
175
    }
176
}
(7-7/18)