Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Dynamically expanding sub-menu on right click(or similar solutions to my problem :))
Dynamically expanding sub-menu on right click [message #541348] Sun, 20 June 2010 11:14 Go to next message
Martin R is currently offline Martin RFriend
Messages: 9
Registered: January 2010
Junior Member
Hi everyone!
First of all, let me explain what I try to do, then how I think it could be done and what my problems are.

So, what I want to do is have a possibility to group files for later use. So we might have file a and b in group 1, file c, f and h in group 2 etc. There is no fixed number of groups, so I need to be able to expand the number of groups dynamically

Now I imagined I could have a sub-menu on the right click in the project explorer with initially just 2 entries "1" and "2" for the group number. The user can then start to add files to those groups, but when group 2 has more than 0 members, a third entry appears in the menu and so on.

So, first of all, how would I go about adding such a sub-menu to the right-click? I know can add an entry by extending org.eclipse.ui.menus and adding a menucontribution to URI popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu , but then I am stumped.
Another problem I see is adding menu items during runtime. Is that possible and if yes, how would it be done?

Thanks in advance for any help you can offer,
Martin
Re: Dynamically expanding sub-menu on right click [message #541520 is a reply to message #541348] Mon, 21 June 2010 13:08 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

first place a submenu in the menu you want, and then you would use
<dynamic/> and provide a subclass of CompoundContributionItem. Then you
can return multiple IContributionItems (Separator for separators and
CommandContributionItems to access different files).

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: Dynamically expanding sub-menu on right click [message #541927 is a reply to message #541520] Wed, 23 June 2010 09:01 Go to previous messageGo to next message
Martin R is currently offline Martin RFriend
Messages: 9
Registered: January 2010
Junior Member
Thanks for the reply!
Paul Webster wrote on Mon, 21 June 2010 09:08
first place a submenu in the menu you want

Well, that is kinda one of my problems Smile Could you please elaborate on how I would do that a little?
Re: Dynamically expanding sub-menu on right click [message #541970 is a reply to message #541927] Wed, 23 June 2010 12:26 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Martin R wrote:
> Thanks for the reply!
> Paul Webster wrote on Mon, 21 June 2010 09:08
>> first place a submenu in the menu you want
>
> Well, that is kinda one of my problems :) Could you please elaborate on
> how I would do that a little?

you add a menu using the <menu/> element in a menuContribution. You
need to get the locationURI correct, but I thought that was what you
provided in your first post:
popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu

Use the org.eclipse.ui.menus extension point ... please read the
Extension Point Description

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: Dynamically expanding sub-menu on right click [message #542059 is a reply to message #541348] Wed, 23 June 2010 16:35 Go to previous message
Martin R is currently offline Martin RFriend
Messages: 9
Registered: January 2010
Junior Member
Okay, I was able to do what I had in mind using your tips.

Thanks a lot!
Previous Topic:RCP applications without org.eclipse.ui.workbench
Next Topic:Problem updating to final helios release from RC6
Goto Forum:
  


Current Time: Tue Apr 16 06:44:11 GMT 2024

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

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

Back to the top