我正在使用目标平台 3.7 编写 RCP 应用程序。我喜欢仅在特定视图处于活动状态时才启用 menuItem,否则应将其禁用。我通过如下 plugin.xml 中所示的表达式尝试它,但 menuItem 始终处于活动状态。
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="pgui.handler.SaveHandler"
id="pgui.rcp.command.save"
name="Save">
</command>
</extension>
<extension
point="org.eclipse.ui.views">
<view
allowMultiple="true"
class="pgui.view.LogView"
id="pgui.view.LogView"
name="logview"
restorable="true">
</view>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:org.eclipse.ui.main.menu">
<menu
id="fileMenu"
label="File">
<command
commandId="pgui.rcp.command.save"
label="Save"
style="push"
tooltip="Save the active log file.">
</command>
</menu>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="pgui.rcp.command.save">
<activeWhen>
<with
variable="activePart">
<instanceof
value="pgui.view.LogView">
</instanceof>
</with>
</activeWhen>
</handler>
</extension>