Cannot get the active selection from CompoundContributionItem [message #1733080] |
Tue, 24 May 2016 09:26 |
Michael Ritzert 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.02407 seconds