Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 08:19 Go to next message
Bjoern Berg is currently offline Bjoern BergFriend
Messages: 47
Registered: November 2009
Location: Essen
Member
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 08:52 Go to previous messageGo to next message
Thorsten Schlathölter is currently offline Thorsten SchlathölterFriend
Messages: 312
Registered: February 2012
Location: Düsseldorf
Senior Member
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 08:53]

Report message to a moderator

Re: Multiple SelectionProvider in single ViewPart? [message #908485 is a reply to message #908367] Wed, 05 September 2012 13:14 Go to previous message
Bjoern Berg is currently offline Bjoern BergFriend
Messages: 47
Registered: November 2009
Location: Essen
Member
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: Thu Oct 03 17:26:27 GMT 2024

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

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

Back to the top