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;
|
45 |
44 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
|
46 |
45 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
|
47 |
46 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
|
... | ... | |
64 |
63 |
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
|
65 |
64 |
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
|
66 |
65 |
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;
|
69 |
66 |
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
|
70 |
67 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel;
|
71 |
68 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider;
|
72 |
69 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
|
73 |
70 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
|
74 |
|
import org.eclipse.nebula.widgets.nattable.style.CellStyleAttributes;
|
75 |
71 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
|
76 |
|
import org.eclipse.nebula.widgets.nattable.style.Style;
|
77 |
72 |
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
|
78 |
73 |
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
|
79 |
74 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;
|
80 |
75 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
|
81 |
76 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
|
82 |
77 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
|
83 |
|
import org.eclipse.nebula.widgets.nattable.util.GUIHelper;
|
84 |
78 |
import org.eclipse.swt.SWT;
|
85 |
79 |
import org.eclipse.swt.dnd.Clipboard;
|
86 |
80 |
import org.eclipse.swt.dnd.TextTransfer;
|
... | ... | |
268 |
262 |
}));
|
269 |
263 |
|
270 |
264 |
//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 |
|
});
|
|
265 |
dataLayer.setConfigLabelAccumulator(new BulkEditorConfigLabelAccumulator(bodyDataProvider, input));
|
284 |
266 |
|
285 |
267 |
//add tooltip to table
|
286 |
268 |
new BulkEditorTooltip(natTable);
|
... | ... | |
290 |
272 |
|
291 |
273 |
//this configuration enables cell to be editable in general
|
292 |
274 |
//necessary because we disabled this beforehand by setting autoconfigure=false
|
293 |
|
//in the GridLayer
|
|
275 |
//in the GridLayer constructor
|
294 |
276 |
((AbstractLayer) natTable.getLayer()).addConfiguration(new DefaultEditConfiguration());
|
295 |
277 |
|
296 |
278 |
natTable.addConfiguration(new AbstractUiBindingConfiguration() {
|
... | ... | |
301 |
283 |
}
|
302 |
284 |
});
|
303 |
285 |
|
|
286 |
//make cells editable to allow selecting the text
|
|
287 |
natTable.addConfiguration(new AbstractRegistryConfiguration() {
|
|
288 |
@Override
|
|
289 |
public void configureRegistry(IConfigRegistry configRegistry) {
|
|
290 |
//make cell editable
|
|
291 |
configRegistry.registerConfigAttribute(
|
|
292 |
EditConfigAttributes.CELL_EDITABLE_RULE,
|
|
293 |
IEditableRule.ALWAYS_EDITABLE,
|
|
294 |
DisplayMode.EDIT);
|
|
295 |
//register editor
|
|
296 |
TextCellEditor editor = new TextCellEditor();
|
|
297 |
editor.setEditable(false);
|
|
298 |
configRegistry.registerConfigAttribute(
|
|
299 |
EditConfigAttributes.CELL_EDITOR,
|
|
300 |
editor,
|
|
301 |
DisplayMode.NORMAL);
|
|
302 |
}
|
|
303 |
});
|
|
304 |
|
304 |
305 |
//+++CONTEXT MENU+++
|
305 |
306 |
menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$
|
306 |
307 |
// get the menu registered by EMenuService
|
... | ... | |
326 |
327 |
}
|
327 |
328 |
});
|
328 |
329 |
|
329 |
|
//make cells editable to allow selecting the text
|
330 |
|
natTable.addConfiguration(new AbstractRegistryConfiguration() {
|
331 |
|
@Override
|
332 |
|
public void configureRegistry(IConfigRegistry configRegistry) {
|
333 |
|
//make cell editable
|
334 |
|
configRegistry.registerConfigAttribute(
|
335 |
|
EditConfigAttributes.CELL_EDITABLE_RULE,
|
336 |
|
IEditableRule.ALWAYS_EDITABLE,
|
337 |
|
DisplayMode.EDIT);
|
338 |
|
//register editor
|
339 |
|
TextCellEditor editor = new TextCellEditor();
|
340 |
|
editor.setEditable(false);
|
341 |
|
configRegistry.registerConfigAttribute(
|
342 |
|
EditConfigAttributes.CELL_EDITOR,
|
343 |
|
editor,
|
344 |
|
DisplayMode.NORMAL);
|
345 |
|
}
|
346 |
|
});
|
347 |
330 |
|
348 |
331 |
//enable sorting
|
349 |
332 |
natTable.addConfiguration(new SingleClickSortConfiguration());
|
350 |
333 |
|
351 |
334 |
// 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 |
|
});
|
|
335 |
natTable.addConfiguration(new LabelStyleConfiguration());
|
373 |
336 |
|
374 |
337 |
//add default configuration because autoconfigure is set to false in constructor
|
375 |
338 |
natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
|
... | ... | |
474 |
437 |
@Optional
|
475 |
438 |
@Inject
|
476 |
439 |
private void updateAfterSearch(@UIEventTopic(WorkbenchEventConstants.BULK_EDITOR_SEARCH_FINISHED)IStructuredSelection selection){
|
477 |
|
|
478 |
|
|
479 |
440 |
if(selection!=null){
|
480 |
441 |
setSelection(selection);
|
481 |
442 |
}
|
482 |
|
// //auto resize columns
|
483 |
|
// InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(
|
484 |
|
// natTable, 2, natTable.getConfigRegistry(), new GCFactory(
|
485 |
|
// natTable));
|
486 |
|
// natTable.doCommand(command);
|
487 |
|
// command = new InitializeAutoResizeColumnsCommand(
|
488 |
|
// natTable, 1, natTable.getConfigRegistry(), new GCFactory(
|
489 |
|
// natTable));
|
490 |
|
// natTable.doCommand(command);
|
491 |
443 |
}
|
492 |
444 |
|
493 |
445 |
public void refresh(){
|
ref #7439 Code refactoring