how to get IJavaProject from IProject (Dynamic Web Project) [message #162584] |
Wed, 01 March 2006 18:54 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: wul99.yahoo.com
I am working on a plugin, which needs to check current classpath entried
of dynamic web project. I can get a reference of IProject and I want to
get IJavaProject so that I can retrieve all IClassPathEntry. I have tried
IJavaProject javaProject = project.getAdapter(IJavaPorject.class);
But it returns null.
Did i do it wrong? How can I get reference of IJavaProject from IProject?
Thanks
William
|
|
|
Re: how to get IJavaProject from IProject (Dynamic Web Project) [message #162630 is a reply to message #162584] |
Thu, 02 March 2006 00:03 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: alex_blewitt.yahoo.com
That's how you'd do it. It's probably returning null because it doesn't know how to adapt to that type. You might find that there's some specialised subclass for DynamicWeb projects (IDynamicWebProject, for example) that it knows how to adapt to and as an added bonus, IDynamicWebProject may be a subtype of IJavaProject.
It sounds like it might be a desirable feature, and it would only be an extra few lines of code, so you might want to submit an enhancement request for this in the future.
I've had a quick look at the JavaDoc for the WTP and can't see anything that would suggest there is an IDynamicWebProject, but if you've got it imported into your workspace I'd suggest trying to look for implementors of IProject to see what comes up.
Alex.
|
|
|
|
Re: how to get IJavaProject from IProject (Dynamic Web Project) [message #162654 is a reply to message #162584] |
Thu, 02 March 2006 08:10 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
Originally posted by: daniel.rohe.stud.tu-ilmenau.de
william schrieb:
>
> I am working on a plugin, which needs to check current classpath entried
> of dynamic web project. I can get a reference of IProject and I want to
> get IJavaProject so that I can retrieve all IClassPathEntry. I have tried
> IJavaProject javaProject = project.getAdapter(IJavaPorject.class);
>
> But it returns null.
>
> Did i do it wrong? How can I get reference of IJavaProject from IProject?
>
>
> Thanks
>
> William
>
I think the normal way is:
IProject project = getProject();
IJavaProject javaProject = JavaCore.create(project);
if (javaProject == null || !javaProject.exists()) {
// current project is not a Java project
}
HTH
Daniel
|
|
|
Powered by
FUDForum. Page generated in 0.03420 seconds