[remote dev] restart the frontend process only calling 'restart' (IJPL-165387)

There is no need to ask about stopping the backend process when the frontend is restarting. So here a new method ApplicationListener.canRestartApplication is introduced, and it's overriden in the frontend process to suppress the confirmation before restarting.


(cherry picked from commit d68298df0513978a046829ec87fa1134ceefa1ca)

IJ-CR-150411

GitOrigin-RevId: eab235b69ca2252fe0170870a8f856f2a259407b
This commit is contained in:
Nikolay Chashnikov
2024-11-27 17:31:54 +01:00
committed by intellij-monorepo-bot
parent e8b1cfd99a
commit 1fddf514bb
3 changed files with 13 additions and 3 deletions

View File

@@ -1170,6 +1170,7 @@ com.intellij.openapi.application.ApplicationListener
- applicationExiting():V
- beforeWriteActionStart(java.lang.Object):V
- canExitApplication():Z
- canRestartApplication():Z
- writeActionFinished(java.lang.Object):V
- writeActionStarted(java.lang.Object):V
c:com.intellij.openapi.application.ApplicationManager

View File

@@ -17,6 +17,14 @@ public interface ApplicationListener extends EventListener {
return true;
}
/**
* This method is called before restarting an application (e.g., after installing a plugin).
* Return {@code true} if the application can be restarted, or {@code false} to cancel restarting.
*/
default boolean canRestartApplication() {
return canExitApplication();
}
/**
* @deprecated Use {@link com.intellij.ide.AppLifecycleListener#appWillBeClosed(boolean)}
*/

View File

@@ -587,7 +587,7 @@ public final class ApplicationImpl extends ClientAwareComponentManager implement
AppLifecycleListener lifecycleListener = getMessageBus().syncPublisher(AppLifecycleListener.TOPIC);
lifecycleListener.appClosing();
if (!force && !canExit()) {
if (!force && !canExit(restart)) {
return null;
}
@@ -810,9 +810,10 @@ public final class ApplicationImpl extends ClientAwareComponentManager implement
return exitConfirmed;
}
private boolean canExit() {
private boolean canExit(boolean restart) {
for (ApplicationListener applicationListener : myDispatcher.getListeners()) {
if (!applicationListener.canExitApplication()) {
if (restart && !applicationListener.canRestartApplication()
|| !restart && !applicationListener.canExitApplication()) {
return false;
}
}