Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » visbleWhen and enableWhen for opened files in editor
visbleWhen and enableWhen for opened files in editor [message #965827] Wed, 31 October 2012 14:34
Christian Kosmowski is currently offline Christian KosmowskiFriend
Messages: 5
Registered: October 2012
Junior Member
I'm currently developing an eclipse plugin which conains (among others) an "upload" command and a projectNature "myNature"

This command should be visible at the following places:

- In the context menu of the package explorer (if the surrounding project is of "myNature")

- In the context menu of an opened file in the JavaScript editor if (and only if) the currently opened file is a JavaScript file (can be assumed because its only displayed in JavaScript Editor) AND if this file is contained in a project of "myNature".

So the first part (Project Explorer context menu is working fine).

For the second part i added a menuContribution like this:

 <menuContribution
            allPopups="false"
            locationURI="popup:#JavaScriptEditorContext">
         <menu
               icon="resources/icons/documents_klein.png"
               id="de.test.eclipse.menus.documentsInEditor"
               label="Documents">
            <command
                  commandId="de.test.eclipse.portalscripting.commands.uploadCommand"
                  style="push">
            </command>
            <visibleWhen
               <!-- a good solution is missing here -->
            </visibleWhen>
         </menu>
      </menuContribution>


and a command like this:

 <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="de.test.eclipse.portalscripting.handlers.UploadHandler"
            commandId="de.test.eclipse.portalscripting.commands.uploadCommand">
         <enabledWhen><!-- this works -->
            <or>
               <reference
                     definitionId="de.test.eclipse.portalscripting.hasProjectNature">
               </reference>
               <!-- make the context menu in javascript editor case working -->
            </or>
         </enabledWhen>
      </handler>
   </extension>


What i can't figure out is how i can test the currently opened file in the enabledWhen or visbleWhen elements. I'd like to add an element to enabledWhen section of the command so that it is also enabled when the currentFile is contained in a "myNature" project. The "hasProjectnature" definition only works if there are selected elements in the Project Explorer view.

Can anyone help?
Previous Topic:breakpoint properties
Next Topic:Export plugin with dependencies
Goto Forum:
  


Current Time: Fri Mar 29 08:38:48 GMT 2024

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

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

Back to the top