Reputation: 8152
I am trying to follow Lars Vogel's tutorial on natures and am stuck at the point where the visibleWhen
for a menu is defined. When I add the following to my command
definition in my menuContribution
:
<visibleWhen
checkEnabled="false">
<adapt
type="org.eclipse.core.resources.IProject">
</adapt>
</visibleWhen>
my menu item never appears when right-clicking a project in Project Explorer.
I double-checked that I have all necessary things like org.eclipse.core.runtime
, org.eclipse.core.resources
and org.eclipse.ui
as dependencies.
What am I missing?
Upvotes: 0
Views: 188
Reputation: 111217
You need to use <iterate>
since what you are testing is a selection which may have multiple items:
For example this is one of the PDE API analysis tool command definitions:
<command
commandId="org.eclipse.pde.api.tools.ui.convert.javadocs"
style="push">
<visibleWhen
checkEnabled="false">
<iterate>
<adapt
type="org.eclipse.core.resources.IProject">
<test
property="org.eclipse.core.resources.projectNature"
value="org.eclipse.pde.api.tools.apiAnalysisNature">
</test>
</adapt>
</iterate>
</visibleWhen>
</command>
Upvotes: 1