How to get current project's name and path [message #322730] |
Tue, 27 November 2007 15:48 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
Hello all,
I'm writing a plugin for Eclipse and since somedays i'm searching how to
get current project's name and full path (i.e.
C:\...\workspace\projectname).
I've read all articles and all emails and i tried all codes given but
unfortunately no success no success.
Please kindly can anyone give me a working solution. I think i need
dependencies, import declerations lines and codeline.
Any help will be really very very appreciated.
Thanx in advance.
Best Regards,
Ran
|
|
|
Re: How to get current project's name and path [message #322731 is a reply to message #322730] |
Tue, 27 November 2007 16:03 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Ran,
IResource.getLocation()/getLocationURI() should do the trick.
Noyan Culum wrote:
> Hello all,
>
> I'm writing a plugin for Eclipse and since somedays i'm searching how
> to get current project's name and full path (i.e.
> C:\...\workspace\projectname).
>
> I've read all articles and all emails and i tried all codes given but
> unfortunately no success no success.
> Please kindly can anyone give me a working solution. I think i need
> dependencies, import declerations lines and codeline.
>
> Any help will be really very very appreciated.
>
> Thanx in advance.
>
> Best Regards,
> Ran
>
>
|
|
|
Re: How to get current project's name and path [message #322732 is a reply to message #322731] |
Tue, 27 November 2007 17:01 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
Ed,
Thank you but org.eclipse.core.resources.IResource don't have
getLocation() method.
I tried also
org.eclipse.core.resources.Resourcesplugin.getWorkspace().ge tRoot().getLocation()
but this give this path:
"C:\...\My Documents\runtime-EclipseApplication".
But I'm searching how to get this path:
"C:\...\My Documents\workspace".
+ additionally i'm searching how to get projectname.
|
|
|
|
Re: How to get current project's name and path [message #322744 is a reply to message #322735] |
Tue, 27 November 2007 21:39 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
Dear Ed,
I saw, yes you have reason, there is getLocation() method here. Than i
tried different uses with this, for example:
org.eclipse.core.resources.IResource iresource;
System.out.println(iresource.getLocation());
But this returns a null response, so unfortunately, i can't find the exact
code solution with this (and others) suggestion. If you (or anotherone)
can kindly give me a working codeline, it will be really very appreciated.
Thanx again.
Ran
|
|
|
Re: How to get current project's name and path [message #322746 is a reply to message #322744] |
Tue, 27 November 2007 22:16 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Noyan,
Perhaps the resource doesn't actually exist or something else is wrong?
The getLocationURI is more general, you might try that. If these are
both returning null there's likely something going on you've not told us
about.
Noyan wrote:
> Dear Ed,
>
> I saw, yes you have reason, there is getLocation() method here. Than i
> tried different uses with this, for example:
>
>
> org.eclipse.core.resources.IResource iresource;
> System.out.println(iresource.getLocation());
>
>
> But this returns a null response, so unfortunately, i can't find the
> exact code solution with this (and others) suggestion. If you (or
> anotherone) can kindly give me a working codeline, it will be really
> very appreciated.
>
> Thanx again.
> Ran
>
>
|
|
|
Re: How to get current project's name and path [message #322755 is a reply to message #322746] |
Wed, 28 November 2007 08:51 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
Ed How i can determine IProject?
Is there a method such:
org.eclipse.core.resources.IResource iresource = new IResource(this);
Or the code below automatically detect the current selected project?
org.eclipse.core.resources.IResource iresource;
System.out.println(iresource.getLocation());
|
|
|
|
Re: How to get current project's name and path [message #322758 is a reply to message #322730] |
Wed, 28 November 2007 10:28 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
Hello Ed and others,
I found the trick for workspace location. Here is my code:
org.eclipse.core.resources.ResourcesPlugin.getWorkspace().ge tRoot().getLocation()
When i run this for testing via "Launc an Eclipse Application" or "Run
Eclipse Application" buttons, it returns this location:
workspace: C:/Documents and Settings/rbt/My
Documents/runtime-EclipseApplication
But when i export it as a "Deployable Plug-in" (File->Export->Deployable
plug-ins and fragments), restart Eclipse and execute it as deployable
plugin. This time, it returns this location:
C:/Documents and Settings/rbt/My Documents/workspace
I wrote this for future researchers. I hope this help them.
NOW I HAVE STILL MY OTHER QUESTION
and it is more important now. Beause i want to obtain this path:
C:/Documents and Settings/rbt/My Documents/workspace/projectname
How can i get the project's name? I tried
org.eclipse.core.resources.ResourcesPlugin.getWorkspace().ge tRoot().getProject()
but this returns null..
Thank you in advance
|
|
|
Re: How to get current project's name and path [message #322764 is a reply to message #322755] |
Wed, 28 November 2007 13:08 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
This is a multi-part message in MIME format.
--------------030307080608090006060707
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
Noyan,
I get the feeling you haven't read any of the basic documentation about
Eclipse's workspace APIs. I'd suggest becoming familiar with what's
available in help:
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. platform.doc.user/concepts/concepts-12.htm
Folks will be far more likely to answer questions if it's clearly you've
done a little bit of homework first.
Noyan wrote:
> Ed How i can determine IProject?
>
> Is there a method such:
> org.eclipse.core.resources.IResource iresource = new IResource(this);
>
>
> Or the code below automatically detect the current selected project?
> org.eclipse.core.resources.IResource iresource;
> System.out.println(iresource.getLocation());
>
>
--------------030307080608090006060707
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Noyan,<br>
<br>
I get the feeling you haven't read any of the basic documentation about
Eclipse's workspace APIs.
|
|
|
Re: How to get current project's name and path [message #322765 is a reply to message #322758] |
Wed, 28 November 2007 13:12 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Noyan,
Good, you've done some homework.
Noyan wrote:
> Hello Ed and others,
>
> I found the trick for workspace location. Here is my code:
> org.eclipse.core.resources.ResourcesPlugin.getWorkspace().ge tRoot().getLocation()
>
>
> When i run this for testing via "Launc an Eclipse Application" or "Run
> Eclipse Application" buttons, it returns this location:
> workspace: C:/Documents and Settings/rbt/My
> Documents/runtime-EclipseApplication
>
> But when i export it as a "Deployable Plug-in"
> (File->Export->Deployable plug-ins and fragments), restart Eclipse and
> execute it as deployable plugin. This time, it returns this location:
> C:/Documents and Settings/rbt/My Documents/workspace
>
> I wrote this for future researchers. I hope this help them.
This will always reflect where the workspace itself is located. Project
will not necessarily be physically nested within that folder since when
a project is created you can specify anywhere in the file system at
which to locate it.
>
>
> NOW I HAVE STILL MY OTHER QUESTION
> and it is more important now. Beause i want to obtain this path:
> C:/Documents and Settings/rbt/My Documents/workspace/projectname
>
> How can i get the project's name? I tried
> org.eclipse.core.resources.ResourcesPlugin.getWorkspace().ge tRoot().getProject()
>
> but this returns null..
You really need to read some basic information. To root itself is not
in a project and projects cannot nest. If you look at the API for
IWorkspaceRoot you'll see methods like getProject(String) and
getProjects. Please try to use the Javadoc to help answer your questions...
>
>
> Thank you in advance
>
>
|
|
|
Re: How to get current project's name and path [message #322769 is a reply to message #322765] |
Wed, 28 November 2007 13:55 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
>
> You really need to read some basic information. To root itself is not in a
> project and projects cannot nest. If you look at the API for
> IWorkspaceRoot you'll see methods like getProject(String) and getProjects.
> Please try to use the Javadoc to help answer your questions...
>
:)))
Dear Ed,
Do you know how i can get the selected project's name? or do you not?
However i have to thank you for all your kindly responses..
Best Regards,
Noyan
|
|
|
Re: How to get current project's name and path [message #322770 is a reply to message #322769] |
Wed, 28 November 2007 13:57 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Noyan,
Do you already have the selected project in hand? If not, it becomes
important to understand where you will expect this to come from...
Noyan wrote:
>>
>> You really need to read some basic information. To root itself is
>> not in a project and projects cannot nest. If you look at the API for
>> IWorkspaceRoot you'll see methods like getProject(String) and
>> getProjects. Please try to use the Javadoc to help answer your
>> questions...
>>
>
> :)))
>
> Dear Ed,
>
> Do you know how i can get the selected project's name? or do you not?
>
> However i have to thank you for all your kindly responses..
>
> Best Regards,
> Noyan
>
>
|
|
|
Re: How to get current project's name and path [message #322772 is a reply to message #322765] |
Wed, 28 November 2007 14:07 |
Eclipse User |
|
|
|
Originally posted by: noyanculum.yahoo.com
>
> You really need to read some basic information. To root itself is not in a
> project and projects cannot nest. If you look at the API for
> IWorkspaceRoot you'll see methods like getProject(String) and getProjects.
> Please try to use the Javadoc to help answer your questions...
>
:)))))
Dear Ed,
Do you know how to get the name of the selected project? Or do you not?
However, i thank you for all your kindly responses.
Best Regards,
Noyan
|
|
|
Re: How to get current project's name and path [message #322775 is a reply to message #322772] |
Wed, 28 November 2007 14:26 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Noyan,
You seem to have repeated your question... Of course the answer is you
call IProject.getName, but I think you are asking about how to get "the
selected project" but you've not provided any context in which to answer
that. The IDE is full of views and can even have multiple windows, so
you'll need to narrow down the context of your question for anyone to be
able to answer it...
Noyan wrote:
>>
>> You really need to read some basic information. To root itself is
>> not in a project and projects cannot nest. If you look at the API
>> for IWorkspaceRoot you'll see methods like getProject(String) and
>> getProjects. Please try to use the Javadoc to help answer your
>> questions...
>>
>
> :)))))
>
> Dear Ed,
>
> Do you know how to get the name of the selected project? Or do you not?
>
> However, i thank you for all your kindly responses.
>
> Best Regards,
> Noyan
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05224 seconds