Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Cannot get the active selection from CompoundContributionItem
icon5.gif  Cannot get the active selection from CompoundContributionItem [message #1733080] Tue, 24 May 2016 09:26 Go to next message
Michael Ritzert is currently offline Michael RitzertFriend
Messages: 3
Registered: April 2016
Junior Member
Hi all,

I'm trying to implement a dynamic popup menu. I subclassed CompoundContributionItem, added the extension definition for org.eclipse.ui.menus/menuContribution, and find that my getContributionItems() is called and works as it should. However, I cannot access the active selection to create really dynamic entries based on what is clicked. From googling, it seems that
ISelection sel = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();

is the generic solution everybody uses. However when I try this, se is always null. (I also found another version that doesn't include the getActivePage(), but that doesn't change anything.)

The weirdest thing is that I'm 99% convinced that this was working when I started the implementation and was still debugging things. Then I had a debug output that printed the content of the selection and this was OK. I found that my EditPart didn't yet provide the information I needed, so I committed an empty dummy version of the getContributionItems() function -- unfortunately without the debug prints -- amended the EditPart, and now can no longer get back to the working state.

Michael
Re: Cannot get the active selection from CompoundContributionItem [message #1733196 is a reply to message #1733080] Wed, 25 May 2016 03:30 Go to previous message
Michael Ritzert is currently offline Michael RitzertFriend
Messages: 3
Registered: April 2016
Junior Member
I found what's different: In my first test, I obviously clicked on a view in "edit" mode. There, everything is fine. In "run" mode, a different shell is used, and it fails. Seems I have to bring this up with the developers of the framework.

Michael
Previous Topic:Minimal editor based on bespoke IDocument
Next Topic:How to Customize Search Results View
Goto Forum:
  


Current Time: Thu Apr 25 19:30:23 GMT 2024

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

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

Back to the top