Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to convert data beans to strings within cells
How to convert data beans to strings within cells [message #1173649] Wed, 06 November 2013 17:15 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Hi,

what is the proper way to represent data within cells? I see there is
IDataProvider#Object getDataValue(int columnIndex, int rowIndex)

So I return my beans here. But who is responsible for converting a bean to its string representation? By default it uses toString() on that beans returned from IDataProvider.

I don't want to return strings form dataProvider because I think it would be useful to have the data bean available within cell. So, is there any technique like LabelProviders in JFace Viewers? I have found the IDisplayConverter. Should I use it? I don't think it's a good idea to register a IDisplayConverter for all my columns (since every column has its own bean as it data value).

Or am I missing something?
Re: How to convert data beans to strings within cells [message #1174602 is a reply to message #1173649] Thu, 07 November 2013 07:44 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
Hi,

well the information is hidden in the current documentation, but you find it in the editing section under data conversion: http://eclipse.org/nattable/documentation.php?page=editing

The IDisplayConverter is indeed what you are looking for. Why do you think it is not a good idea to register an IDisplayConverter for every column? This is similar to the LabelProvider technique for JFace viewers.

You have two options:
1. You create a specific IDisplayConverter for every column and register it for every single column
2. You create one IDisplayConverter that performs an instanceof check against your data value

Greez,
Dirk
Re: How to convert data beans to strings within cells [message #1174653 is a reply to message #1174602] Thu, 07 November 2013 08:29 Go to previous messageGo to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
That is the only page I didn't read because I don't need editing in my table Smile
Yes, the second option sounds good to me. Thanks.
Re: How to convert data beans to strings within cells [message #1174724 is a reply to message #1174653] Thu, 07 November 2013 09:24 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
I know, the documentation needs to be updated and completed.

You should notice that the second option might have negative impact on the performance, as for every cell several instanceof checks will be performed in that case. Not sure if that hits you, but I should mention it for completeness.
Previous Topic:Styling based on combination of labels
Next Topic:Left border is not drawn
Goto Forum:
  


Current Time: Fri Aug 23 13:11:51 GMT 2019

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

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

Back to the top