[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.jdt] Discovering whether a project exists in the current workspace
|
- From: "R (Chandra) Chandrasekhar" <chandrac@xxxxxxxxxxxxxx>
- Date: Tue, 04 Apr 2006 15:42:09 +0800
- Newsgroups: eclipse.tools.jdt
- Organization: EclipseCorner
- User-agent: Thunderbird 1.5 (Windows/20051201)
Folks,
I am trying to discover whether a named project exists in the current
Workspace. So far, I can think of three scenarios:
(a) Project does not exist in the current Workspace;
(b) Project has been imported into the current Workspace but resides in
another directory outside the current Workspace; and
(c) Project resides in a directory in the current Workspace.
I would like to interrogate the current Workspace and get null for (a),
and the actual filesystem locations for the project in cases (b) and (c).
I have written a (headless) plugin to use the Resources plugin to do this.
Unfortunately,
1. I either have to give the current development Workspace as an
explicit -data parameter to the CLI invocation of the headless plugin;
or
2. I can run the plugin via
Run > Run As > Eclipse Application
in which case the plugin is run in a new runtime workspace called
runtime-EclipseApplication
which is (I think) the default name for a new runtime Workspace.
Both of these are unsatisfactory because in (1) I explicitly supply the
name of the current workspace (instead of discovering it
programmatically) and in (2) the Workspace that is discovered is not the
development Workspace, which I am interested in, but the runtime Workspace.
It appears that a simple Java program with a main method and the line
System.getProperty("user.dir")
invoked from within the development Workspace returns the filesystem
location of the current project in the development Workspace as a
String. (Searching for the named project in the current Workspace must
be still be done, though.)
Moreover, if the current project has been imported from another
directory (in which it resides) but has not been copied into the current
workspace, this command *does* give the directory in which the project
actually resides.
However, it fails when I invoke it from within the headless plugin that
I developed, when it returns the Eclipse base install directory, in my case:
C:\Program Files\Eclipse-SDK-3.1.2-win32\eclipse
and not the current project in the development Workspace.
Finally, if I select a project in the Package Explorer and right click
the context menu to get
Properties > Info > Location
the displayed string gives the correct filesystem location for the
current project.
My questions are:
A. How may I access the result of Properties > Info > Location for a
project from within a program?
B. How may I use the Resources plugin from within Eclipse to search the
current development Workspace without giving it as an explicit parameter
in the CLI or a launch configuration?
Thank you for your patience, and in advance, for your help.
--
Chandra