Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » 'Visiblewhen' in eclipse menu. Want menu to only appear for particular file extensions
'Visiblewhen' in eclipse menu. Want menu to only appear for particular file extensions [message #1385416] Fri, 06 June 2014 09:53
joseph reddington is currently offline joseph reddingtonFriend
Messages: 16
Registered: January 2012
Junior Member
Hi all, I've a question that struggled on stackoverflow for a while, but didn't solve my problem. I come to you guys to plead for help.


I have an eclipse plugin with a menu. It looks like this:

http://i.stack.imgur.com/5Zuzq.png


I'd like that menu to only appear when viewing files of a particular file extension (let's say .txt for this example).

Using the help of a great guy on SO I got as far as the following plugin.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="menu:org.eclipse.ui.main.menu?after=additions">
         <menu
               id="ARTful.menus.sampleMenu"
               label="Hide Me"
               mnemonic="M">
            <command
                  commandId="ArtEditor.command.format"
                  id="ARTful.menus.sampleCommand"
                  mnemonic="S"
                  tooltip="Hello!">
            </command>

             <visibleWhen
       checkEnabled="false">
   <with variable="selection">
      <iterate
           ifEmpty="false">
         <adapt type="org.eclipse.core.resources.IResource">
              <test property="org.eclipse.core.resources.extension" value="txt" />
         </adapt>
      </iterate>
   </with>
</visibleWhen>
</menu>
      </menuContribution>
   </extension>

</plugin>


With this setup:

http://i.stack.imgur.com/KGuXE.png

...but still NO luck - any ideas what I might be doing wrong?

Previous Topic:PDE Plugin Export failed
Next Topic:Finding the "PlugIn"-Directory
Goto Forum:
  


Current Time: Mon Dec 22 09:19:18 GMT 2014

Powered by FUDForum. Page generated in 0.02104 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software