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?
Why is a .java file not an IFile? [message #604651] 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="HCM Trainers"
path="additions"
id="dds_gen.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="DDS Generator"
class="dds_gen.popup.actions.DdsGeneratorAction"
menubarPath="dds_gen.menu1/group1"
enablesFor="1"
id="dds_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
Re: Why is a .java file not an IFile? [message #604670 is a reply to message #604651] 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 #604687 is a reply to message #604651] 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:Why is a .java file not an IFile?
Next Topic:Product Export fails when optional packages are missing
Goto Forum:
  


Current Time: Wed Apr 24 16:14:51 GMT 2024

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

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

Back to the top