adding items dynamically to toolbar and menubar [message #292225] |
Sun, 02 October 2005 20:10  |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05328 seconds