Revision 079534a2
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorConfigLabelAccumulator.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import org.eclipse.nebula.widgets.nattable.NatTable; |
12 | 12 |
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; |
13 |
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider; |
|
13 | 14 |
import org.eclipse.nebula.widgets.nattable.layer.LabelStack; |
14 | 15 |
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator; |
15 | 16 |
|
... | ... | |
22 | 23 |
* |
23 | 24 |
*/ |
24 | 25 |
public class BulkEditorConfigLabelAccumulator implements IConfigLabelAccumulator { |
26 |
|
|
27 |
public static final String BOOLEAN_COLUMN = "boolean_column"; |
|
28 |
|
|
25 | 29 |
private ListDataProvider<CdmBase> dataProvider; |
26 | 30 |
private AbstractBulkEditorInput input; |
27 | 31 |
private NatTable natTable; |
32 |
private DefaultColumnHeaderDataProvider colHeaderDataProvider; |
|
28 | 33 |
|
29 | 34 |
public BulkEditorConfigLabelAccumulator(NatTable natTable, ListDataProvider<CdmBase> dataProvider, |
30 |
AbstractBulkEditorInput input) { |
|
35 |
DefaultColumnHeaderDataProvider colHeaderDataProvider, AbstractBulkEditorInput input) {
|
|
31 | 36 |
super(); |
32 | 37 |
this.dataProvider = dataProvider; |
38 |
this.colHeaderDataProvider = colHeaderDataProvider; |
|
33 | 39 |
this.input = input; |
34 | 40 |
this.natTable = natTable; |
35 | 41 |
} |
... | ... | |
40 | 46 |
if(rowPosition<0){ |
41 | 47 |
return; |
42 | 48 |
} |
49 |
if(input.isBooleanProperty(colHeaderDataProvider.getColumnHeaderLabel(columnPosition))){ |
|
50 |
configLabels.addLabel(BOOLEAN_COLUMN); |
|
51 |
} |
|
43 | 52 |
CdmBase rowObject = dataProvider.getRowObject(rowPosition); |
44 | 53 |
if(input.getMergeCandidates().contains(rowObject)){ |
45 | 54 |
configLabels.addLabel(BulkEditorE4Composite.LABEL_CANDIDATE); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4Composite.java | ||
---|---|---|
30 | 30 |
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommandHandler; |
31 | 31 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; |
32 | 32 |
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration; |
33 |
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; |
|
33 | 34 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry; |
34 | 35 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration; |
35 | 36 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; |
36 | 37 |
import org.eclipse.nebula.widgets.nattable.config.IEditableRule; |
37 | 38 |
import org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor; |
38 | 39 |
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider; |
40 |
import org.eclipse.nebula.widgets.nattable.data.convert.DefaultBooleanDisplayConverter; |
|
39 | 41 |
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes; |
40 | 42 |
import org.eclipse.nebula.widgets.nattable.edit.action.MouseEditAction; |
41 | 43 |
import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration; |
... | ... | |
53 | 55 |
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer; |
54 | 56 |
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; |
55 | 57 |
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack; |
58 |
import org.eclipse.nebula.widgets.nattable.painter.cell.CheckBoxPainter; |
|
56 | 59 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel; |
57 | 60 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider; |
58 | 61 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer; |
... | ... | |
169 | 172 |
ConfigRegistry configRegistry = new ConfigRegistry(); |
170 | 173 |
//property map |
171 | 174 |
Map<String, String> propertyToLabels = new HashMap<>(); |
172 |
for(String columnLabel:columnList){ |
|
173 |
propertyToLabels.put(columnLabel, columnLabel); |
|
174 |
} |
|
175 |
columnList.forEach(columnLabel->propertyToLabels.put(columnLabel, columnLabel)); |
|
176 |
|
|
175 | 177 |
String[] propertyNames = columnList.toArray(columnList.toArray(new String[columnList.size()])); |
176 | 178 |
//sorted list |
177 | 179 |
SortedList<CdmBase> sortedList = new SortedList<>(bulkEditor.getEditorInput().getModel(), bulkEditor.getEditorInput().getTitleComparator()); |
... | ... | |
192 | 194 |
dataLayer.setColumnPercentageSizing(0, true); |
193 | 195 |
dataLayer.setColumnWidthPercentageByPosition(0, 45); |
194 | 196 |
for(int i=1;i<columnList.size();i++){ |
195 |
dataLayer.setColumnWidthByPosition(i, 100); |
|
197 |
// if(bulkEditor.getEditorInput().isBooleanProperty(columnList.get(i))){ |
|
198 |
// dataLayer.setColumnWidthByPosition(i, 20); |
|
199 |
// } |
|
200 |
// else{ |
|
201 |
dataLayer.setColumnWidthByPosition(i, 100); |
|
202 |
// } |
|
196 | 203 |
} |
197 | 204 |
|
198 | 205 |
//column |
... | ... | |
235 | 242 |
} |
236 | 243 |
})); |
237 | 244 |
|
238 |
//add label to deduplication rows |
|
239 |
dataLayer.setConfigLabelAccumulator(new BulkEditorConfigLabelAccumulator(natTable, bodyDataProvider, bulkEditor.getEditorInput())); |
|
245 |
dataLayer.setConfigLabelAccumulator(new BulkEditorConfigLabelAccumulator(natTable, bodyDataProvider, |
|
246 |
colHeaderDataProvider, |
|
247 |
bulkEditor.getEditorInput())); |
|
240 | 248 |
|
241 | 249 |
//add tooltip to table |
242 | 250 |
new BulkEditorTooltip(natTable); |
... | ... | |
276 | 284 |
} |
277 | 285 |
}); |
278 | 286 |
|
287 |
//show boolean values as check boxes |
|
288 |
natTable.addConfiguration(new AbstractRegistryConfiguration() { |
|
289 |
@Override |
|
290 |
public void configureRegistry(IConfigRegistry configRegistry) { |
|
291 |
configRegistry.registerConfigAttribute( |
|
292 |
CellConfigAttributes.CELL_PAINTER, |
|
293 |
new CheckBoxPainter(), |
|
294 |
DisplayMode.NORMAL, |
|
295 |
BulkEditorConfigLabelAccumulator.BOOLEAN_COLUMN); |
|
296 |
|
|
297 |
configRegistry.registerConfigAttribute( |
|
298 |
CellConfigAttributes.DISPLAY_CONVERTER, |
|
299 |
new DefaultBooleanDisplayConverter(), |
|
300 |
DisplayMode.NORMAL, |
|
301 |
BulkEditorConfigLabelAccumulator.BOOLEAN_COLUMN); |
|
302 |
} |
|
303 |
}); |
|
304 |
|
|
279 | 305 |
//+++CONTEXT MENU+++ |
280 | 306 |
menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$ |
281 | 307 |
// get the menu registered by EMenuService |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AbstractBulkEditorInput.java | ||
---|---|---|
152 | 152 |
return null; |
153 | 153 |
} |
154 | 154 |
|
155 |
public boolean isBooleanProperty(String property) { |
|
156 |
if(property.equals(PROPERTY_PROTECTED_TITLECACHE)){ |
|
157 |
return true; |
|
158 |
} |
|
159 |
return false; |
|
160 |
} |
|
161 |
|
|
155 | 162 |
public Comparator<T> getTitleComparator(){ |
156 | 163 |
return new TitleCacheComparator(); |
157 | 164 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/AgentEditorInput.java | ||
---|---|---|
94 | 94 |
return super.getPropertyValue(cdmBase, property); |
95 | 95 |
} |
96 | 96 |
|
97 |
@Override |
|
98 |
public boolean isBooleanProperty(String property) { |
|
99 |
if(property.equals(PROPERTY_TEAM_HAS_MORE_MEMBERS)){ |
|
100 |
return true; |
|
101 |
} |
|
102 |
return super.isBooleanProperty(property); |
|
103 |
} |
|
104 |
|
|
97 | 105 |
@Override |
98 | 106 |
public String getName() { |
99 | 107 |
return BulkEditorInputType.AGENT.label; |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/NameEditorInput.java | ||
---|---|---|
98 | 98 |
return super.getPropertyValue(cdmBase, property); |
99 | 99 |
} |
100 | 100 |
|
101 |
@Override |
|
102 |
public boolean isBooleanProperty(String property) { |
|
103 |
if(property.equals(PROPERTY_PROTECT_NAME_CACHE) |
|
104 |
|| property.equals(PROPERTY_PROTECT_AUTHORSHIP_CACHE)){ |
|
105 |
return true; |
|
106 |
} |
|
107 |
return super.isBooleanProperty(property); |
|
108 |
} |
|
109 |
|
|
101 | 110 |
@Override |
102 | 111 |
public String getName() { |
103 | 112 |
return BulkEditorInputType.NAME.label; |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/OccurrenceEditorInput.java | ||
---|---|---|
104 | 104 |
return super.getPropertyValue(cdmBase, property); |
105 | 105 |
} |
106 | 106 |
|
107 |
@Override |
|
108 |
public boolean isBooleanProperty(String property) { |
|
109 |
if(property.equals(PROPERTY_PUBLISH)){ |
|
110 |
return true; |
|
111 |
} |
|
112 |
return super.isBooleanProperty(property); |
|
113 |
} |
|
114 |
|
|
107 | 115 |
private Object getCollector(SpecimenOrObservationBase<?> cdmBase) { |
108 | 116 |
if(cdmBase.isInstanceOf(FieldUnit.class)){ |
109 | 117 |
GatheringEvent gatheringEvent = HibernateProxyHelper.deproxy(cdmBase, FieldUnit.class).getGatheringEvent(); |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/ReferenceEditorInput.java | ||
---|---|---|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
@Override |
80 |
public boolean isBooleanProperty(String property) { |
|
81 |
if(property.equals(PROPERTY_PROTECT_NOMENCLATURAL_CACHE)){ |
|
82 |
return true; |
|
83 |
} |
|
84 |
return super.isBooleanProperty(property); |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
80 | 88 |
public String getName() { |
81 | 89 |
return BulkEditorInputType.REFERENCE.label; |
82 | 90 |
} |
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/TaxonEditorInput.java | ||
---|---|---|
57 | 57 |
} |
58 | 58 |
|
59 | 59 |
@Override |
60 |
public boolean isBooleanProperty(String property) { |
|
61 |
if(property.equals(PROPERTY_PUBLISH)){ |
|
62 |
return true; |
|
63 |
} |
|
64 |
return super.isBooleanProperty(property); |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
60 | 68 |
public String getName() { |
61 | 69 |
return BulkEditorInputType.TAXON.label; |
62 | 70 |
} |
Also available in: Unified diff
ref #7502 Show boolean properties in checkboxes