bec*_*cks 6 eclipse eclipse-plugin popupmenu eclipse-rcp menuitem
我已经创建了一个带有一个菜单项的弹出菜单,我想只在右键单击某个类类型的树项时启用它,否则禁用它.
我怎样才能做到这一点?
您可以添加使用activeWhen的处理程序,并将其与该菜单的命令ID相关联.
这是一个处理程序,只有在当前选择不为空时才使命令处于活动状态,并且选择是一个可以适应Widget类型对象的项目:
<extension point="org.eclipse.ui.handlers">
<handler class="com.myproject.handlers.ExportWidgetHandler"
commandId="com.myproject.commands.exportWidget">
<activeWhen>
<with variable="selection">
<iterate ifEmpty="false" operator="and">
<adapt type="com.myproject.objects.Widget"/>
</iterate>
</with>
</activeWhen>
</handler>
</extension>
Run Code Online (Sandbox Code Playgroud)