1

I'm using Viewer Framework in my Eclipse RCP Application, i was stuck at a situation wherein i need to get(know which row has been selected in the UI) the selected row from a TableViewer. In UI user can be able to select a row.Below is my Tableviewer declaration

TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION
    | SWT.HIDE_SELECTION);

i'm able to select a row in the sense when a user clicks on a particular row it gets highlighted, i wanted to know if which row has been selected by the user and fetch exactly the row details? How can i achieve this?

srk
  • 4,857
  • 12
  • 65
  • 109

1 Answers1

11

In JFace you can add a selectionListener to your TableViewer. Instead of the selected row you'll get notified about the selected object. Heres the code:

this.viewer.addSelectionChangedListener(new ISelectionChangedListener() {
    public void selectionChanged(final SelectionChangedEvent event) {
        IStructuredSelection selection = (IStructuredSelection)event.getSelection();
    }
});
Tom Seidel
  • 9,525
  • 1
  • 26
  • 38