Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » popupMenus folder Problem
popupMenus folder Problem [message #18584] Mon, 28 April 2003 08:49 Go to next message
Eclipse UserFriend
Originally posted by: hawkini.myrealbox.com

Hi, I have been trying to write a plugin, where when you right click on a
source folder (in a java project for example) a new menu item appears and
when you click that, I want an IStructuredSelection to be returned so I
can use it in the run() method of my action. So far, I have the menu item,
when I click it the run() method executes (as I have a test dialog that
appears). I also have a IStructuredSelection cast from the ISelection that
contains more than one item.

However, I am getting very frustrated as I expect some IFolders and IFiles
to be in this selection, but all I get are IPackageFragmentRoots and
IPackageFragments - I have tried casting these to everything under the sun
but keep getting the infamous "Unhandled exception caught in event loop."
everytime I try and do ANYTHING other than handle objects in my selection.

Please please please can someone offer up some code, as I have scoured the
web but none seems to be available - I just need a simple example where I
can do some processing on the IFolder (not IFile) that the user right
clicked on.

Kind regards,

Matt Hawkins
Re: popupMenus folder Problem [message #19294 is a reply to message #18584] Mon, 28 April 2003 09:56 Go to previous messageGo to next message
Eclipse UserFriend
That's because you are on a java packager view. The selected objects are
special java objects. You need to do

1) Test if the item(s) are implementers of IAdaptable
2) If they are, then you use item.getAdapter(IResource.class);

This should return the IResource representing it. Though you will need
to test each one to make sure. You could be selecting something that
doesn't adapt to an IResource or to an IFile or IFolder.

Rich Kulp
Re: popupMenus folder Problem [message #19475 is a reply to message #19294] Mon, 28 April 2003 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hawkini.myrealbox.com

Thank you very much - it works fine now! For future reference, can you
tell me where I could of found that information? I'm not being sarcastic -
I really would like to know because I've spent ages trying to find it!

Regards,

Matt Hawkins

Richard L. Kulp wrote:

> That's because you are on a java packager view. The selected objects are
> special java objects. You need to do

> 1) Test if the item(s) are implementers of IAdaptable
> 2) If they are, then you use item.getAdapter(IResource.class);

> This should return the IResource representing it. Though you will need
> to test each one to make sure. You could be selecting something that
> doesn't adapt to an IResource or to an IFile or IFolder.

> Rich Kulp
Re: popupMenus folder Problem [message #19701 is a reply to message #19475] Mon, 28 April 2003 11:09 Go to previous message
Eclipse UserFriend
To tell you the truth, I don't know where you find it out. There may be
something in the help somewhere, but often it is just looking at other
code to see how they did it.

Rich Kulp
Previous Topic:4-5 eclipse software engineers needed
Next Topic:display problem in WizardDialog
Goto Forum:
  


Current Time: Sat May 03 01:31:44 EDT 2025

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

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

Back to the top