我有一个 Eclipse 插件,我在其中使用 actionSets 创建了菜单。
<extension point="org.eclipse.ui.actionSets">
<actionSet description="My Sample"
id="MySample.actionSet"
label="My Sample"
visible="true">
<menu
id="mysample.actionset.menu1"
label="My Sample">
<groupMarker
name="mysample.groupCreatesimilar">
</groupMarker>
</menu>
<action
class="org.mysample.actions.create.MyCreateCodeAction"
definitionId="MySample.myCreateCode.command"
id="MySample.myCreateCode.command"
label="Create Sample Code"
menubarPath="mysample.actionset.menu1/mysample.groupMarker2">
</action>
</actionSet>
</extension>
我需要根据偏好值启用或禁用其中一个菜单。当我使用如下命令时,我能够实现这一点。但我不应该这样做。我必须让它使用上面的代码(actionSet)。请建议如何做到这一点。
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="my label"
id="myMenu.menu1">
<command
commandId="MySample.myCreateCode.command"
mnemonic="S"
id="MySample.myCreateCode.command">
</command>
</menu>
</menuContribution>
</extension>