Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Help! Cannot cast Selection to anything useful
Help! Cannot cast Selection to anything useful [message #143318] Mon, 13 October 2003 20:41
Eclipse UserFriend
Originally posted by: clee3.students.depaul.edu

Hello,

I've been struggling with this for about 2 days now. What I want to do
is, by using a menu action, launch a wizard programatically. From there,
I want to get the selection in the Package Explorer to get the Java class
selected. However, from the selection (StructuredSelection) I get nothing
useful.

SampleNewWizard wizard = new SampleNewWizard();
IWorkbench workbench = PlatformUI.getWorkbench();
ISelection selection = workbench.getActiveWorkbenchWindow()
.getSelectionService().getSelection();

I then cast selection to IStructuredSelection and getFirstElement()

however, from there, I cannot cast that to anything. IJavaElement,
ICompilationUnit, or anything. When I do a getClass() and getInterfaces()
on the object from the StructuredSelection, it shows ICompilationUnit,
however it is not an instanceof ICompilationUnit.

My guess is that the classloader is affecting this. I have to export the
jdtcore.jar with the plugin to get it to work, or i get
ClassNotFoundExceptions. But then, if the classloader for the selection
is different than the plugin. And I cannot cast from one to another.

ANY help is appreciated, as I've wasted many hours on this issue.

Thanks,

Chris
Previous Topic:Getting weird error when context menu is opened
Next Topic:Cross version API compatibility
Goto Forum:
  


Current Time: Tue Aug 27 23:54:35 GMT 2024

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

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

Back to the top