问题
I've got a menu contribution, realised through org.eclipse.ui.menus
extension point. I'd like to offer this menu contribution only for specific file extensions (e.g. *.pld), but I couldn't figure out how to do this with "visibleWhen". Any ideas?
---------------Update---------------- My extension point so far:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?before=additions">
<command
commandId="org.variability.configurator.commands.createPlc"
icon="icons/PlcWizard.png"
label="Create Product"
style="push">
<visibleWhen
checkEnabled="false">
</visibleWhen>
</command>
</menuContribution>
</extension>
Cheers, Phil
回答1:
There are a couple of property tests you can use:
<test
property="org.eclipse.core.resources.name"
value="*.pld">
</test>
and
<test
property="org.eclipse.core.resources.extension"
value="pld">
</test>
You will need to iterate over the selection so the full visible when would be something like:
<visibleWhen
checkEnabled="false">
<iterate
ifEmpty="false"
operator="or">
<test
property="org.eclipse.core.resources.name"
value="*.pld">
</test>
</iterate>
</visibleWhen>
来源:https://stackoverflow.com/questions/19776876/name-filter-for-eclipse-ui-menus