[EMF Forms] TableFactory with EditingSupport [message #1753729] |
Thu, 09 February 2017 11:50 |
Hauke Fuhrmann Messages: 26 Registered: January 2016 |
Junior Member |
|
|
Hi there,
following the blog post [1] I created a table for some EMF object list. Now I want to make the cells editable but do not really find the right way to configure the TableViewerSWTBuilder.
builder.addColumn(true, // resizeable
true, // moveable
SWT.LEFT, // styleBits
10, // weight
50, // minWidth
"Name", // columnText
"Name des Knotens", // tooltipText
nameProvider, // CellLabelProvider
nameEditingSupport, // editingSupportProvider
null // Image
);
How do I obtain the EditingSupportCreator? Some EditingSupportUtil requires a CellEditorCreator. A naive implementation of that results in NPEs [2] cause of problems with databinding.
final EditingSupportCreator nameEditingSupport = EditingSupportUtil.createEditingSupport(
new MyCellEditorCreator(), infra, CorePackage.eINSTANCE.getNamedObject_Name());
class MyCellEditorCreator implements CellEditorCreator {
@Override
public CellEditor createCellEditor(final TableViewer viewer) {
return new StringCellEditor();
}
}
How can the editing support configured correctly?
A side question: Creating the table colums with the builder methods of the TableViewerSWTBuilder is a little bulky. At first sight it looks like a wrapper around plain JFace Tables. What's the major advantage of this builder over plain JFace?
Cheers,
Hauke
[1] http://eclipsesource.com/blogs/2016/03/09/emf-forms-1-8-0-feature-factories-for-treeviewer-and-tableviewer/
[2] NPE at org.eclipse.jface.viewers.ColumnViewerEditor.activateCellEditor(ColumnViewerEditor.java:199)
|
|
|
Re: [EMF Forms] TableFactory with EditingSupport [message #1754063 is a reply to message #1753729] |
Tue, 14 February 2017 09:24 |
|
Hi,
I think you have to pass a parent-composite to your Cell Editor (viewer.getTable()). Otherwise the cell editor's control will not be created, causing a NPE.
Regarding the side question, this builder is nothing more but a wrapper around the JFace API allowing to use the fluent pattern. The main advantage is, that you may reuse some of the building blocks very easily without subclassing. Main use case for us was to make it easy to create custom Tables which look like the ones created with EMFForms renderers. So it is used by us to create very custom tables with the same look and feel as the generic table renderer.
Cheers
Johannes
Johannes Faltermeier
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
Powered by
FUDForum. Page generated in 0.03374 seconds