Skip to main content



      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 11:50 Go to next message
Eclipse UserFriend
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 11:51] by Moderator

Re: Why is a .java file not an IFile? [message #514311 is a reply to message #514167] Sat, 13 February 2010 19:03 Go to previous messageGo to next message
Eclipse UserFriend
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 14:19 Go to previous message
Eclipse UserFriend
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 Jul 05 09:12:02 EDT 2025

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

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

Back to the top