Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » popup menu: dynamic objectContribution(RFC: provide dynamic objectContribution as dynamic menuContribution)
popup menu: dynamic objectContribution [message #511184] Sat, 30 January 2010 20:16 Go to next message
zos rothko is currently offline zos rothkoFriend
Messages: 4
Registered: January 2010
Junior Member
Hi

I need to have a dynamic popup menu objectContribution like exits a dynamic menuContribution. Can someone explain me if this is possible in M3.5 and how to do it??

Otherwise, I would suggest to make an RFE for this kind of dynamic menu that needs to know on which object there were activated...

Thanks for you help

zosrothko
Re: popup menu: dynamic objectContribution [message #512009 is a reply to message #511184] Wed, 03 February 2010 16:07 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

There is no way to use a pulldown action in an object contribution.

But you can use menuContribution to supply a dynamic
org.eclipse.ui.actions.CompoundContributionItem to a popup. You can use
visibleWhen to restrict it similar to objectClass.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: popup menu: dynamic objectContribution [message #512077 is a reply to message #512009] Wed, 03 February 2010 20:04 Go to previous messageGo to next message
zos rothko is currently offline zos rothkoFriend
Messages: 4
Registered: January 2010
Junior Member
My popup dynamic contributionItem values are depending on the value of the initially selection object, and since this object is never passed to the menuContribution, I can't implement the dynamic items of the popup...

for example, having 2 objects A & B in a TreeViewer, the popup submenu should display A1, A2 when A is selected and B1, B2, B3, B4 when B is selected...

Did I misunderstand something from your answer??

TIA for your reply.

zosrothko
Re: popup menu: dynamic objectContribution [message #512567 is a reply to message #512077] Fri, 05 February 2010 14:09 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

While not elegant, you can implement
org.eclipse.ui.menus.IWorkbenchContribution which will give you a
service locator. If you want to know what the selection for your popup,
is, use:

evalService = (IEvaluationService) locator
.getService(IEvaluationService.class);
Object selection = evalService.getCurrentState()
.getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: popup menu: dynamic objectContribution [message #512749 is a reply to message #512567] Sun, 07 February 2010 09:35 Go to previous messageGo to next message
zos rothko is currently offline zos rothkoFriend
Messages: 4
Registered: January 2010
Junior Member
Hi Paul

Thank for your help.. it works as expected...

Anyway, I am wondering why do you consider this solution as non elegant?? Also, I am wondering why the selected object is not forwarded to menuContribution in all case??
Is this something missing from the spec, or another reason?

zos
Re: popup menu: dynamic objectContribution [message #513235 is a reply to message #512749] Tue, 09 February 2010 13:15 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

zosrothko@orange.fr wrote:
> Anyway, I am wondering why do you consider this solution as non
> elegant??

It's technically correct, just a little verbose, that's all.

> Also, I am wondering why the selected object is not forwarded
> to menuContribution in all case??
> Is this something missing from the spec, or another reason?

Because the menu contribution is normally a View component (not model or
control), and most view components don't have code associated with them
at all. But they can reach out to the "model" or in your case
application state.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Previous Topic:worspace indication
Next Topic:Editor association seems broken in Helios
Goto Forum:
  


Current Time: Thu Apr 25 01:38:18 GMT 2024

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

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

Back to the top