Project events

Hello,

I would like to know how to perform an action when closing a project
And also, how to perform an action when a person moves from an open project to another open project

Thanks for your help

1
6 comments
Avatar
Permanently deleted user

Register a ProjectManagerListener and/or ProjectLifecycleListener.  Note that it is possible to configure IDEA to have multiple projects open simultaneously, so "moving from one project to another" may require you to watch for focus events using a WindowFocusListener subclass.

0
Avatar
Permanently deleted user

Hello,

Thanks for your help, however, I don't know how to verify that the open window is that of an open project, do you have any idea how to proceed?

Thank you

0
Avatar
Permanently deleted user

OK.. Instead of using the AWT focus listener, take a look at FocusChangeListener(Editor editor).  editor.getProject() will give you the project associated with the editor.  You will have to register the listener with EditorEventMulticaster.addFocusChangeListener(), which you get from EditorFactory.getEventMulticaster().

1
Avatar
Permanently deleted user

Hello,

I can't find the addFocusChangeListener() method in the EditorEventMulticaster interface (see https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/editor/event/EditorEventMulticaster.java), was I wrong somewhere?

Thanks

2
Avatar
Permanently deleted user

Sorry, EditorEventMulticasterEx: 

https://github.com/JetBrains/intellij-community/blob/02ded51e171b89c6a1e05ab7725a4634e9c01873/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorEventMulticasterEx.java#L31
1
Avatar
Permanently deleted user

Hello,

Thanks for your help!

Sincerely

0

Please sign in to leave a comment.