Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Need to get the Project name in which I am currently working in
Need to get the Project name in which I am currently working in [message #196107] Fri, 16 September 2005 11:44 Go to next message
Eclipse UserFriend
Originally posted by: seshasai.aesv.softwareag.com

I need to get the name of the Project which I am working in so that I can
save the various files which I create in the GEF application.
I tried this but :(

IWorkspace myWorkspaceRoot =
ResourcesPlugin.getWorkspace().getRoot().getWorkspace();

IProject myWebProject = myWorkspaceRoot.getProject();


Please help

Sai
Re: Need to get the Project name in which I am currently working in [message #196128 is a reply to message #196107] Fri, 16 September 2005 13:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Sai" <seshasai.aesv@softwareag.com> wrote in message
news:9371069b5be1bf6bc4a91239a0a3d70d$1@www.eclipse.org...
>I need to get the name of the Project which I am working in so that I can
>save the various files which I create in the GEF application.
> I tried this but :(
>
> IWorkspace myWorkspaceRoot =
> ResourcesPlugin.getWorkspace().getRoot().getWorkspace();
>
> IProject myWebProject = myWorkspaceRoot.getProject();
>
There is no such thing as "the project in which you are working".
You could have multiple projects open and be working in all of them.
What you *can* do is get the IProject of a specific IResource.
So, what you should do is determine the IFile for your GEF diagram (you can
get it from ((IFileEditorInput)getEditorInput()).getFile(), and then call
getProject().
---
Sunil
Re: Need to get the Project name in which I am currently working in [message #196135 is a reply to message #196107] Fri, 16 September 2005 13:59 Go to previous messageGo to next message
Nick Allen is currently offline Nick AllenFriend
Messages: 23
Registered: July 2009
Junior Member
Sai wrote:
> I need to get the name of the Project which I am working in so that I
> can save the various files which I create in the GEF application.
> I tried this but :(
>
> IWorkspace myWorkspaceRoot =
> ResourcesPlugin.getWorkspace().getRoot().getWorkspace();
>
> IProject myWebProject = myWorkspaceRoot.getProject();

Since there can be multiple open projects at one time, this is just not
possible. I believe there has been discussion of this point in the
platform newsgroup.

What you can do is use an IResource to determine its project. For
instance, an IFile: IFile.getProject().getName(). Your GEF diagram
should give you access to the IFile interface.

For another way to determine the project in another context see the
following newsgroup posting.

newsgroup: eclipse.platform
date: 5/21/2003 10:25AM
subject: Re: How to get current project from a plugin
author: Richard L. Kulp

Good Luck,
Nick
Re: Need to get the Project name in which I am currently working in [message #196143 is a reply to message #196135] Fri, 16 September 2005 14:07 Go to previous messageGo to next message
Nick Allen is currently offline Nick AllenFriend
Messages: 23
Registered: July 2009
Junior Member
Opps! Looks like Sunil beat me to the punch.
Re: Need to get the Project name in which I am currently working in [message #196165 is a reply to message #196143] Fri, 16 September 2005 14:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Nick Allen" <nwa@bitwiser.org> wrote in message
news:dgejjn$jvj$1@news.eclipse.org...
> Opps! Looks like Sunil beat me to the punch.

Never mind- you confirmed that I wasn't just blowing smoke.
---
Sunil
Re: Need to get the Project name in which I am currently working in [message #196348 is a reply to message #196128] Sun, 18 September 2005 08:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mvsteenbergen.eljakim.scratch-this.nl

Sunil Kamath wrote:
> So, what you should do is determine the IFile for your GEF diagram (you can
> get it from ((IFileEditorInput)getEditorInput()).getFile(), and then call
> getProject().

Note that this will throw a ClassCastException if you're not careful
when you open a file outside your workspace in your graphical editor.

Martijn.
Re: Need to get the Project name in which I am currently working in [message #196380 is a reply to message #196348] Mon, 19 September 2005 14:21 Go to previous message
Eclipse UserFriend
Originally posted by: sunil_kamath.nohotspammail.com

"Martijn van Steenbergen" <mvsteenbergen@eljakim.scratch-this.nl> wrote in
message news:dgj94l$n6j$1@news.eclipse.org...
> Sunil Kamath wrote:
>> So, what you should do is determine the IFile for your GEF diagram (you
>> can
>> get it from ((IFileEditorInput)getEditorInput()).getFile(), and then call
>> getProject().
>
> Note that this will throw a ClassCastException if you're not careful when
> you open a file outside your workspace in your graphical editor.
>
Good point.
You should check that getEditorInput() is an instanceof IFileEditorInput.
---
Sunil
Previous Topic:FreeFormLayer#setOpaque(true) prevents multiple selection?
Next Topic:Alignment actions and LayoutConstrainsts
Goto Forum:
  


Current Time: Wed Jan 15 20:39:08 GMT 2025

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

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

Back to the top