Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set selection in a TableViewer to a specified index?

I have a TableViewer in a view of my RCP application. The TableViewer has a List of objects as input. Is it possible to make a selection for a particular object using the index of the object in the List that I set as input to the TableViewer? For example, I want to set a default selection to the third object every time I open my application. How do I set that selection?

like image 942
Rajath Avatar asked Oct 27 '25 10:10

Rajath


1 Answers

Found the answer!

int selection = 5; //row we want to select
tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(selection)),true);

Thanks to http://andy.ekiwi.de/?p=1040.

like image 195
Rajath Avatar answered Oct 28 '25 22:10

Rajath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!