39 |
39 |
import org.eclipse.nebula.widgets.nattable.NatTable;
|
40 |
40 |
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommand;
|
41 |
41 |
import org.eclipse.nebula.widgets.nattable.command.VisualRefreshCommandHandler;
|
|
42 |
import org.eclipse.nebula.widgets.nattable.config.AbstractRegistryConfiguration;
|
42 |
43 |
import org.eclipse.nebula.widgets.nattable.config.AbstractUiBindingConfiguration;
|
43 |
44 |
import org.eclipse.nebula.widgets.nattable.config.ConfigRegistry;
|
44 |
45 |
import org.eclipse.nebula.widgets.nattable.config.DefaultNatTableStyleConfiguration;
|
|
46 |
import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
|
|
47 |
import org.eclipse.nebula.widgets.nattable.config.IEditableRule;
|
45 |
48 |
import org.eclipse.nebula.widgets.nattable.data.IRowIdAccessor;
|
46 |
49 |
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
|
|
50 |
import org.eclipse.nebula.widgets.nattable.edit.EditConfigAttributes;
|
|
51 |
import org.eclipse.nebula.widgets.nattable.edit.action.MouseEditAction;
|
|
52 |
import org.eclipse.nebula.widgets.nattable.edit.config.DefaultEditConfiguration;
|
|
53 |
import org.eclipse.nebula.widgets.nattable.edit.editor.TextCellEditor;
|
47 |
54 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsEventLayer;
|
48 |
55 |
import org.eclipse.nebula.widgets.nattable.extension.glazedlists.GlazedListsSortModel;
|
49 |
56 |
import org.eclipse.nebula.widgets.nattable.grid.GridRegion;
|
... | ... | |
54 |
61 |
import org.eclipse.nebula.widgets.nattable.grid.layer.CornerLayer;
|
55 |
62 |
import org.eclipse.nebula.widgets.nattable.grid.layer.GridLayer;
|
56 |
63 |
import org.eclipse.nebula.widgets.nattable.grid.layer.RowHeaderLayer;
|
|
64 |
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayer;
|
57 |
65 |
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
|
58 |
66 |
import org.eclipse.nebula.widgets.nattable.layer.stack.DefaultBodyLayerStack;
|
59 |
67 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionModel;
|
60 |
68 |
import org.eclipse.nebula.widgets.nattable.selection.RowSelectionProvider;
|
61 |
69 |
import org.eclipse.nebula.widgets.nattable.sort.SortHeaderLayer;
|
62 |
70 |
import org.eclipse.nebula.widgets.nattable.sort.config.SingleClickSortConfiguration;
|
|
71 |
import org.eclipse.nebula.widgets.nattable.style.DisplayMode;
|
63 |
72 |
import org.eclipse.nebula.widgets.nattable.style.theme.ModernNatTableThemeConfiguration;
|
64 |
73 |
import org.eclipse.nebula.widgets.nattable.ui.binding.UiBindingRegistry;
|
|
74 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.CellEditorMouseEventMatcher;
|
65 |
75 |
import org.eclipse.nebula.widgets.nattable.ui.matcher.MouseEventMatcher;
|
66 |
76 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuAction;
|
67 |
77 |
import org.eclipse.nebula.widgets.nattable.ui.menu.PopupMenuBuilder;
|
... | ... | |
236 |
246 |
cornerDataProvider), rowHeaderLayer, sortHeaderLayer);
|
237 |
247 |
//grid
|
238 |
248 |
GridLayer gridLayer = new GridLayer(bodyLayer, sortHeaderLayer,
|
239 |
|
rowHeaderLayer, cornerLayer);
|
|
249 |
rowHeaderLayer, cornerLayer, false);//set autoconfigure to false to get rid of the single click editing
|
240 |
250 |
dataLayer.setColumnPercentageSizing(true);
|
241 |
251 |
natTable = new NatTable(bottomComposite, gridLayer, false);
|
242 |
252 |
natTable.setConfigRegistry(configRegistry);
|
... | ... | |
251 |
261 |
}
|
252 |
262 |
|
253 |
263 |
private void configureTable(){
|
|
264 |
|
|
265 |
//this configuration enables cell to be editable in general
|
|
266 |
//necessary because we disabled this beforehand by setting autoconfigure=false
|
|
267 |
//in the GridLayer
|
|
268 |
((AbstractLayer) natTable.getLayer()).addConfiguration(new DefaultEditConfiguration());
|
|
269 |
|
|
270 |
natTable.addConfiguration(new AbstractUiBindingConfiguration() {
|
|
271 |
@Override
|
|
272 |
public void configureUiBindings(UiBindingRegistry uiBindingRegistry) {
|
|
273 |
uiBindingRegistry.registerFirstDoubleClickBinding(new CellEditorMouseEventMatcher(GridRegion.BODY),
|
|
274 |
new MouseEditAction());
|
|
275 |
}
|
|
276 |
});
|
|
277 |
|
254 |
278 |
//+++CONTEXT MENU+++
|
255 |
279 |
menuService.registerContextMenu(natTable, "eu.etaxonomy.taxeditor.bulkeditor.popupmenu.bulkeditor"); //$NON-NLS-1$
|
256 |
280 |
// get the menu registered by EMenuService
|
... | ... | |
270 |
294 |
uiBindingRegistry.registerMouseDownBinding(
|
271 |
295 |
new MouseEventMatcher(
|
272 |
296 |
SWT.NONE,
|
273 |
|
GridRegion.BODY,
|
274 |
|
MouseEventMatcher.RIGHT_BUTTON),
|
275 |
|
new PopupMenuAction(e4Menu));
|
276 |
|
uiBindingRegistry.registerMouseDownBinding(
|
277 |
|
new MouseEventMatcher(
|
278 |
|
SWT.NONE,
|
279 |
|
GridRegion.COLUMN_HEADER,
|
280 |
|
MouseEventMatcher.RIGHT_BUTTON),
|
281 |
|
new PopupMenuAction(e4Menu));
|
282 |
|
uiBindingRegistry.registerMouseDownBinding(
|
283 |
|
new MouseEventMatcher(
|
284 |
|
SWT.NONE,
|
285 |
|
GridRegion.CORNER,
|
|
297 |
null,
|
286 |
298 |
MouseEventMatcher.RIGHT_BUTTON),
|
287 |
299 |
new PopupMenuAction(e4Menu));
|
288 |
300 |
}
|
289 |
301 |
});
|
290 |
302 |
|
291 |
303 |
//make cells editable to allow selecting the text
|
292 |
|
// natTable.addConfiguration(new AbstractRegistryConfiguration() {
|
293 |
|
// @Override
|
294 |
|
// public void configureRegistry(IConfigRegistry configRegistry) {
|
295 |
|
// //make cell editable
|
296 |
|
// configRegistry.registerConfigAttribute(
|
297 |
|
// EditConfigAttributes.CELL_EDITABLE_RULE,
|
298 |
|
// IEditableRule.ALWAYS_EDITABLE,
|
299 |
|
// DisplayMode.EDIT);
|
300 |
|
// //register editor
|
301 |
|
// NullTextEditor nullTextEditor = new NullTextEditor();
|
302 |
|
// ContextInjectionFactory.inject(nullTextEditor, context);
|
303 |
|
// configRegistry.registerConfigAttribute(
|
304 |
|
// EditConfigAttributes.CELL_EDITOR,
|
305 |
|
// nullTextEditor,
|
306 |
|
// DisplayMode.EDIT);
|
307 |
|
// }
|
308 |
|
// });
|
|
304 |
natTable.addConfiguration(new AbstractRegistryConfiguration() {
|
|
305 |
@Override
|
|
306 |
public void configureRegistry(IConfigRegistry configRegistry) {
|
|
307 |
//make cell editable
|
|
308 |
configRegistry.registerConfigAttribute(
|
|
309 |
EditConfigAttributes.CELL_EDITABLE_RULE,
|
|
310 |
IEditableRule.ALWAYS_EDITABLE,
|
|
311 |
DisplayMode.EDIT);
|
|
312 |
//register editor
|
|
313 |
TextCellEditor editor = new TextCellEditor();
|
|
314 |
editor.setEditable(false);
|
|
315 |
configRegistry.registerConfigAttribute(
|
|
316 |
EditConfigAttributes.CELL_EDITOR,
|
|
317 |
editor,
|
|
318 |
DisplayMode.NORMAL);
|
|
319 |
}
|
|
320 |
});
|
309 |
321 |
|
310 |
322 |
//enable sorting
|
311 |
323 |
natTable.addConfiguration(new SingleClickSortConfiguration());
|
ref #7518 re-enable cell text selection (on double-click)