Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Dynamic creation of popup submenus
Dynamic creation of popup submenus [message #265161] Mon, 02 August 2004 22:45 Go to next message
Eclipse UserFriend
I'm trying to add a submenu to the popup menu that appears when I right
click on a file in the Package Explorer. However, the contents of the
submenu must be generated at runtime, and should look like:

profile-spec.xml ---> Edit ---> Foo, 1.0, Me
|-> Bar, 1.0, Me
\-> Baz, 0.1, Me ---> Identity
|-> CMP Fields

The contents of the first submenu (Foo, Bar & Baz) are determined from
the file right-clicked on and may contain 0 or more entries. Each of
these is a submenu containing two actions, "Identity" and "CMP Fields".

I can easily add an "Edit" submenu via plugin.xml, but can't find a way
to generate its contents at runtime based on the file selected. Is this
possible to do? And if so, does anyone know of an example that
demonstrates this?

I'm using Eclipse 3.0.

Thanks,
Cath
Re: Dynamic creation of popup submenus [message #265271 is a reply to message #265161] Tue, 03 August 2004 14:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dfs.dsf.com

I'm trying to do the same thing, still haven't found a way to do it myself.
The closest thing I can find is in IMenuManager or IContributionManager,
there is an add(IAction) the only problem is that I don't know how to get to
the menu manager of the menu that I want.
Re: Dynamic creation of popup submenus [message #265281 is a reply to message #265271] Tue, 03 August 2004 15:49 Go to previous message
Eclipse UserFriend
Originally posted by: news.vadalus.com

Archimedes Trajano wrote:
> I'm trying to do the same thing, still haven't found a way to do it myself.
> The closest thing I can find is in IMenuManager or IContributionManager,
> there is an add(IAction) the only problem is that I don't know how to get to
> the menu manager of the menu that I want.
>
>
fill the dynamic menu contents in the fillContextMenu method

menuMgr.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager mgr) {
fillContextMenu(mgr);
}
});
Re: Dynamic creation of popup submenus [message #265282 is a reply to message #265161] Tue, 03 August 2004 15:48 Go to previous message
Eclipse UserFriend
> I can easily add an "Edit" submenu via plugin.xml, but can't find a way
> to generate its contents at runtime based on the file selected. Is this
> possible to do? And if so, does anyone know of an example that
> demonstrates this?

It appears to be possible. From what I've read, the method to do so is to
contribute an org.eclipse.ui.popupMenus extension where the action has style
"pulldown", and then have the class indicated implement both
IObjectActionDelegate and IMenuCreator. However, over the last couple days
I've been trying to do so, and it hasn't worked :)

Per bug 11114, it appears that this is the correct way to do so, and in
perusing at the source, it looks like that's how the Run and Debug submenus
are created in the resource navigator. Even copying and pasting the
relevant XML from the org.eclipse.debug.ui plugin.xml into a test plug-in
(not changing the class or anything) hasn't managed to work for me yet,
though (I get a normal "push" style menu item instead).

So, it appears that it's possible, but I haven't managed to get it to work
yet.

- Adam
Previous Topic:How to Export a Plugging?
Next Topic:Questions about help system search pre-built indices and user optionally installing components
Goto Forum:
  


Current Time: Wed May 14 07:47:27 EDT 2025

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

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

Back to the top