I'm trying to automatically select the first item in a filtered table.
I'm essentially doing the following:
table = new TableViewer(...);
table.addFilter(filter);
table.setContentProvider(contentProvider);
table.setInput(input);
first = table.getElementAt(0);
table.setSelection(new StructuredSelection(first));
The surprising thing is that (depending on the filter) I can get an element that is filtered out from getElementAt(0)
. The result is that ultimately, no item will be selected.
I have tried calling table.refresh()
before getting the element with the same results.
If I call getElementAt(0)
at a later point, I do indeed get the correct first element (that is not filtered out).
How can I make getElementAt
respect the filtering immediately?