SgtDroelf
SgtDroelf

Reputation: 349

Eclipse-Plugin - plugin.xml - Understanding ?after=refactor

i am currently given an Eclipse-Plugin at work and nobody knows where it is supposed to show in Eclipse. So i'm trying to understand how the plugin.xml works and so far it looks good - So just to confirm myself here:

<menuContribution
     allPopups="false"  
     locationURI="[...]?after=refactor">

That means that the my plugin menu (with the commands it contains) is supposed to show in the options after i choose Refactor on any element, right?

(There is still some work to be done on this and so far nothing shows butso i can be sure to look in the right place, thats the reason for my (quite simple) question.)

Upvotes: 0

Views: 148

Answers (1)

greg-449
greg-449

Reputation: 111218

All this means is that the menu item is added to the menu after a menu item called refactor. It has nothing to do with running any actions. You use the visibleWhen elements to control when a menu item is visible.

For example this is from the Java Debug code:

   <menuContribution
         allPopups="false"
         locationURI="popup:#CompilationUnitEditorContext?before=additions">
      <separator
            name="java.debug">
      </separator>
      <command
            commandId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
            style="push">
         <visibleWhen
               checkEnabled="false">
            <and>
               <systemTest
                     property="org.eclipse.jdt.debug.ui.debuggerActive"
                     value="true">
               </systemTest>
               <systemTest
                     property="org.eclipse.jdt.debug.ui.instanceof.IJavaStackFrame"
                     value="true">
               </systemTest>
               <with
                     variable="activeMenuSelection">
                  <instanceof
                        value="org.eclipse.jface.text.ITextSelection">
                  </instanceof>
               </with>
            </and>
         </visibleWhen>
      </command>
   </menuContribution>

In this case before=additions says the menu is added before the menu entry called additions. A fairly elaborate visibleWhen is used to control when the menu is shown.

The separator definition:

      <separator
            name="java.debug">
      </separator>

adds a separate with the name java.debug - which could then be used in before / after.

Upvotes: 1

Related Questions