From ef13dce84078d4b8d5fc47e2d5ff2e8f61886ed6 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Tue, 25 Jan 2011 13:51:26 +0300 Subject: [PATCH] Do not wait for frame to be activated for project-level notifications --- .../intellij/notification/Notifications.java | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/platform/platform-api/src/com/intellij/notification/Notifications.java b/platform/platform-api/src/com/intellij/notification/Notifications.java index 2f71c57a27a5..e056d4ee7f37 100644 --- a/platform/platform-api/src/com/intellij/notification/Notifications.java +++ b/platform/platform-api/src/com/intellij/notification/Notifications.java @@ -49,19 +49,36 @@ public interface Notifications { } public static void notify(@NotNull final Notification notification, @NotNull final NotificationDisplayType defaultDisplayType, @Nullable final Project project) { - if (project != null && !project.isInitialized()) { - StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { - public void run() { - project.getMessageBus().syncPublisher(TOPIC).notify(notification, defaultDisplayType); - } - }); + if (project != null && !project.isDisposed()) { + if (!project.isInitialized()) { + StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { + public void run() { + project.getMessageBus().syncPublisher(TOPIC).notify(notification, defaultDisplayType); + } + }); + } + else { + if (EventQueue.isDispatchThread()) { + project.getMessageBus().syncPublisher(TOPIC).notify(notification, defaultDisplayType); + } + else { + //noinspection SSBasedInspection + SwingUtilities.invokeLater(new Runnable() { + public void run() { + project.getMessageBus().syncPublisher(TOPIC).notify(notification, defaultDisplayType); + } + }); + } + } + return; } FrameStateManager.getInstance().getApplicationActive().doWhenDone(new Runnable() { @Override public void run() { - final MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : (project.isDisposed() ? null : project.getMessageBus()); + final MessageBus bus = + project == null ? ApplicationManager.getApplication().getMessageBus() : (project.isDisposed() ? null : project.getMessageBus()); if (bus != null) { if (EventQueue.isDispatchThread()) { bus.syncPublisher(TOPIC).notify(notification, defaultDisplayType);