From 13fedab45a2c00fe243ac807a46e68316bbe259f Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Sun, 28 Apr 2024 12:15:10 +0200 Subject: [PATCH] [java] IDEA-352622 JarRepositoryManager requests service from class init GitOrigin-RevId: 858f0dce9a5c7c277b35d22afee0ce5ef748d233 --- .../com/intellij/jarRepository/JarRepositoryManager.java | 6 ++++-- .../intellij/jarRepository/RepositoryLibrarySynchronizer.kt | 2 +- .../com/intellij/jarRepository/RepositoryLibraryUtils.kt | 2 +- .../jarRepository/settings/repositoryLibrariesReloader.kt | 3 +-- .../library/RepositoryLibraryResolveErrorNotification.java | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java index e2c9346f7fed..d5f9d4af7d55 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java +++ b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java @@ -93,7 +93,9 @@ public final class JarRepositoryManager { // used in integration tests private static final boolean DO_REFRESH = SystemProperties.getBooleanProperty("idea.do.refresh.after.jps.library.downloaded", true); - public final static NotificationGroup GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Repository"); + public static @NotNull NotificationGroup getNotificationGroup() { + return NotificationGroupManager.getInstance().getNotificationGroup("Repository"); + } public static boolean hasRunningTasks() { return ourTasksInProgress.get() > 0; // todo: count tasks on per-project basis? @@ -383,7 +385,7 @@ public final class JarRepositoryManager { sb.append(root.getFile().getName()); } @NlsSafe final String content = sb.toString(); - Notifications.Bus.notify(GROUP.createNotification(title, content, NotificationType.INFORMATION), project); + Notifications.Bus.notify(getNotificationGroup().createNotification(title, content, NotificationType.INFORMATION), project); } public static void searchArtifacts(Project project, diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt index 497836c5a348..2720b67fd455 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt @@ -141,7 +141,7 @@ internal fun removeDuplicatedUrlsFromRepositoryLibraries(project: Project) { else { "${validLibraries.size} libraries" } - Notifications.Bus.notify(JarRepositoryManager.GROUP.createNotification( + Notifications.Bus.notify(JarRepositoryManager.getNotificationGroup().createNotification( JavaUiBundle.message("notification.title.repository.libraries.cleanup"), JavaUiBundle.message("notification.text.duplicated.urls.were.removed", libraryText, diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryUtils.kt b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryUtils.kt index 0f7668f600e0..85d29e75afa4 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryUtils.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibraryUtils.kt @@ -283,7 +283,7 @@ class RepositoryLibraryUtils(private val project: Project, private val cs: Corou if (isInfoNotificationDisabled && type == NotificationType.INFORMATION) return /* Reuse [JarRepositoryManager]'s notification group */ - val notification = JarRepositoryManager.GROUP.createNotification( + val notification = JarRepositoryManager.getNotificationGroup().createNotification( JavaUiBundle.message("repository.library.utils.library.update.title"), content, type diff --git a/java/idea-ui/src/com/intellij/jarRepository/settings/repositoryLibrariesReloader.kt b/java/idea-ui/src/com/intellij/jarRepository/settings/repositoryLibrariesReloader.kt index bda587e281a9..a0ea16d8d1b3 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/settings/repositoryLibrariesReloader.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/settings/repositoryLibrariesReloader.kt @@ -21,10 +21,9 @@ internal fun reloadAllRepositoryLibraries(project: Project) { .toList() .collectResults() .onSuccess { - Notifications.Bus.notify(JarRepositoryManager.GROUP.createNotification( + Notifications.Bus.notify(JarRepositoryManager.getNotificationGroup().createNotification( JavaUiBundle.message("notification.title.repository.library.synchronization"), JavaUiBundle.message("notification.content.libraries.reloaded", it.size), NotificationType.INFORMATION), project) } - } \ No newline at end of file diff --git a/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryResolveErrorNotification.java b/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryResolveErrorNotification.java index b1a32990f120..b7bee6328cc7 100644 --- a/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryResolveErrorNotification.java +++ b/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryLibraryResolveErrorNotification.java @@ -21,7 +21,7 @@ class RepositoryLibraryResolveErrorNotification extends Notification { RepositoryLibraryResolveErrorNotification() { super( - JarRepositoryManager.GROUP.getDisplayId(), + JarRepositoryManager.getNotificationGroup().getDisplayId(), JavaUiBundle.message("notification.title.repository.library.synchronization"), "", NotificationType.ERROR