I have added a menu item to the right click Project Explorer menu but cannot get the visibleWhen to work. I have tried various different core expressions and regardless what I put in there the menu does not show up (it does show up if I remove the entire visibleWhen section). I want it to show up if the selected project has my custom nature on it.
First attempt:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer?after=additions">
<command
commandId="myCommand"
label="Test">
<visibleWhen checkEnabled="false">
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="myProjectNature"/>
</adapt>
</visibleWhen>
</command>
</menuContribution>
</extension>
Then I tried changing the adapt type to IResource - still no luck. I also tried using the standard JavaCore.NATURE_ID. Next:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer?after=additions">
<command
commandId="myCommand"
label="Test">
<visibleWhen>
<iterate operator="and">
<test property="org.eclipse.core.resources.projectNature" value="myProjectNature"/>
</iterate>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer?after=additions">
<command
commandId="myCommand"
label="Test">
<visibleWhen>
<with variable="selection">
<iterate operator="and" ifEmpty="false">
<test property="org.eclipse.core.resources.projectNature" value="myProjectNature"/>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
Then I tried this one both with and without the iterate:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.PackageExplorer?after=additions">
<command
commandId="myCommand"
label="Test">
<visibleWhen checkEnabled="false">
<with variable="selection">
<iterate>
<instanceof value="org.eclipse.core.resources.IProject"/>
</iterate>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
The fact that none of these work make me think maybe something more fundamental is going on. Hoping someone here can help me out.... what am I doing wrong??
[Updated on: Tue, 01 October 2013 19:35]
Report message to a moderator