Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » adding items dynamically to toolbar and menubar
adding items dynamically to toolbar and menubar [message #292225] Sun, 02 October 2005 20:10 Go to next message
Eclipse UserFriend
Originally posted by: ahsanfz.hotmail.com

Hye,

I want to add actions (actually menuItems) dynamically to toolbar and menubar in my actionSet. This is how I define the menu and action in actionSet tags:-

        <menu
		label="Dynamic Menus"
		id="dynamic menu"
		path="my-main-menu/additions">
                <separator name="add-here"/>
	</menu>

	   <action id="dropDown.emptyItem"
		   toolbarPath="my-toolbargroup"
		    menubarPath="my-main-menu/dynamic menu/add-here"
		   label="Component Inactive"
		   tooltip="Component is not running"
		   style="pulldown"
		   icon="icon.png"		     class="a-class-implementing-IWorkbenchWindowPulldownDelegate">
	   </action>



And this is how I define the getMenu() fucntion of the IWorkbenchWindowPulldownDelegate

public Menu getMenu(Control parent)
	{
		// TODO Auto-generated method stub
		Menu fMenu = null;
		if (menuManager == null) {
			menuManager = new MenuManager();

			fMenu = menuManager.createContextMenu(parent);
			
			menuManager.removeAll();

                        //The dynamic items to add.
			Iterator i = items.keySet().iterator();
			for (;i.hasNext();) 
			{
				String name = (String)i.next();
				Action action = new Action();
				menuManager.add(action);
			}
		} 
		else 
		{
			fMenu = menuManager.getMenu();
		}
		return fMenu;
	}





Now the good news is that it works perfectly well for the toolbar, I get a dropdown button with a list of my actions and the correct action happens when I press it.

The problem is that I can't get my menu (the Dynamic Menus) to reflect this drop down list. Any body know what I am doing wrong.

Regards
Re: adding items dynamically to toolbar and menubar [message #292312 is a reply to message #292225] Tue, 04 October 2005 13:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: douglas.pollock.magma.ca

I'm not sure what's going wrong here, but I suggest a couple of things.


Elemental wrote:
> class="a-class-implementing-IWorkbenchWindowPulldownDelegate "> </action>

What about implementing IWorkbenchWindowPulldownDelegate2?


> menuManager.removeAll();
>
> //The dynamic items to add.
> Iterator i = items.keySet().iterator();
> for (;i.hasNext();)
> {
> String name = (String)i.next();
> Action action = new Action();
> menuManager.add(action);
> }

menuManager.update(false);




d.
Re: adding items dynamically to toolbar and menubar [message #292516 is a reply to message #292312] Thu, 06 October 2005 19:44 Go to previous message
Eclipse UserFriend
Originally posted by: ahsanfz.hotmail.com

thanx for your reply,

I found a gr8 soln that works. i.e Don't bother with it yet. Looking onto other bigger things in my project than cosmetics r8 now. Maybe I'll come abck to these issues later.

THanks again
Previous Topic:How to generate test report while running Eclipse plugin tests.
Next Topic:Bundle activation error/problem--Eclipse 3.1.0
Goto Forum:
  


Current Time: Sun May 04 15:57:16 EDT 2025

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

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

Back to the top