Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Dynamic Submenus of Context Menus (2)
Dynamic Submenus of Context Menus (2) [message #303112] Tue, 09 May 2006 06:12 Go to next message
Eclipse UserFriend
Originally posted by: richcar.us.ibm.com

Hi,

I copied my 5/1 posting below to see if anyone would like to take a shot
at it. It's similar to today's posting by Adrian, "Adding a submenu
File -> New."

Thanks,
Rich
--------------------------- 5/1 Posting ----------------------------

Using my own MenuManager and Actions, I call
MenuManager.createContextMenu() to create a dynamic context menu for a
TableViewer object. Now, I want to add a submenu to that context menu,
but all attempts to do so fail. Any thoughts on the subject are
appreciated.

Here's the general outline of my Eclipse 3.1.1, Windows XP, Java 1.5 code:

// Create top-level menu manager.
MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(new IMenuListener()
{
public void menuAboutToShow(IMenuManager mgr)
{
mgr.add(action1);
mgr.add(action2);
MenuManager subMgr = new MenuManager("SubMenu");
subMgr.setRemoveAllWhenShown(true);
subMgr.addMenuListener(new IMenuListener()
{
public void menuAboutToShow(IMenuManager mgr)
{mgr.add(subAction1);}
});
mgr.add(subMgr);
}
});

// Create viewer's top-level context menu.
Menu menu = menuMgr.createContextMenu(_viewer.getControl());
_viewer.getControl().setMenu(menu);

Thanks,
Rich
Re: Dynamic Submenus of Context Menus (2) [message #303186 is a reply to message #303112] Wed, 10 May 2006 07:34 Go to previous messageGo to next message
Eclipse UserFriend
It's only the top level menu that really needs the listener.

MenuManager subMgr = new MenuManager("SubMenu");
subMgr.add(subAction1);
mgr.add(subMgr);

Later,
PW
Re: Dynamic Submenus of Context Menus (2) [message #303240 is a reply to message #303186] Wed, 10 May 2006 12:10 Go to previous message
Eclipse UserFriend
Originally posted by: richcar.us.ibm.com

Thanks Paul! I guess the submenu listener messed up the works. Things
seems to be working now.

Rich


Paul Webster wrote:
> It's only the top level menu that really needs the listener.
>
> MenuManager subMgr = new MenuManager("SubMenu");
> subMgr.add(subAction1);
> mgr.add(subMgr);
>
> Later,
> PW
Previous Topic:A cycle was detected in the build path of project Error
Next Topic:How to find a plugin's physical location
Goto Forum:
  


Current Time: Mon Jun 02 18:08:45 EDT 2025

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

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

Back to the top