[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] How to create Menus with a give ActionSet id


Can someone show me some code that would create a pop up menu with a given ActionSet id string.

Ultimately I need a menu that is equivilent to the "contextMenu" below:

contextMenu = new Menu(window.getShell(),SWT.POP_UP);
MenuItem subItem = new MenuItem(contextMenu,SWT.CASCADE);
userMenu = new Menu(subItem);
subItem.setMenu(userMenu);
MenuItem item = new MenuItem(userMenu,SWT.PUSH);
item.setText("Menu Test");

But I need to populate it via an ActionSet so I'm doing something like:

ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry();
IActionSetDescriptor actionSetDesc = reg.findActionSet(desc.getActionSet());
PluginActionSet set = (PluginActionSet)actionSetDesc.createActionSet();
SubActionBars bars = new ActionSetActionBars(((WorkbenchWindow)window).getActionBars(), actionSetDesc.getId());
set.init(window, bars);
IAction actions[] = set.getPluginActions();
                       
MenuManager mng = new MenuManager();
for (int i = 0; i < actions.length; i++) {
        mng.add(actions[i]);
}                        
contextMenu = mng.createContextMenu(window.getShell());

But there is a lot of dependency in org.eclipse.ui.internal classes.  I'm assuming that isn't safe.  There has to be an easier/safer/better way.  Maybe I should reinvent the actionSet extension point for my plugin??

-m@