[ui] postponing system health notifications until app UI is ready (IDEA-239832)

GitOrigin-RevId: 1b1e36ba898c9e017197418754f43ef020c98ff1
This commit is contained in:
Roman Shevchenko
2020-05-04 20:49:32 +00:00
committed by intellij-monorepo-bot
parent 026e917bb9
commit 02a0da5198
2 changed files with 29 additions and 4 deletions
@@ -26,12 +26,21 @@ public interface AppLifecycleListener {
/**
* Called before an application frame is shown.
*/
default void appFrameCreated(@NotNull List<String> commandLineArgs) { }
default void appFrameCreated(@NotNull List<String> commandLineArgs) {
appUiReady();
}
/**
* Called when the welcome screen is displayed (not called if the application opens a project).
*/
default void welcomeScreenDisplayed() { }
default void welcomeScreenDisplayed() {
appUiReady();
}
/**
* Called when either a welcome screen or a project frame is displayed.
*/
default void appUiReady() { }
/**
* Called after an application frame is shown.
@@ -1,6 +1,7 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.ide;
import com.intellij.diagnostic.LoadingState;
import com.intellij.diagnostic.VMOptions;
import com.intellij.execution.process.UnixProcessManager;
import com.intellij.ide.actions.EditCustomVmOptionsAction;
@@ -15,6 +16,7 @@ import com.intellij.openapi.application.*;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Ref;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
@@ -23,6 +25,7 @@ import com.intellij.util.SystemProperties;
import com.intellij.util.TimeoutUtil;
import com.intellij.util.concurrency.AppExecutorUtil;
import com.intellij.util.lang.JavaVersion;
import com.intellij.util.messages.MessageBusConnection;
import com.sun.jna.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -30,6 +33,7 @@ import org.jetbrains.annotations.PropertyKey;
import javax.swing.*;
import java.io.File;
import java.util.List;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -158,7 +162,7 @@ final class SystemHealthMonitor extends PreloadingActivity {
@Nullable NotificationAction action,
Object... params) {
boolean ignored = PropertiesComponent.getInstance().isValueSet("ignore." + key);
LOG.info("issue detected: " + key + (ignored ? " (ignored)" : ""));
LOG.warn("issue detected: " + key + (ignored ? " (ignored)" : ""));
if (ignored) return;
Notification notification = new MyNotification(IdeBundle.message(key, params));
@@ -174,7 +178,19 @@ final class SystemHealthMonitor extends PreloadingActivity {
});
notification.setImportant(true);
ApplicationManager.getApplication().invokeLater(() -> Notifications.Bus.notify(notification));
if (LoadingState.APP_STARTED.isOccurred()) {
ApplicationManager.getApplication().invokeLater(() -> Notifications.Bus.notify(notification));
}
else {
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
@Override
public void appUiReady() {
Notifications.Bus.notify(notification);
connection.disconnect();
}
});
}
}
private static final class MyNotification extends Notification implements NotificationFullContent {