Listen for "IDEA is closing" event and terminate some processes

our IDEA-based application starts some external processes (an external JVM with debugger, specifically).
then I get "process... is running. disconnect from the process?" when I'm trying to close IDEA.

how can I add a listener for "IDEA is closing" event so that I can correctly terminate our external process?

5 comments
Comment actions Permalink

Hello Alexey,

You can use ProjectManagerListener.canCloseProject() method to shut down
your processes.

our IDEA-based application starts some external processes (an external
JVM with debugger, specifically).

then I get "process... is running. disconnect from the process?" when
I'm trying to close IDEA.

how can I add a listener for "IDEA is closing" event so that I can
correctly terminate our external process?


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


0
Comment actions Permalink

unfortunately, I see both projectClosing() and canCloseProject() methods are only invoked AFTER "Process ... is running" dialog is shown and closed (see the screenshot). the goal is to avoid showing that dialog to user.



Attachment(s):
process_running.PNG
0
Comment actions Permalink

I guess I need to add the project listener at some earlier stage of the application startup...

0
Comment actions Permalink

ok, I added the project listener registration to the beginning of my method, which creates the tool window. this solves the problem. now canCloseProject() is called before that IDEA dialog can be shown, so I can properly terminate the debug process.

0
Comment actions Permalink

Hello Alexey,

This depends on the order of listeners registration.

unfortunately, I see both projectClosing() and canCloseProject()
methods are only invoked AFTER "Process ... is running" dialog is
shown and closed (see the screenshot). the goal is to avoid showing
that dialog to user.


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


0

Please sign in to leave a comment.