Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Multiple SelectionProvider in single ViewPart?(Multiple SelectionProvider inside a single ViewPart or changing the SelectionProvider during runtime)
icon5.gif  Multiple SelectionProvider in single ViewPart? [message #908356] Wed, 05 September 2012 04:19 Go to next message
Eclipse UserFriend
Hi,

I was wondering if it is possible to have multiple SelectionProvider inside a single ViewPart or if the SelectionProvider can be changed during runtime.

The Background:
I have written several Controls that implement a SelectionProvider. In a ViewPart I try to regsiter the Composites as SelectionProvider but only the latest Control set is registered as SelectionProvider (Listeners only react on Events by the latest added Provider). The code looks like this:

for (NavigationItem item : items) {
  Control ctl = item.getControl();
  if (ctl != null && ctl instanceof ISelectionProvider) {		
    getSite().setSelectionProvider((ISelectionProvider) ctl);
  }
}


In fact I was not sure I can have multiple SelectionProviders I had the hope I can change the SelectionProvider dynamically during runtime, when something changes.
Although the code for changing the SelectionProvider is executed, the Listeners still react on the last Selections provided by the last Control from the example above:

if (widget instanceof NavigationItem) {
  NavigationItem item = (NavigationItem) widget;
  Control ctl = item.getControl();
  getSite().setSelectionProvider((ISelectionProvider) ctl);
}


Any idea how the problem can be solved using the SelectionService of Eclipse?

Bjoern
Re: Multiple SelectionProvider in single ViewPart? [message #908367 is a reply to message #908356] Wed, 05 September 2012 04:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Bjoern,
you need a selectionProvider that is able to provide all selections performed in your viewpart. You can do this by registering a special MultiSelectionProvider as selectionListener to all the controls that provide selections. The MultiSelectionProvider can then provide each selection to the site. You may want to have a look at org.eclipse.ui.part.MultiPageSelectionProvider.

Regards,
Thorsten

[Updated on: Wed, 05 September 2012 04:53] by Moderator

Re: Multiple SelectionProvider in single ViewPart? [message #908485 is a reply to message #908367] Wed, 05 September 2012 09:14 Go to previous message
Eclipse UserFriend
Thank you for the quick response. So am I right, that there can be only one SelectionProvider per Viewpart.

The hint with the MultiPageSelectionProvider is helpful.
Previous Topic:RCP product export customized ANT script for multiplatform
Next Topic:StyleRange uppercase
Goto Forum:
  


Current Time: Mon Apr 21 11:53:57 EDT 2025

Powered by FUDForum. Page generated in 0.06035 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top