Name Filter for eclipse.ui.menus

I have a contribution to the menu implemented through the extension point org.eclipse.ui.menus. I would like to offer this contribution to the menu only for certain file extensions (for example, * .pld), but I could not figure out how to do this with "visibleWhen". Any ideas?

--------------- Update ---------------- So far, my distribution point is:

<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

+4
source share
1 answer

There are several 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 repeat the selection so that it is fully visible when there is something like:

<visibleWhen
      checkEnabled="false">
    <iterate
         ifEmpty="false"
         operator="or">
        <test
            property="org.eclipse.core.resources.name"
            value="*.pld">
        </test>
    </iterate>
</visibleWhen>
+3
source

All Articles