Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Adding a wizard to the new context menu of the package explorer
Adding a wizard to the new context menu of the package explorer [message #523471] Fri, 26 March 2010 10:53 Go to next message
Eclipse UserFriend
Hello everybody,

I'm trying to add a wizard to the new context menu of the package explorer via the extension point "org.eclipse.ui.navigator.navigatorContent". The following configuration inside the plugin.xml of my plugin works for the project explorer, but not for the package explorer:

<extension point="org.eclipse.ui.navigator.navigatorContent">
    <commonWizard
        type="new"
        menuGroupId="org.eclipse.jdt.ui.java"
        wizardId="WIZARD_ID_PLACEHOLDER">
        <enablement>
            <instanceof
                value="org.eclipse.jdt.core.IPackageFragment">
            </instanceof>
        </enablement>
    </commonWizard>
</extension>


What am I doing wrong? The wizard shall only be available for package fragments and shall be displayed inside the Java section of the new context menu. Thanks in advance!

Best regards, Robin.
icon3.gif  Re: Adding a wizard to the new context menu of the package explorer [message #523492 is a reply to message #523471] Fri, 26 March 2010 11:34 Go to previous message
Eclipse UserFriend
Hi Robin,
I had the same problems with the visibleWhen-condition of commands. I found the solution in the book Eclipse plug-ins from Clayberg/Rubel:
<extension
         point="org.eclipse.ui.navigator.navigatorContent">
      <commonWizard
            type="new"
            menuGroupId="org.eclipse.jdt.ui.java"
            wizardId="WIZARD_ID_PLACEHOLDER">
         <enablement>
            <with variable="selection">
               <iterate
                     ifEmpty="false"
                     operator="or">
                  <instanceof
                        value="org.eclipse.jdt.core.IPackageFragment">
                  </instanceof>
               </iterate>
            </with>
         </enablement>
      </commonWizard>
   </extension>

The main aspect to know is how the condition matching works:
You have to test the global variable selection (which returns a collection/iterator of the selected items) and to iterate through them in order to test each one.

In your wizard you then should get the same selection as parameter of the init-method. There you should filter/check it again and take the first object of the type IPackageFragment...

I hope this works for you Smile
Martin
Previous Topic:Responding to specific kinds of interruption in a builder
Next Topic:Dynamic web project option is not showing in File->New->other
Goto Forum:
  


Current Time: Tue Jun 24 10:39:36 EDT 2025

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

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

Back to the top