Reputation: 116
I'm defining my own perspective using:
<extension point="org.eclipse.ui.perspectives">
In my implementation of IPerspectiveFactory::createInitialLayout() I want to use IPageLayout.addActionSet() which points to a new actionset. But actionsets are deprecated; what is the recommended alternative?
The reason I want to add a new actionset is I want the Run menu to display debug actions, but not run actions. If I use layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET) I get both. So I figured I'd define my own actionset with just the debug variants in. But I'd like to use a non deprecated API. What's the recom
Upvotes: 1
Views: 92
Reputation: 111216
The alternative is to use the org.eclipse.ui.menus
extension point for menu items. However you can't add this to a perspective, instead you have to use the visibleWhen
element to control when the menu is shown.
For example this is how the PDE plugin adds a menu to the Navigate menu when the plugin development perspective is active or the search action set is in use:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:navigate?after=open.ext2">
<separator
name="org.eclipse.pde.ui.openPluginArtifactSeparator"
visible="true">
</separator>
<command
commandId="org.eclipse.pde.ui.openPluginArtifact"
icon="$nl$/icons/obj16/open_artifact_obj.gif"
label="%pluginsearch.action.menu.name">
<visibleWhen>
<or>
<with
variable="activeWorkbenchWindow.currentPerspective">
<equals
value="org.eclipse.pde.ui.PDEPerspective">
</equals>
</with>
<with
variable="activeContexts">
<iterate
operator="or">
<equals
value="org.eclipse.pde.ui.SearchActionSet">
</equals>
</iterate>
</with>
</or>
</visibleWhen>
</command>
</menuContribution>
Although action sets are deprecated they are not going to be removed for a long time as a lot of Eclipse code still uses them, so you may just want to stick with them.
Upvotes: 2