Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » how to get IJavaProject from IProject (Dynamic Web Project)
how to get IJavaProject from IProject (Dynamic Web Project) [message #162584] Wed, 01 March 2006 18:54 Go to next message
Eclipse UserFriend
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 messageGo to next message
Eclipse UserFriend
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 #162637 is a reply to message #162584] Thu, 02 March 2006 03:45 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
I've used:

(IJavaProject)iproject.getNature(JavaCore.NATURE_ID);


Cheers,
Larry

william wrote:
>
> 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 #162654 is a reply to message #162584] Thu, 02 March 2006 08:10 Go to previous message
Eclipse UserFriend
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
Previous Topic:wtp downloads
Next Topic:how to add web module to a project
Goto Forum:
  


Current Time: Fri Aug 23 06:04:37 GMT 2024

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

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

Back to the top