Get last focused project window
Hi,
I have developed a small plugin, Go To Project, http://plugins.jetbrains.com/plugin/7359?pr=idea.
This plugin just shows a speed search enabled popup of the ProjectWindowActions available.
Now I would like that the first selected project window is the one that was focused before the currently focused, to be consistent with Recent Files-dialog, but can't see how to get that information. On ProjectWindowAction there is a previous and next field, but the ordering is the openining order for the projects. And I can't find any listener to register to be notified when a project gets focus, because then I could just store that information, and use it for setting the order in the popup.
So how can this be archieved?
Best regards,
Erik Zielke
请先登录再写评论。
You could try to add a java.awt.event.WindowFocusListener to the projects JFrame. Here's how to get the JFrame:
com.intellij.openapi.wm.WindowManager.getInstance().getFrame(project)
You will probably want to implement a com.intellij.openapi.components.ProjectComponent for your plugin and add the listener in projectOpened(). Be sure to remove the listener again in projectClosed() or you will create a memory leak.
Bas
How does it differ from Frame Switcher?