Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » PDE: how to get workspace root for imported project?
PDE: how to get workspace root for imported project? [message #89058] Fri, 04 July 2003 09:41 Go to next message
Eclipse UserFriend
Originally posted by: Frank_van_den_Beuken.programmingresearch.com

Hi all,
I'm writing a plug-in and to test it, I imported an existing large project
from my regular workspace into the runtime-workspace, using the
launched eclipse runtime.
This does not copy the contents of the project.
Eclipse works fine for the imported project; I am able to build the project
without problems in the launched runtime.

My plugin, however, needs paths to Java resources in the project and
is unable to get these.
I use:
IWorkspaceRoot root = eclipseProject.getProject().getWorkspace().getRoot();

where eclipseProject is the IJavaProject the plug-in action operates on,
but this gives me the root of the runtime-workspace, instead of the regular
workspace, in which the project is actually located.
Is this a bug?
Or is there another way to get the file location of the project?
Why is it so hard to get absolute file system paths (including workspace
root path) from eclipse?

Thanks in advance for any help,
Frank
Re: PDE: how to get workspace root for imported project? [message #91350 is a reply to message #89058] Thu, 10 July 2003 18:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

You're working with two different Eclipse workspaces, and they don't
know anything about each other. From the runtime-workspace Eclipse,
there is no way to get information about the workspace of the Eclipse it
was launched from. They're two completely independent programs. Sorry.
However, there is no problem with getting the absolute file system
path of any resource: just use IResource.getLocation().
--


Frank van den Beuken wrote:
> Hi all,
> I'm writing a plug-in and to test it, I imported an existing large project
> from my regular workspace into the runtime-workspace, using the
> launched eclipse runtime.
> This does not copy the contents of the project.
> Eclipse works fine for the imported project; I am able to build the project
> without problems in the launched runtime.
>
> My plugin, however, needs paths to Java resources in the project and
> is unable to get these.
> I use:
> IWorkspaceRoot root = eclipseProject.getProject().getWorkspace().getRoot();
>
> where eclipseProject is the IJavaProject the plug-in action operates on,
> but this gives me the root of the runtime-workspace, instead of the regular
> workspace, in which the project is actually located.
> Is this a bug?
> Or is there another way to get the file location of the project?
> Why is it so hard to get absolute file system paths (including workspace
> root path) from eclipse?
>
> Thanks in advance for any help,
> Frank
>
>
Re: PDE: how to get workspace root for imported project? [message #93228 is a reply to message #91350] Mon, 14 July 2003 11:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Frank_van_den_Beuken.programmingresearch.com

Thanks for your answer..

If I use IResource.getLocation on the IProject, I indeed get the correct
path to the contents of the project.
I was looking for the path to the workspace root, as I want to make
classpath entries returned by IJavaProject.getResolvedClasspath absolute,
and these classpaths often are absolute starting from the workspace root.

So what I am going to do now is take the path to the project and strip
of the last segment, which assumes that the project path always starts one
level deep inside the workspace.

If you know of better ways to make the classpath entries absolute, I'd be
very interested to hear how that is done.

Thanks,
Frank

"John Arthorne" <John_Arthorne@oti.com_> wrote in message
news:3F0DEA4B.5050604@oti.com_...
> You're working with two different Eclipse workspaces, and they don't
> know anything about each other. From the runtime-workspace Eclipse,
> there is no way to get information about the workspace of the Eclipse it
> was launched from. They're two completely independent programs. Sorry.
> However, there is no problem with getting the absolute file system
> path of any resource: just use IResource.getLocation().
> --
>
>
> Frank van den Beuken wrote:
> > Hi all,
> > I'm writing a plug-in and to test it, I imported an existing large
project
> > from my regular workspace into the runtime-workspace, using the
> > launched eclipse runtime.
> > This does not copy the contents of the project.
> > Eclipse works fine for the imported project; I am able to build the
project
> > without problems in the launched runtime.
> >
> > My plugin, however, needs paths to Java resources in the project and
> > is unable to get these.
> > I use:
> > IWorkspaceRoot root =
eclipseProject.getProject().getWorkspace().getRoot();
> >
> > where eclipseProject is the IJavaProject the plug-in action operates on,
> > but this gives me the root of the runtime-workspace, instead of the
regular
> > workspace, in which the project is actually located.
> > Is this a bug?
> > Or is there another way to get the file location of the project?
> > Why is it so hard to get absolute file system paths (including workspace
> > root path) from eclipse?
> >
> > Thanks in advance for any help,
> > Frank
> >
> >
>
Re: PDE: how to get workspace root for imported project? [message #93489 is a reply to message #93228] Mon, 14 July 2003 16:55 Go to previous message
Eclipse UserFriend
Originally posted by: John_Arthorne.oti.com_

There is not necessarily any correspondence between a project location
and the location of the workspace root. Each project can have its own
location, independent of any project or the default location.

To resolve the paths of classpath entries, it would help to know what
kinds of entries you are interested in. As the javadoc for
IClasspathEntry.getPath states, each type of entry returns a path that
is relative to something different. FYI, As a general rule, when API
methods say "path", they generally mean a workspace path that has
nothing to do with the file system. When API says "location", it is
talking about a file system path. You map from a "path" to a "location"
by finding the IResource that corresponds to the path (for example using
IWorkspace.getRoot().findMember(IPath path)), and then say
IResource.getLocation() to get the file system location.
--


Frank van den Beuken wrote:
> Thanks for your answer..
>
> If I use IResource.getLocation on the IProject, I indeed get the correct
> path to the contents of the project.
> I was looking for the path to the workspace root, as I want to make
> classpath entries returned by IJavaProject.getResolvedClasspath absolute,
> and these classpaths often are absolute starting from the workspace root.
>
> So what I am going to do now is take the path to the project and strip
> of the last segment, which assumes that the project path always starts one
> level deep inside the workspace.
>
> If you know of better ways to make the classpath entries absolute, I'd be
> very interested to hear how that is done.
>
Previous Topic:Re: Adding menu items to File --> New
Next Topic:Re: CVS Graph plugin for Eclipse available
Goto Forum:
  


Current Time: Tue Jul 22 02:27:35 EDT 2025

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

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

Back to the top