Help! Cannot cast Selection to anything useful [message #143318] |
Mon, 13 October 2003 16:41 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.02684 seconds