我有一个由此扩展点定义的菜单:org.eclipse.ui.menus
。
它的位置 URI 是 popup:org.eclipse.ui.popup.any
,这意味着它也会从不同的资源管理器 View 和编辑器 View 中显示(右键单击代码上的某处)。
我希望此菜单仅在某些扩展中显示。我使用了 here 中格雷格的答案它非常适合浏览器 View 。 如何为编辑器 View 也执行相同的过滤器?
我想以某种方式更改它,如果有人从编辑器 View (和资源管理器 View )右键单击某个文件,则仅当该文件是“*.myextension”文件时才会显示该文件。
谢谢。
尝试组合过滤器 - 根据 greg 的回答,这是我的代码,但无法按预期工作。
<visibleWhen
checkEnabled="false">
<iterate
ifEmpty="false"
operator="or">
<or>
<test
property="org.eclipse.core.resources.name"
value="*.myextension">
</test>
</or>
<or>
<with variable="activeEditorInput">
<adapt type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.name"
value="*.myextension">
</test>
</adapt>
</with>
</or>
</iterate>
</visibleWhen>
最佳答案
对于编辑器,您可以使用以下方法测试“Activity 编辑器输入”:
<visibleWhen
checkEnabled="false">
<with variable="activeEditorInput">
<adapt type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.name"
value="*.myextension">
</test>
</adapt>
</with>
</visibleWhen>
这将获取 Activity 编辑器输入,获取正在编辑的 IResource
并对其进行测试。
组合可能会给出:
<visibleWhen
checkEnabled="false">
<or>
<with variable="activeEditorInput">
<adapt type="org.eclipse.core.resources.IResource">
<test
property="org.eclipse.core.resources.name"
value="*.myextension">
</test>
</adapt>
</with>
<iterate
ifEmpty="false"
operator="or">
<test
property="org.eclipse.core.resources.name"
value="*.myextension">
</test>
</iterate>
</or>
</visibleWhen>
关于java - org.eclipse.ui.menus 的名称过滤器 - 也适用于编辑器 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41240806/