Revision 6328df3b
Added by Patrick Plitzner almost 6 years ago
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/e4/BulkEditorE4.java | ||
---|---|---|
41 | 41 |
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommandHandler; |
42 | 42 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration; |
43 | 43 |
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration; |
44 |
import org.eclipse.nebula.widgets.nattable.config.CellConfigAttributes; |
|
44 | 45 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry; |
45 | 46 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration; |
46 | 47 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry; |
... | ... | |
63 | 64 |
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer; |
64 | 65 |
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer; |
65 | 66 |
import org.eclipse.nebula.widgets.nattable.layer.DataLayer; |
67 |
import org.eclipse.nebula.widgets.nattable.layer.LabelStack; |
|
68 |
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator; |
|
66 | 69 |
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack; |
67 | 70 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel; |
68 | 71 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider; |
69 | 72 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer; |
70 | 73 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration; |
74 |
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes; |
|
71 | 75 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode; |
76 |
import org.eclipse.nebula.widgets.nattable.style.Style; |
|
72 | 77 |
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration; |
73 | 78 |
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry; |
74 | 79 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher; |
75 | 80 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher; |
76 | 81 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction; |
77 | 82 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder; |
83 |
import org.eclipse.nebula.widgets.nattable.util.GUIHelper; |
|
78 | 84 |
import org.eclipse.swt.SWT; |
79 | 85 |
import org.eclipse.swt.dnd.Clipboard; |
80 | 86 |
import org.eclipse.swt.dnd.TextTransfer; |
... | ... | |
119 | 125 |
IDirtyMarkable, IDerivedUnitFacadePart, IPartContentHasFactualData, |
120 | 126 |
IPartContentHasSupplementalData, IPartContentHasMedia, IE4SavablePart, ITaxonEditor { |
121 | 127 |
|
128 |
public static final String TARGET_LABEL = "target"; |
|
129 |
public static final String CANDIDATE_LABEL = "candidate"; |
|
130 |
|
|
122 | 131 |
public static final String TYPE_PROPERTY = Messages.BulkEditorE4_TYPE; |
123 | 132 |
|
124 | 133 |
@Inject |
... | ... | |
214 | 223 |
dataLayer.registerCommandHandler(new VisualRefreshCommandHandler()); |
215 | 224 |
GlazedListsEventLayer<CdmBase> eventLayer = new GlazedListsEventLayer<>(dataLayer, input.getModel()); |
216 | 225 |
bodyLayer = new DefaultBodyLayerStack(eventLayer); |
226 |
|
|
227 |
dataLayer.setColumnPercentageSizing(true); |
|
228 |
dataLayer.setColumnWidthPercentageByPosition(0, 80); |
|
229 |
dataLayer.setColumnWidthPercentageByPosition(1, 20); |
|
230 |
|
|
217 | 231 |
//column |
218 | 232 |
DataLayer columnHeaderDataLayer = new DataLayer(colHeaderDataProvider); |
219 | 233 |
ColumnHeaderLayer columnHeaderLayer = new ColumnHeaderLayer( |
... | ... | |
233 | 247 |
DataLayer rowHeaderDataLayer = new DataLayer(rowHeaderDataProvider); |
234 | 248 |
RowHeaderLayer rowHeaderLayer = new RowHeaderLayer(rowHeaderDataLayer, |
235 | 249 |
bodyLayer, bodyLayer.getSelectionLayer()); |
236 |
dataLayer.setColumnPercentageSizing(true); |
|
237 |
dataLayer.setColumnWidthPercentageByPosition(0, 80); |
|
238 |
dataLayer.setColumnWidthPercentageByPosition(1, 20); |
|
239 | 250 |
|
240 | 251 |
//corner |
241 | 252 |
DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider( |
... | ... | |
255 | 266 |
return input.getModel().indexOf(rowObject); |
256 | 267 |
} |
257 | 268 |
})); |
269 |
|
|
270 |
//add label to deduplication rows |
|
271 |
dataLayer.setConfigLabelAccumulator(new IConfigLabelAccumulator() { |
|
272 |
|
|
273 |
@Override |
|
274 |
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) { |
|
275 |
CdmBase rowObject = bodyDataProvider.getRowObject(rowPosition); |
|
276 |
if(input.getMergeCandidates().contains(rowObject)){ |
|
277 |
configLabels.addLabel(CANDIDATE_LABEL); |
|
278 |
} |
|
279 |
else if(input.getMergeTarget()==rowObject){ |
|
280 |
configLabels.addLabel(TARGET_LABEL); |
|
281 |
} |
|
282 |
} |
|
283 |
}); |
|
284 |
|
|
285 |
//add tooltip to table |
|
286 |
new BulkEditorTooltip(natTable); |
|
258 | 287 |
} |
259 | 288 |
|
260 | 289 |
private void configureTable(){ |
... | ... | |
318 | 347 |
|
319 | 348 |
//enable sorting |
320 | 349 |
natTable.addConfiguration(new SingleClickSortConfiguration()); |
350 |
|
|
351 |
// Custom style for deduplication labels |
|
352 |
natTable.addConfiguration(new AbstractRegistryConfiguration() { |
|
353 |
@Override |
|
354 |
public void configureRegistry(IConfigRegistry configRegistry) { |
|
355 |
Style cellStyle = new Style(); |
|
356 |
cellStyle.setAttributeValue( |
|
357 |
CellStyleAttributes.BACKGROUND_COLOR, |
|
358 |
GUIHelper.COLOR_YELLOW); |
|
359 |
configRegistry.registerConfigAttribute( |
|
360 |
CellConfigAttributes.CELL_STYLE, cellStyle, |
|
361 |
DisplayMode.NORMAL, CANDIDATE_LABEL); |
|
362 |
|
|
363 |
cellStyle = new Style(); |
|
364 |
cellStyle.setAttributeValue( |
|
365 |
CellStyleAttributes.BACKGROUND_COLOR, |
|
366 |
GUIHelper.COLOR_GREEN); |
|
367 |
configRegistry.registerConfigAttribute( |
|
368 |
CellConfigAttributes.CELL_STYLE, cellStyle, |
|
369 |
DisplayMode.NORMAL, TARGET_LABEL); |
|
370 |
|
|
371 |
} |
|
372 |
}); |
|
373 |
|
|
321 | 374 |
//add default configuration because autoconfigure is set to false in constructor |
322 | 375 |
natTable.addConfiguration(new DefaultNatTableStyleConfiguration()); |
323 | 376 |
natTable.configure(); |
Also available in: Unified diff
ref #7518 Colorize deduplication rows + tooltip