简体   繁体   中英

How can i print the org.eclipse.core.resources for an eclipse plugin

I'm currently working on an Eclipse plugin. I want to add an item on right-click menu in WorkbenchView of my plugin. This item should be visible only to a specific object.

I tried to use the VisibleWhen tag like this :

    <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="popup:MyURI">
         <command
               commandId="MyCommandId"
               style="push">
            <visibleWhen
                  checkEnabled="false">
               <test
                     property="org.eclipse.core.resources.name"
                     value="WORKSPACE">
               </test>
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>

And when I do it the menu item never appears.

So is there a way to test the properties values of org.eclipse.core.resources and know what is wrong with them ?

Thanks.

Alexandre.

Try something like this:

<visibleWhen 
    checkEnabled="false"> 
<iterate>
   <adapt type="org.eclipse.core.resources.IResource">
      <test property="org.eclipse.core.resources.name" 
            value="*.java"/>
   </adapt>
</iterate>

This will show the menu for all of the *.java files. Modify this according to your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM