Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » TableCellPainter trouble (TableCellPainter configuration for specific rows-columns instead of entire column)
TableCellPainter trouble [message #1772861] Mon, 18 September 2017 03:02 Go to next message
Maximus X is currently offline Maximus XFriend
Messages: 6
Registered: March 2017
Junior Member
Hi,
I'm wondering if anybody encountered this issue... I'm using TableCellPainter as configuration for specific columns, however not all rows under this column contain lists of values. Pretty standard configuration from documentation, as below:

		private void registerColumnElevenTablePainter(IConfigRegistry configRegistry) {
			configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new TableCellPainter(), DisplayMode.NORMAL, COLUMN_THREE_LABEL);
						
			configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITABLE_RULE, IEditableRule.ALWAYS_EDITABLE, DisplayMode.EDIT, COLUMN_THREE_LABEL);
						
			configRegistry.registerConfigAttribute(EditConfigAttributes.CELL_EDITOR, new TableCellEditor(), DisplayMode.NORMAL, COLUMN_THREE_LABEL);
						
		}


The problem arises when I try to edit values for a row that does not contain lists of values, in that column that was configured for a cellpainter. It only contains a single value at that cell. Attempting to edit it gives me a nattable exception below:

java.lang.NullPointerException
	at org.eclipse.nebula.widgets.nattable.edit.editor.TableCellEditor.getCanonicalValue(TableCellEditor.java:202)
	at org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor.commit(AbstractCellEditor.java:364)
	at org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor.commit(AbstractCellEditor.java:356)
	at org.eclipse.nebula.widgets.nattable.edit.editor.TableCellEditor$InternalFocusListener$1.run(TableCellEditor.java:785)
	at org.eclipse.swt.widgets.Display.runTimer(Display.java:4329)


Looks like it happens because indeed it expects a list of editable values at that point. I wonder, is there a way to add TableCellPainter configuration on specific rows only, or perhaps disable it for rows where it is not needed? The other way I thought of is to have all rows contain lists of values (even if the list will contain only a single value), but it seems a little absurd to modify the data to work around this.
Re: TableCellPainter trouble [message #1772863 is a reply to message #1772861] Mon, 18 September 2017 04:53 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2615
Registered: July 2012
Senior Member
Java is a type-safe language. From that point of view your data model is not correct, as it sometimes contains a list of values and sometimes a single object. So it is not absurd to change the data model, it would be correct from the type-safe point of view.

But that was not your question. If you want to stick with the Javascript programming model, you need to register a column label accumulator that performs a type check whether the object contains a list in that column or a single value. Then apply a special label in case it is a list and register the TableCellPainter and TableCellEditor for that special label instead of a label that is applied to the whole column.
Re: TableCellPainter trouble [message #1772913 is a reply to message #1772863] Mon, 18 September 2017 16:44 Go to previous messageGo to next message
Maximus X is currently offline Maximus XFriend
Messages: 6
Registered: March 2017
Junior Member
Thanks Dirk, I'll try both of these approaches and see what works for me. While working with TableCellPainter configuration, there is something I noticed - the subdivided cell always displays an empty "extra" subcell on the bottom, e.g. if a list contained four elements, then five subcells would be displayed, last one being empty. Looking at it, it might not be a full cell but "extra" space instead, do you know how to rectify that?

https://imgur.com/ComW7LX
Re: TableCellPainter trouble [message #1772915 is a reply to message #1772913] Mon, 18 September 2017 17:01 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2615
Registered: July 2012
Senior Member
Well your row height is bigger than the three subcells. I don't know where the row height is set in your configuration
Previous Topic:ComboBox Multiselect/Use Checkbox question
Next Topic:Possible bug in NatCombo using multiselect with easy fix
Goto Forum:
  


Current Time: Wed Sep 26 08:38:43 GMT 2018

Powered by FUDForum. Page generated in 0.02789 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top