Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Why is a .java file not an IFile?
icon8.gif  Why is a .java file not an IFile? [message #514167] Fri, 12 February 2010 16:50 Go to next message
sheamus  is currently offline sheamus Friend
Messages: 14
Registered: September 2009
Junior Member
I want to create a context menu action for Java source files in eclipses.

In my plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         point="org.eclipse.ui.popupMenus">
      <objectContribution
            id="dds_gen.contribution1"
            objectClass="org.eclipse.core.runtime.IAdaptable"
            nameFilter="*.java">
         <menu
               label="My Menu"
               path="additions"
               id="my_gen.menu1">
            <separator
                  name="group1">
            </separator>
         </menu>
         <action
               label="My Generator"
               class="my_gen.popup.actions.MyGeneratorAction"
               menubarPath="my_gen.menu1/group1"
               enablesFor="1"
               id="my_gen.newAction">
         </action>
      </objectContribution>
   </extension>

</plugin> 


If I change org.eclipse.core.runtime.IAdaptable to org.eclipse.core.resources.IFile or org.eclipse.core.resources.IResource I do not see my action in menu. But if it is an IAdaptable I do. All the docs and tutorials say I should be using IFile.

I am on eclipse 3.4.

Thanks,
~S

[Updated on: Fri, 12 February 2010 16:51]

Report message to a moderator

Re: Why is a .java file not an IFile? [message #514311 is a reply to message #514167] Sun, 14 February 2010 00:03 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
if you want the menu for .java files in the package explorer,
try org.eclipse.jdt.core.ICompilationUnit, which is the Java model
view of the file. The connection to the IFile is then via
getUnderlyingResource()

HTH
Stephan
Re: Why is a .java file not an IFile? [message #514564 is a reply to message #514167] Mon, 15 February 2010 19:19 Go to previous message
sheamus  is currently offline sheamus Friend
Messages: 14
Registered: September 2009
Junior Member
Thanks that got it.
~S
Previous Topic:Cleanest way to allow plugin version ranges
Next Topic:Why is a .java file not an IFile?
Goto Forum:
  


Current Time: Sat Apr 27 05:16:47 GMT 2024

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

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

Back to the top