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.view.checklist.e4;
|
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.edit.EditConfigAttributes;
|
15
|
import org.eclipse.nebula.widgets.nattable.edit.editor.ComboBoxCellEditor;
|
16
|
import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowDataLayer;
|
17
|
import org.eclipse.nebula.widgets.nattable.filterrow.FilterRowTextCellEditor;
|
18
|
import org.eclipse.nebula.widgets.nattable.filterrow.TextMatchingMode;
|
19
|
import org.eclipse.nebula.widgets.nattable.filterrow.config.FilterRowConfigAttributes;
|
20
|
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
|
21
|
|
22
|
import eu.etaxonomy.taxeditor.editor.descriptiveDataSet.matrix.supplementalInfo.SupplementalInfoDisplayConverter;
|
23
|
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
|
24
|
|
25
|
/**
|
26
|
* @author k.luther
|
27
|
* @since 13.12.2018
|
28
|
*
|
29
|
*/
|
30
|
public class FilterRowConfiguration extends AbstractRegistryConfiguration {
|
31
|
|
32
|
DistributionEditor editor;
|
33
|
|
34
|
/**
|
35
|
* @param distributionEditor
|
36
|
*/
|
37
|
public FilterRowConfiguration(DistributionEditor distributionEditor) {
|
38
|
editor = distributionEditor;
|
39
|
}
|
40
|
|
41
|
@Override
|
42
|
public void configureRegistry(IConfigRegistry configRegistry) {
|
43
|
|
44
|
// register the FilterRowTextCellEditor in the first column which
|
45
|
// immediately commits on key press
|
46
|
configRegistry.registerConfigAttribute(
|
47
|
EditConfigAttributes.CELL_EDITOR,
|
48
|
new FilterRowTextCellEditor(),
|
49
|
DisplayMode.NORMAL,
|
50
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 1);
|
51
|
|
52
|
configRegistry.registerConfigAttribute(
|
53
|
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
|
54
|
TextMatchingMode.CONTAINS,
|
55
|
DisplayMode.NORMAL,
|
56
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 1);
|
57
|
|
58
|
configRegistry.registerConfigAttribute(
|
59
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
60
|
new SupplementalInfoDisplayConverter(),
|
61
|
DisplayMode.NORMAL,
|
62
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 1);
|
63
|
|
64
|
configRegistry.registerConfigAttribute(
|
65
|
EditConfigAttributes.CELL_EDITOR,
|
66
|
new FilterRowTextCellEditor(),
|
67
|
DisplayMode.NORMAL,
|
68
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 2);
|
69
|
|
70
|
configRegistry.registerConfigAttribute(
|
71
|
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
|
72
|
TextMatchingMode.CONTAINS,
|
73
|
DisplayMode.NORMAL,
|
74
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 2);
|
75
|
|
76
|
configRegistry.registerConfigAttribute(
|
77
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
78
|
new SupplementalInfoDisplayConverter(),
|
79
|
DisplayMode.NORMAL,
|
80
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 2);
|
81
|
|
82
|
if (PreferencesUtil.isShowRankInChecklistEditor()){
|
83
|
configRegistry.registerConfigAttribute(
|
84
|
EditConfigAttributes.CELL_EDITOR,
|
85
|
new FilterRowTextCellEditor(),
|
86
|
DisplayMode.NORMAL,
|
87
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 3);
|
88
|
|
89
|
configRegistry.registerConfigAttribute(
|
90
|
FilterRowConfigAttributes.TEXT_MATCHING_MODE,
|
91
|
TextMatchingMode.CONTAINS,
|
92
|
DisplayMode.NORMAL,
|
93
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 3);
|
94
|
|
95
|
configRegistry.registerConfigAttribute(
|
96
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
97
|
new SupplementalInfoDisplayConverter(),
|
98
|
DisplayMode.NORMAL,
|
99
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + 3);
|
100
|
}
|
101
|
|
102
|
// Register a combo box editor to be displayed in the filter row
|
103
|
// cell when a value is selected from the combo, the object is
|
104
|
// converted to a string using the converter (registered below)
|
105
|
StatusComboBoxDataProvider dataProvider;
|
106
|
int start = 2;
|
107
|
if (PreferencesUtil.isShowRankInChecklistEditor()){
|
108
|
start = 3;
|
109
|
}
|
110
|
|
111
|
for (int i = start; i < editor.areas.size()+start; ++i) {
|
112
|
dataProvider = new StatusComboBoxDataProvider(editor);
|
113
|
ComboBoxCellEditor cellEditor = new ComboBoxCellEditor(dataProvider, dataProvider.getMaxVisibleItems());
|
114
|
cellEditor.setFreeEdit(true);
|
115
|
configRegistry.registerConfigAttribute(
|
116
|
EditConfigAttributes.CELL_EDITOR,
|
117
|
cellEditor,
|
118
|
DisplayMode.NORMAL,
|
119
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX + i);
|
120
|
|
121
|
|
122
|
|
123
|
configRegistry.registerConfigAttribute(
|
124
|
FilterRowConfigAttributes.FILTER_DISPLAY_CONVERTER,
|
125
|
new FilterStatusDisplayConverter(),
|
126
|
DisplayMode.NORMAL,
|
127
|
FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX+i);
|
128
|
|
129
|
configRegistry.registerConfigAttribute(
|
130
|
CellConfigAttributes.DISPLAY_CONVERTER,
|
131
|
new StatusDisplayConverter(),
|
132
|
DisplayMode.NORMAL,
|
133
|
DistributionEditorConfigLabelAccumulator.STATUS);
|
134
|
|
135
|
}
|
136
|
|
137
|
|
138
|
// // register the FilterRowTextCellEditor in the first column which
|
139
|
// // immediately commits on key press
|
140
|
// configRegistry.registerConfigAttribute(
|
141
|
// EditConfigAttributes.CELL_EDITOR,
|
142
|
// new FilterRowTextCellEditor(),
|
143
|
// DisplayMode.NORMAL,
|
144
|
// FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX
|
145
|
// + DistributionEditorConfigLabelAccumulator.STATUS);
|
146
|
//
|
147
|
// configRegistry.registerConfigAttribute(
|
148
|
// FilterRowConfigAttributes.TEXT_MATCHING_MODE,
|
149
|
// TextMatchingMode.CONTAINS,
|
150
|
// DisplayMode.NORMAL,
|
151
|
// FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX
|
152
|
// + DistributionEditorConfigLabelAccumulator.STATUS);
|
153
|
//
|
154
|
// configRegistry.registerConfigAttribute(
|
155
|
// CellConfigAttributes.DISPLAY_CONVERTER,
|
156
|
// new StatusDisplayConverter(),
|
157
|
// DisplayMode.NORMAL,
|
158
|
// FilterRowDataLayer.FILTER_ROW_COLUMN_LABEL_PREFIX
|
159
|
// + DistributionEditorConfigLabelAccumulator.STATUS);
|
160
|
|
161
|
|
162
|
|
163
|
|
164
|
|
165
|
configRegistry.registerConfigAttribute(
|
166
|
FilterRowConfigAttributes.TEXT_DELIMITER, "&"); //$NON-NLS-1$
|
167
|
|
168
|
}
|
169
|
|
170
|
}
|