From c7b8a4c6ab6c1024a8dc07590a75ac9c1235e76b Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Mon, 11 Nov 2024 15:41:43 +0100 Subject: [PATCH] IJPL-166332 Avoid showing repeated notifications about Floating License Server connectivity problem (cherry picked from commit 1b237a3de797b3061428b2ce762cd5204807d90b) IJ-CR-149110 GitOrigin-RevId: 6f781b89ea1abb7440cd5630afa3b71622761918 --- platform/ide-core/api-dump-unreviewed.txt | 2 ++ .../src/com/intellij/notification/Notification.java | 11 +++++++++++ .../notification/impl/NotificationsToolWindow.kt | 8 ++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/platform/ide-core/api-dump-unreviewed.txt b/platform/ide-core/api-dump-unreviewed.txt index c1d62b8bfa62..f57ccd1149da 100644 --- a/platform/ide-core/api-dump-unreviewed.txt +++ b/platform/ide-core/api-dump-unreviewed.txt @@ -689,6 +689,7 @@ c:com.intellij.notification.Notification - isExpired():Z - isImportant():Z - isImportantSuggestion():Z +- isRemoveWhenExpired():Z - isSuggestionType():Z - notify(com.intellij.openapi.project.Project):V - setBalloon(com.intellij.openapi.ui.popup.Balloon):V @@ -703,6 +704,7 @@ c:com.intellij.notification.Notification - setImportantSuggestion(Z):com.intellij.notification.Notification - setListener(com.intellij.notification.NotificationListener):com.intellij.notification.Notification - setRemindLaterHandlerId(java.lang.String):com.intellij.notification.Notification +- setRemoveWhenExpired(Z):com.intellij.notification.Notification - setSubtitle(java.lang.String):com.intellij.notification.Notification - setSuggestionType(Z):com.intellij.notification.Notification - setTitle(java.lang.String):com.intellij.notification.Notification diff --git a/platform/ide-core/src/com/intellij/notification/Notification.java b/platform/ide-core/src/com/intellij/notification/Notification.java index 6906a8cd12b2..8ede84218af4 100644 --- a/platform/ide-core/src/com/intellij/notification/Notification.java +++ b/platform/ide-core/src/com/intellij/notification/Notification.java @@ -71,6 +71,7 @@ public class Notification { private @Nullable Boolean myImportant; private boolean mySuggestionType; private boolean myImportantSuggestion; + private boolean myRemoveWhenExpired; private String myDoNotAskId; private @Nls String myDoNotAskDisplayName; private boolean myIsShowingPopupSuppressed; @@ -121,6 +122,16 @@ public class Notification { return this; } + public boolean isRemoveWhenExpired() { + return myRemoveWhenExpired; + } + + @Contract(value = "_ -> this", mutates = "this") + public @NotNull Notification setRemoveWhenExpired(boolean removeWhenExpired) { + myRemoveWhenExpired = removeWhenExpired; + return this; + } + /** * Returns the time (in milliseconds since Jan 1, 1970) when the notification was created. */ diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsToolWindow.kt b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsToolWindow.kt index 68e81166b12a..39e1ee572605 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/NotificationsToolWindow.kt +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationsToolWindow.kt @@ -702,7 +702,7 @@ private class NotificationGroupComponent(private val myMainContent: Notification for (i in 0 until count) { val component = myList.getComponent(i) as NotificationComponent if (component.myNotificationWrapper.notification === notification) { - if (notification.isSuggestionType) { + if (notification.isSuggestionType || notification.isRemoveWhenExpired) { component.removeFromParent() myList.remove(i) } @@ -1668,7 +1668,11 @@ internal class ApplicationNotificationModel { fun getNotifications(project: Project?): List { synchronized(myLock) { if (project == null) { - return ArrayList(myNotifications) + val result = ArrayList(myNotifications) + for ((_, eachModel) in myProjectToModel.entries) { + result.addAll(eachModel.getNotifications(emptyList())) + } + return result } val model = myProjectToModel[project] if (model == null) {