I have a TableViewer
in my application that has the following features:
Now I want to select the new line by default, and I tried many commands like tableViewer.getTable().select(index);
and as it is now:
public void selectAdded(int id) {
tableViewer.getTable().setSelection(id);
}
This picture shows what is the problem:
The upper one shows as it works now with this code. The row below shows how it looks when I click a row. The problem is, the buttons don't get enabled, and I have two read-only text fields that remains blank instead of showing the information I need. But when I click, everything works normally.
What should I do to achive that selectAdded(int id)
acts like a click? The solution should be multi-platform (Mac/Windows), but at least on Mac.
Don't use the Table
selection methods which using TableViewer
. Instead use
ISelection selection = new StructuredSelection(model object);
tableViewer.setSelection(selection);
'model object' is the model object for the row you want to select (as returned by your content provider).