In my RCP program, I added a menu “Demo” in the workbenchwindow and a seperator “addition” below “Demo”. The code is below,
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
private ExampleAction exampleAction;
@Override
protected void makeActions(IWorkbenchWindow window) {
// TODO Auto-generated method stub
super.makeActions(window);
exampleAction = new ExampleAction(window);
}
@Override
protected void fillMenuBar(IMenuManager menuBar) {
// TODO Auto-generated method stub
super.fillMenuBar(menuBar);
MenuManager demoMenu = new MenuManager("&Demo", "demo");
demoMenu.add(exampleAction);
demoMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menuBar.add(demoMenu);
}
..............
}
Now I want to contribute a submenu to the position “demo/additions”. I declare an actionSet extension point like below,
<extension
point="org.eclipse.ui.actionSets">
<actionSet
id="RCP-View-Example.actionSet"
label="actionSet">
<menu
id="RCP-View-Example.menu"
label="ActionSetMenu"
path="demo/additions">
<groupMarker
name="menuItem">
</groupMarker>
</menu>
<action
class="Action1"
id="RCP-View-Example.action"
label="Action"
menubarPath="RCP-View-Example.menu/menuItem"
style="push"
toolbarPath="main/additions">
</action>
</actionSet>
</extension>
<extension
point="org.eclipse.ui.actionSetPartAssociations">
<actionSetPartAssociation
targetID="RCP-View-Example.actionSet">
<part
id="my.view">
</part>
</actionSetPartAssociation>
</extension>
I don’t see the menu is contributed and shown under “Demo” menu.
I modify the menu path from “path=”demo/additions” to “path=”org.eclipse.ui.main.menu/demo/additions”, I still don’t see it.
Could anyone help to see what’s wrong in my program?
I modify the menu path from path=”demo/additions to path=”additions”. I see the menu after “Demo” when the view is opened. But, after the view specified in actionSetPartAssociations extension point is closed, the menu is still there.
I expect the menu disappears when the view associated with it is closed.
What’s wrong in my program?
I think this note from the documentation might fit here:
So the problem is probably in your sub-menu path=”demo/additions”, which should include the complete path to the sub-menu. If you already have that Sub-Menu you can try Alt+Shift +F2 on an action inside that menu to find the Id for that menu and work from there.
However if you are just starting with Menus, I’d recommend you to use the Command Framework right away. Even if you are using an already established Rich Client you can easily fit commands in wherever you like and the actionSets ExtensionPoint is deprecated in Eclipse Juno and newer. A good Commands tutorial can be found here.