I'm using org.eclipse.jface.viewers.TableViewer in one of my projects. I need to export the visible rows of my table in a CSV file. Saying visible, I mean the rows a user can see after the table has been filtered. But I can't understand how I can get the rows, I didn't find any appropriate method. Does anybody know?
CodePudding user response:
I don't think there is a direct method.
One way is to get the TableItem
array of the underlying Table
that TableViewer
uses. The table will only contain the visible items. The data in the table item is the element from your content provider:
TableItem [] items = viewer.getTable().getItems();
for (final TableItem item : items) {
Object data = item.getData();
// TODO data is the element from the content provider
}