I am implementing a plug-in in eclipse, which reads a set of values from a database and displays it in a TableViewer
inside a ViewPart
. The TableViewer uses an ArrayContentProvider
as shown
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
...
viewer.setContentProvider(new ArrayContentProvider());
I also have a handler which has access to the TableViewer
instance for importing data from an XML file. When the importer imports data, I create a ModelProvider
instance which generates a list of objects whose data is displayed by TableViewer
.
The handler then sets the input:
viewer.setInput(new ModelProvider(Data.getDocs()).getTableRows())
;
When I test this application, with this ViewPart
already open (and the TableViewer
being empty) and invoke the handler for importing data, the data is imported succesfully but the TableViewer
shows only a single row and the scroll bar. Only when I drag the ViewPart
to some other location on the Workbench, then all the rows are shown.
I have even tried:
viewer.setInput(new ModelProvider(Data.getDocs()).getTableRows());
viewer.refresh();
and
viewer.setInput(null);
viewer.setInput(new ModelProvider(Data.getDocs()).getTableRows());
viewer.refresh();
but nothing works. How do I make all the rows display as soon as new input is set?