Forum Controls
Spotlight Features
Replies: 2 - Pages: 1  
  Click to reply to this thread Reply

How to get "current project"?

At 10:39 AM on Jul 27, 2006, Lonnie Lewis Javalobby Newcomers wrote:

Hello, all,
I'm a newbie to plugin development so sorry if this is a silly question, but after searching and searching, I still haven't found the answer. How do I get the "current project"? That is, the project that I have clicked on when running my plugin? In my plugin, I'm generating some files, but I need to get the appropriate IProject from the workspace. How do I do this?

Thanks.
  Click to reply to this thread Reply
1. At 11:44 AM on Jul 27, 2006, Alex Blewitt DeveloperZone Top 100 wrote:

Re: How to get "current project"?

The selection should contain what project it's associated with.

http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html
http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/jface/viewers/ISelection.html

Cast it to an IStructedSelection, then adapt it to an IResource, then use getProject() on that.

Alex.
  Click to reply to this thread Reply
2. At 12:41 PM on Jul 27, 2006, Lonnie Lewis Javalobby Newcomers wrote:

Re: How to get "current project"?

Great! Thank you very much for the quick response. I appreciate it.

thread.rss_message