I am trying configure visibility of a command within the context menu using \'visibleWhen\' expression within a menuContribution. What I am trying to do is make the command vis
@blissfool, I would suggest a slight restructuring. You can put your basic test (which is correct) in a org.eclipse.core.expressions.definitions
block:
<extension point="org.eclipse.core.expressions.definitions">
<definition id="org.eclipse.example.testExtension">
<adapt type="org.eclipse.core.resources.IResource">
<or>
<test property="org.eclipse.core.resources.extension"
value="ext1">
</test>
<test property="org.eclipse.core.resources.extension"
value="ext2">
</test>
</or>
</adapt>
</definition>
</extension>
Then in your visibleWhen move the activeEditorInput
test up to the top:
<visibleWhen>
<or>
<with variable="selection">
<iterate ifEmtpy="false">
<reference definitionId="org.eclipse.example.testExtension"/>
</iterate>
</with>
<with variable="activeEditorInput">
<reference definitionId="org.eclipse.example.testExtension"/>
</with>
</or>
</visibleWhen>
You could implement your own PropertyTester.
I was able to get it done with a with
variable that I came across. Using the same code example above:
<or>
block within the <iterate>
block<adapt>
block in the new <or>
blockwith
variable called activeEditorInput
Here is the new code example.
<iterate ifEmpty="false" operator="or">
<or>
<adapt type="org.eclipse.core.resources.IResource">
<or>
...test extensions
</or>
</adapt>
<with variable="activeEditorInput">
<adapt type="org.eclipse.core.resources.IResource">
<or>
...test extensions
</or>
</adapt>
</with>
</or>
</iterate>