QueNuevo
QueNuevo

Reputation: 105

Eclipse RCP: How to listen to CheckboxTableViewer selection in other view

I have an Eclipse RCP with a view whose Control is a CheckboxTableViewer.

I'd like to use the WorkbenchPage's SelectionService (for reasons of loose coupling) to react to check/uncheck actions within the view in an editor.

So I do getSite().setSelectionProvider(myTableViewer); in the view's createPartControl() method.

Also, I create a listener field in the editor:

private ISelectionListener mylistener = new ISelectionListener() {
    public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) {
        System.out.println(((IStructuredSelection) selection).size());
    }
};

Unfortunately, I only get the number of rows that are selected printed out in the console, not the number of checked elements. I'm trying to pass myTableViewer.getCheckedElements() to the SelectionProvider somehow, but cannot find an access point :(.

Upvotes: 1

Views: 187

Answers (1)

greg-449
greg-449

Reputation: 111142

You could write your own implementation of ISelectionProvider which returns the checked elements instead of using the default provider implemented by TableViewer which returns the selected elements.

Upvotes: 2

Related Questions