How to get current Project? (the project with user focus)

Hello,

Is there an API to get the project in the current frame? In other words, if several projects are open in different frames, I only want the project that has focus.

ProjectManager.getOpenProjects() gets me all open projects.

Thanks!

3 comments
Comment actions Permalink

Hello JoeNearBoston,

Is there an API to get the project in the current frame? In other
words, if several projects are open in different frames, I only want
the project that has focus.

ProjectManager.getOpenProjects() gets me all open projects.


Where are you calling this method from? If you have an action, you can get
the project with AnActionEvent.getData(DataKeys.PROJECT).

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Hi, I think it's possible doing that in such way:

DataContext dataContext = anActionEvent.getDataContext();
Project project = DataKeys.PROJECT.getData(dataContext);

anActionEvent is com.intellij.openapi.actionSystem.AnActionEvent. In my case when I invoke some popup menu in the current frame, then I receive an anActionEvent and I can get the current project.

0
Comment actions Permalink

Thanks, that will work.

0

Please sign in to leave a comment.