Get last focused project window


I have developed a small plugin, Go To Project,

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

Comment actions Permalink

You could try to add a java.awt.event.WindowFocusListener to the projects JFrame. Here's how to get the JFrame:
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.



Please sign in to leave a comment.