Question

I have successfully mapped an array of objects to a table using a TableViewer. I used ArrayContentProvider and then TableViewer.setInput to map my array.

What I need to do now is change the background color of several rows in the table in order to visually highlight them. Each row corresponds to an object in the array. But I can't figure out how to obtain a reference to a row (ie, its TableItem) given an object of the mapped type. I can obtain an object given a row with TableItem.getData() but what I really want to do is get the TableItem given its data.

Était-ce utile?

La solution

You can just call protected method TableViewer.doFindItem using reflection.

Or better, make your label provider implement ITableColorProvider and the TableViewer will use the correct color automatically.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top