views:

1064

answers:

3

Hi All,

I am trying to add a new menu item to Eclipse's popupmenus. It really seemed straightforward enough in the examples and tutorials but the menu item itself is never visible. I expect this to work in all views and for basically anything that is a file. I am using Eclipse 3.4. This is the my plugin.xml configuration:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>

   <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            objectClass="org.eclipse.core.resources.IFile"
            id="com.willcodejavaforfood.ExploreHere.contribution1">
         <action
               label="Explore Here"
               class="com.willcodejavaforfood.explorehere.popup.actions.ExploreHereAction"
               menubarPath="additions"
               enablesFor="1"
               id="com.willcodejavaforfood.ExploreHere.newAction">
         </action>
      </objectContribution>
   </extension>

</plugin>

Any idea why it is never visible?

----edit----

Turns out my plugin works just fine in version 3.4.2 of Ganymede, but not in the older version 3.4.0 that I previously used.

+2  A: 

Hi,

I tried your code in my Eclipse's installation and I am able to see the action in the contextual menu when I right click one of my .c file in the Project explorer's view of the C perspective.

Take care that a Project or a project's sub folder is not a file.

Manuel Selva
Hey thanks for trying it. Where in the context menu does it show up?
willcodejavaforfood
Just after the refresh entry
Manuel Selva
That is where I expected it to be. I packaged it into a jar and tried it on another machine with a clean eclipse install but still nothing. You must have done something differently from me.... ? :)
willcodejavaforfood
Which version of eclipse are you using?
willcodejavaforfood
Eclipse 3.4.2. I just copied and pasted your extension in one of my plugin.xml file.
Manuel Selva
Works for me too. I'm running 3.5.
Kire Haglin
Is your project setup correctly? Does other extension points work?
Kire Haglin
+2  A: 

May be you can try the PDE templates:

File -> New plugin project -> On the last page select create from template and try the Plugin with popup menu which description is exactly what you want:

"This template adds a submenu and a new action to a target object's popup menu. This contribution will appear in all viewers where an object of the specified type is selected."

Hope this can help

Manu

Manuel Selva
That is actually what I started out with, but that never worked either. I might try and see if I have the latest version of eclipse.
willcodejavaforfood
A: 

Try ICompiliationUnit instead of IFile

BOB
Thank you but it works in every other version of Eclipse I've tried except in 3.4.0 so this issue has been resolved.
willcodejavaforfood