|
1 |
/**
|
|
2 |
* Copyright (C) 2020 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.view.checklist.e4;
|
|
10 |
|
|
11 |
import org.eclipse.nebula.widgets.nattable.group.painter.ColumnGroupHeaderTextPainter;
|
|
12 |
import org.eclipse.nebula.widgets.nattable.group.painter.RowGroupHeaderTextPainter;
|
|
13 |
import org.eclipse.nebula.widgets.nattable.painter.cell.BackgroundPainter;
|
|
14 |
import org.eclipse.nebula.widgets.nattable.painter.cell.TextPainter;
|
|
15 |
import org.eclipse.nebula.widgets.nattable.painter.cell.VerticalTextPainter;
|
|
16 |
import org.eclipse.nebula.widgets.nattable.painter.cell.decorator.PaddingDecorator;
|
|
17 |
import org.eclipse.nebula.widgets.nattable.sort.painter.SortIconPainter;
|
|
18 |
import org.eclipse.nebula.widgets.nattable.sort.painter.SortableHeaderTextPainter;
|
|
19 |
import org.eclipse.nebula.widgets.nattable.style.BorderStyle;
|
|
20 |
import org.eclipse.nebula.widgets.nattable.style.BorderStyle.LineStyleEnum;
|
|
21 |
import org.eclipse.nebula.widgets.nattable.style.HorizontalAlignmentEnum;
|
|
22 |
import org.eclipse.nebula.widgets.nattable.style.theme.DefaultNatTableThemeConfiguration;
|
|
23 |
import org.eclipse.nebula.widgets.nattable.tree.painter.IndentedTreeImagePainter;
|
|
24 |
import org.eclipse.nebula.widgets.nattable.tree.painter.TreeImagePainter;
|
|
25 |
import org.eclipse.nebula.widgets.nattable.ui.util.CellEdgeEnum;
|
|
26 |
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
|
|
27 |
import org.eclipse.swt.SWT;
|
|
28 |
import org.eclipse.swt.graphics.FontData;
|
|
29 |
|
|
30 |
/**
|
|
31 |
* This is a class copied from ModernNatTableThemeConfiguration and adapted to the Cdm use case.
|
|
32 |
*
|
|
33 |
* @author k.luther
|
|
34 |
* @since Mar 5, 2020
|
|
35 |
*/
|
|
36 |
public class CdmModernNatTableThemeConfiguration extends DefaultNatTableThemeConfiguration {
|
|
37 |
{
|
|
38 |
this.defaultHAlign = HorizontalAlignmentEnum.LEFT;
|
|
39 |
this.defaultCellPainter =
|
|
40 |
new BackgroundPainter(
|
|
41 |
new PaddingDecorator(
|
|
42 |
new TextPainter(false, false),
|
|
43 |
0,
|
|
44 |
5,
|
|
45 |
0,
|
|
46 |
5,
|
|
47 |
false));
|
|
48 |
|
|
49 |
// column header styling
|
|
50 |
this.cHeaderHAlign = HorizontalAlignmentEnum.LEFT;
|
|
51 |
this.cHeaderFont = GUIHelper.DEFAULT_FONT;
|
|
52 |
TextPainter painter = new TextPainter();
|
|
53 |
painter.setCalculateByTextLength(true);
|
|
54 |
painter.setWrapText(false);
|
|
55 |
this.cHeaderCellPainter =
|
|
56 |
new PaddingDecorator(
|
|
57 |
painter,
|
|
58 |
0,
|
|
59 |
5,
|
|
60 |
0,
|
|
61 |
5);
|
|
62 |
|
|
63 |
// column header selection style
|
|
64 |
this.cHeaderSelectionFont = GUIHelper.DEFAULT_FONT;
|
|
65 |
this.cHeaderSelectionCellPainter =
|
|
66 |
new BackgroundPainter(
|
|
67 |
new PaddingDecorator(
|
|
68 |
new TextPainter(false, false),
|
|
69 |
0,
|
|
70 |
5,
|
|
71 |
0,
|
|
72 |
5,
|
|
73 |
false));
|
|
74 |
|
|
75 |
// row header styling
|
|
76 |
this.rHeaderFont = GUIHelper.DEFAULT_FONT;
|
|
77 |
|
|
78 |
// row header selection style
|
|
79 |
this.rHeaderSelectionFont = GUIHelper.DEFAULT_FONT;
|
|
80 |
this.rHeaderSelectionCellPainter = new TextPainter();
|
|
81 |
|
|
82 |
// no alternate row styling
|
|
83 |
this.evenRowBgColor = GUIHelper.COLOR_WHITE;
|
|
84 |
this.oddRowBgColor = GUIHelper.COLOR_WHITE;
|
|
85 |
|
|
86 |
// default selection style
|
|
87 |
this.defaultSelectionBgColor = GUIHelper.COLOR_LIST_SELECTION;
|
|
88 |
this.defaultSelectionFgColor = GUIHelper.COLOR_WHITE;
|
|
89 |
this.defaultSelectionFont = GUIHelper.DEFAULT_FONT;
|
|
90 |
|
|
91 |
// selection anchor
|
|
92 |
this.selectionAnchorSelectionBgColor = GUIHelper.COLOR_LIST_SELECTION;
|
|
93 |
this.selectionAnchorSelectionFgColor = GUIHelper.COLOR_WHITE;
|
|
94 |
this.selectionAnchorBorderStyle = new BorderStyle(1, GUIHelper.COLOR_BLUE, LineStyleEnum.SOLID);
|
|
95 |
|
|
96 |
// column/row group header style
|
|
97 |
this.cGroupHeaderHAlign = HorizontalAlignmentEnum.CENTER;
|
|
98 |
this.cGroupHeaderCellPainter = new ColumnGroupHeaderTextPainter();
|
|
99 |
this.rGroupHeaderCellPainter =
|
|
100 |
new BackgroundPainter(
|
|
101 |
new PaddingDecorator(
|
|
102 |
new RowGroupHeaderTextPainter(
|
|
103 |
new VerticalTextPainter(false, false),
|
|
104 |
CellEdgeEnum.BOTTOM,
|
|
105 |
false,
|
|
106 |
2,
|
|
107 |
true),
|
|
108 |
0,
|
|
109 |
0,
|
|
110 |
2,
|
|
111 |
0,
|
|
112 |
false));
|
|
113 |
|
|
114 |
// sort header styling
|
|
115 |
this.sortHeaderCellPainter =
|
|
116 |
new BackgroundPainter(
|
|
117 |
new PaddingDecorator(
|
|
118 |
new SortableHeaderTextPainter(
|
|
119 |
new TextPainter(false, false),
|
|
120 |
CellEdgeEnum.RIGHT,
|
|
121 |
new SortIconPainter(false),
|
|
122 |
false,
|
|
123 |
0,
|
|
124 |
false),
|
|
125 |
0,
|
|
126 |
2,
|
|
127 |
0,
|
|
128 |
5,
|
|
129 |
false));
|
|
130 |
this.selectedSortHeaderCellPainter =
|
|
131 |
new BackgroundPainter(
|
|
132 |
new PaddingDecorator(
|
|
133 |
new SortableHeaderTextPainter(
|
|
134 |
new TextPainter(false, false),
|
|
135 |
CellEdgeEnum.RIGHT,
|
|
136 |
new SortIconPainter(false, true),
|
|
137 |
false,
|
|
138 |
0,
|
|
139 |
false),
|
|
140 |
0,
|
|
141 |
2,
|
|
142 |
0,
|
|
143 |
5,
|
|
144 |
false));
|
|
145 |
|
|
146 |
TreeImagePainter treeImagePainter =
|
|
147 |
new TreeImagePainter(
|
|
148 |
false,
|
|
149 |
GUIHelper.getImage("right"), //$NON-NLS-1$
|
|
150 |
GUIHelper.getImage("right_down"), //$NON-NLS-1$
|
|
151 |
null);
|
|
152 |
this.treeStructurePainter =
|
|
153 |
new BackgroundPainter(
|
|
154 |
new PaddingDecorator(
|
|
155 |
new IndentedTreeImagePainter(
|
|
156 |
10,
|
|
157 |
null,
|
|
158 |
CellEdgeEnum.LEFT,
|
|
159 |
treeImagePainter,
|
|
160 |
false,
|
|
161 |
2,
|
|
162 |
true),
|
|
163 |
0,
|
|
164 |
5,
|
|
165 |
0,
|
|
166 |
5,
|
|
167 |
false));
|
|
168 |
|
|
169 |
TreeImagePainter treeSelectionImagePainter =
|
|
170 |
new TreeImagePainter(
|
|
171 |
false,
|
|
172 |
GUIHelper.getImage("right_inv"), //$NON-NLS-1$
|
|
173 |
GUIHelper.getImage("right_down_inv"), //$NON-NLS-1$
|
|
174 |
null);
|
|
175 |
this.treeStructureSelectionPainter =
|
|
176 |
new BackgroundPainter(
|
|
177 |
new PaddingDecorator(
|
|
178 |
new IndentedTreeImagePainter(
|
|
179 |
10,
|
|
180 |
null,
|
|
181 |
CellEdgeEnum.LEFT,
|
|
182 |
treeSelectionImagePainter,
|
|
183 |
false,
|
|
184 |
2,
|
|
185 |
true),
|
|
186 |
0,
|
|
187 |
5,
|
|
188 |
0,
|
|
189 |
5,
|
|
190 |
false));
|
|
191 |
|
|
192 |
FontData summaryRowFontData = GUIHelper.DEFAULT_FONT.getFontData()[0];
|
|
193 |
summaryRowFontData.setStyle(SWT.BOLD);
|
|
194 |
this.summaryRowFont = GUIHelper.getFont(summaryRowFontData);
|
|
195 |
this.summaryRowHAlign = HorizontalAlignmentEnum.RIGHT;
|
|
196 |
this.summaryRowBgColor = GUIHelper.COLOR_WIDGET_LIGHT_SHADOW;
|
|
197 |
|
|
198 |
this.summaryRowSelectionFont = GUIHelper.getFont(summaryRowFontData);
|
|
199 |
this.summaryRowSelectionBgColor = GUIHelper.COLOR_WIDGET_DARK_SHADOW;
|
|
200 |
|
|
201 |
this.renderCornerGridLines = true;
|
|
202 |
this.renderColumnHeaderGridLines = true;
|
|
203 |
}
|
|
204 |
}
|
ref #8047: adapt column width to length of header label