Dynamic creation of popup submenus [message #265161] |
Mon, 02 August 2004 22:45  |
Eclipse User |
|
|
|
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 #265281 is a reply to message #265271] |
Tue, 03 August 2004 15:49  |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
> 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
|
|
|
Powered by
FUDForum. Page generated in 0.04072 seconds