hub
hub

Reputation: 39

How to set some data object to JFace TableViewer row

Currently, I rework on my code , because I want to use MVC and JFace. Native SWT provides the possibility to add some Objects to a SWT-TableItem by using the function .setData(..):

TableItem item = new TableItem(table, SWT.NONE, 1);
item.setData(someObject)

Is there a chance to do this in my new created Label- or ContentProviders?

Upvotes: 1

Views: 545

Answers (1)

greg-449
greg-449

Reputation: 111142

TableViewer (and other viewers) uses the item.setData(object) method itself to associate your data model object with the item. Setting the data value to something else will break the viewer.

Also the viewer does not guarantee to use the same item for a particular row for the life time of the table. Operations such as refresh may use new table items.

Upvotes: 1

Related Questions