From 398a58faea7a5f30f3192159196a54d4d89bf7ec Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Sun, 9 Jan 2022 14:50:21 +0100 Subject: [PATCH] i18n and normalize names for notification groups in Java plugin (IDEA-256552) GitOrigin-RevId: 13f4bce1a4753d5575fe1404115832c0abb5602c --- .../messages/JavaCompilerBundle.properties | 2 +- .../messages/JavaUiBundle.properties | 1 + .../SetupJavaProjectFromSourcesActivity.kt | 2 +- .../jarRepository/JarRepositoryManager.java | 8 +++---- .../RepositoryLibrarySynchronizer.java | 4 ++-- .../settings/repositoryLibrariesReloader.kt | 10 ++++---- .../JavadocQuarantineStatusCleaner.java | 5 ++-- .../maven/utils/library/RepositoryUtils.java | 8 ++++--- java/java-impl/src/META-INF/JavaPlugin.xml | 24 ++++++++++--------- .../java/AcceptedLanguageLevelsSettings.java | 8 ++++--- .../intellij/unscramble/ThreadDumpPanel.java | 3 ++- .../resources/messages/JavaBundle.properties | 8 +++++++ 12 files changed, 49 insertions(+), 34 deletions(-) diff --git a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties index 1a6bbb8391ca..b193a7e0783d 100644 --- a/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties +++ b/java/compiler/openapi/resources/messages/JavaCompilerBundle.properties @@ -320,7 +320,7 @@ element.with.manifest.button.use.existing.manifest=&Use Existing Manifest... element.with.manifest.label.meta.inf.manifest.mf.file.not.found=META-INF/MANIFEST.MF file not found element.with.manifest.label.manifest.file=Manifest &File: -notification.group.title.jps.cannot.start.compiler=Cannot start compilation +notification.group.title.jps.cannot.start.compiler=Build failed to start notification.action.jps.open.configuration.dialog=Configure... notification.title.jps.cannot.start.compiler=Cannot start compiler notification.title.cpu.snapshot.build.has.been.captured=Build CPU snapshot has been captured diff --git a/java/idea-ui/resources/messages/JavaUiBundle.properties b/java/idea-ui/resources/messages/JavaUiBundle.properties index e0c09b2aa65c..2a1a50273ef4 100644 --- a/java/idea-ui/resources/messages/JavaUiBundle.properties +++ b/java/idea-ui/resources/messages/JavaUiBundle.properties @@ -645,3 +645,4 @@ label.select.project.type.to.configure=Select project type to configure language.level.combo.lts.versions=LTS Versions language.level.combo.other.versions=Other Versions project.or.module.jdk.misconfigured={0, choice, 0#Project|1#Module} JDK is misconfigured +notification.group.build.script.found=Build script found diff --git a/java/idea-ui/src/com/intellij/ide/SetupJavaProjectFromSourcesActivity.kt b/java/idea-ui/src/com/intellij/ide/SetupJavaProjectFromSourcesActivity.kt index bdd921fbe31e..7d6826b99633 100644 --- a/java/idea-ui/src/com/intellij/ide/SetupJavaProjectFromSourcesActivity.kt +++ b/java/idea-ui/src/com/intellij/ide/SetupJavaProjectFromSourcesActivity.kt @@ -37,7 +37,7 @@ import com.intellij.util.SystemProperties import java.io.File import javax.swing.event.HyperlinkEvent -private val NOTIFICATION_GROUP = NotificationGroup("Build Script Found", NotificationDisplayType.STICKY_BALLOON, true) +private val NOTIFICATION_GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Build Script Found") private val SETUP_JAVA_PROJECT_IS_DISABLED = SystemProperties.getBooleanProperty("idea.java.project.setup.disabled", false) private const val SCAN_DEPTH_LIMIT = 5 diff --git a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java index 937cfaef92e2..b76295cf61da 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java +++ b/java/idea-ui/src/com/intellij/jarRepository/JarRepositoryManager.java @@ -6,9 +6,7 @@ import com.intellij.core.JavaPsiBundle; import com.intellij.execution.process.ProcessIOExecutorService; import com.intellij.ide.JavaUiBundle; import com.intellij.jarRepository.services.MavenRepositoryServicesManager; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationType; -import com.intellij.notification.Notifications; +import com.intellij.notification.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.components.PathMacroManager; @@ -88,6 +86,8 @@ public final class JarRepositoryManager { ProcessIOExecutorService.INSTANCE); } + public static NotificationGroup GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Repository"); + public static boolean hasRunningTasks() { return ourTasksInProgress.get() > 0; // todo: count tasks on per-project basis? } @@ -341,7 +341,7 @@ public final class JarRepositoryManager { sb.append(root.getFile().getName()); } @NlsSafe final String content = sb.toString(); - Notifications.Bus.notify(new Notification("Repository", title, content, NotificationType.INFORMATION), project); + Notifications.Bus.notify(GROUP.createNotification(title, content, NotificationType.INFORMATION), project); } public static void searchArtifacts(Project project, diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.java b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.java index 891230115107..afc1c56f4e56 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.java +++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.java @@ -108,8 +108,8 @@ public class RepositoryLibrarySynchronizer implements StartupActivity.DumbAware String libraryText = validLibraries.size() == 1 ? "'" + validLibraries.iterator().next().getPresentableName() + "' library" : validLibraries.size() + " libraries"; - Notifications.Bus.notify(new Notification( - "Repository", JavaUiBundle.message("notification.title.repository.libraries.cleanup"), + Notifications.Bus.notify(JarRepositoryManager.GROUP.createNotification( + JavaUiBundle.message("notification.title.repository.libraries.cleanup"), JavaUiBundle.message("notification.text.duplicated.urls.were.removed", libraryText, ApplicationNamesInfo.getInstance().getFullProductName()), NotificationType.INFORMATION ), project); 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 3a93210824d8..e7b74c4ba242 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/settings/repositoryLibrariesReloader.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/settings/repositoryLibrariesReloader.kt @@ -2,8 +2,8 @@ package com.intellij.jarRepository.settings import com.intellij.ide.JavaUiBundle +import com.intellij.jarRepository.JarRepositoryManager import com.intellij.jarRepository.RepositoryLibrarySynchronizer -import com.intellij.notification.Notification import com.intellij.notification.NotificationType import com.intellij.notification.Notifications import com.intellij.openapi.project.Project @@ -20,10 +20,10 @@ fun reloadAllRepositoryLibraries(project: Project) { .map { RepositoryUtils.reloadDependencies(project, it) } .collectResults() .onSuccess { - Notifications.Bus.notify(Notification("Repository", - JavaUiBundle.message("notification.title.repository.library.synchronization"), - JavaUiBundle.message("notification.content.libraries.reloaded", it.size), - NotificationType.INFORMATION), project) + Notifications.Bus.notify(JarRepositoryManager.GROUP.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/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavadocQuarantineStatusCleaner.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavadocQuarantineStatusCleaner.java index 17b1cca37e02..388fdb2bdb85 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavadocQuarantineStatusCleaner.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/JavadocQuarantineStatusCleaner.java @@ -2,8 +2,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.ide.JavaUiBundle; -import com.intellij.notification.Notification; -import com.intellij.notification.NotificationGroup; +import com.intellij.notification.NotificationGroupManager; import com.intellij.notification.NotificationType; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; @@ -89,7 +88,7 @@ public final class JavadocQuarantineStatusCleaner { LOG.warn(error); String title = JavaUiBundle.message("quarantine.cleaner"); String message = JavaUiBundle.message("quarantine.error.message", error.getMessage()); - new Notification(NotificationGroup.createIdWithTitle("Quarantine Cleaner", title), title, message, NotificationType.WARNING) + NotificationGroupManager.getInstance().getNotificationGroup("Quarantine Cleaner").createNotification(title, message, NotificationType.WARNING) .notify(null); } }.queue(); diff --git a/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryUtils.java b/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryUtils.java index 1052849edbf3..af4a64cd652d 100644 --- a/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryUtils.java +++ b/java/idea-ui/src/org/jetbrains/idea/maven/utils/library/RepositoryUtils.java @@ -98,9 +98,11 @@ public final class RepositoryUtils { roots == null || roots.isEmpty() ? () -> { String message = JavaUiBundle.message("notification.content.no.files.were.downloaded", properties.getMavenId()); - Notifications.Bus.notify(new Notification("Repository", JavaUiBundle.message( - "notification.title.repository.library.synchronization"), - message, NotificationType.ERROR), project); + Notifications.Bus.notify( + JarRepositoryManager.GROUP.createNotification( + JavaUiBundle.message("notification.title.repository.library.synchronization"), + message, NotificationType.ERROR), + project); promise.setError(message); } : () -> { diff --git a/java/java-impl/src/META-INF/JavaPlugin.xml b/java/java-impl/src/META-INF/JavaPlugin.xml index b842f4a5322b..a29f9659cb74 100644 --- a/java/java-impl/src/META-INF/JavaPlugin.xml +++ b/java/java-impl/src/META-INF/JavaPlugin.xml @@ -283,7 +283,9 @@ key="notification.group.title.jps.cannot.start.compiler" /> + displayType="BALLOON" + bundle="messages.JavaBundle" + key="notification.group.jdk.resolve.problems"/> @@ -2206,17 +2208,17 @@ - - - + + + - - - - - - - + + + + + + + diff --git a/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java b/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java index a2960eb6db04..3312efb27769 100644 --- a/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java +++ b/java/java-impl/src/com/intellij/pom/java/AcceptedLanguageLevelsSettings.java @@ -45,10 +45,12 @@ import java.util.TreeSet; ) public class AcceptedLanguageLevelsSettings implements PersistentStateComponent, StartupActivity { private static final NotificationGroup NOTIFICATION_GROUP = - new NotificationGroup("Accepted language levels", NotificationDisplayType.STICKY_BALLOON, true); + NotificationGroupManager.getInstance().getNotificationGroup("Accepted language levels"); - private static final NotificationGroup PREVIEW_NOTIFICATION_GROUP = NotificationGroup.balloonGroup("Java Preview Features"); - private static final String IGNORE_USED_PREVIEW_FEATURES = "ignore.preview.features.used"; + private static final NotificationGroup PREVIEW_NOTIFICATION_GROUP = + NotificationGroupManager.getInstance().getNotificationGroup("Java Preview Features"); + + private static final String IGNORE_USED_PREVIEW_FEATURES = "ignore.preview.features.used"; @XCollection(propertyElementName = "explicitly-accepted", elementName = "name", valueAttributeName = "") public List acceptedNames = new ArrayList<>(); diff --git a/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java b/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java index 3843fcdb4d79..cbe6de92ffeb 100644 --- a/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java +++ b/java/java-impl/src/com/intellij/unscramble/ThreadDumpPanel.java @@ -10,6 +10,7 @@ import com.intellij.ide.ExporterToTextFile; import com.intellij.ide.ui.UISettings; import com.intellij.java.JavaBundle; import com.intellij.notification.NotificationGroup; +import com.intellij.notification.NotificationGroupManager; import com.intellij.openapi.actionSystem.*; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.colors.EditorColors; @@ -331,7 +332,7 @@ public final class ThreadDumpPanel extends JPanel implements DataProvider { } } private static final class CopyToClipboardAction extends DumbAwareAction { - private static final NotificationGroup GROUP = NotificationGroup.toolWindowGroup("Analyze thread dump", ToolWindowId.RUN, false); + private static final NotificationGroup GROUP = NotificationGroupManager.getInstance().getNotificationGroup("Analyze thread dump"); private final List myThreadDump; private final Project myProject; diff --git a/java/openapi/resources/messages/JavaBundle.properties b/java/openapi/resources/messages/JavaBundle.properties index 66289cd51a37..6e21d82a3479 100644 --- a/java/openapi/resources/messages/JavaBundle.properties +++ b/java/openapi/resources/messages/JavaBundle.properties @@ -1707,3 +1707,11 @@ dialog.title.move.directory=Move Directory progress.title.checking.if.class.exists=Check target class ''{0}'' exists quickfix.find.cause.description=Attempts to highlight code elements that resulted in this warning and explain how exactly they contribute. completion.generate.via.wizard=(generate via wizard) +notification.group.jdk.resolve.problems=Failed to resolve JDK +notification.group.jshell=JShell problem occurred +notification.group.repository=JAR files synchronized with repository +notification.group.source.searcher=Failed to find sources for JAR file +notification.group.language.level=Preview Java language level requires accepting license +notification.group.preview.features=Preview Java language level may be discontinued +notification.group.redundant.exports=Redundant exports/opens can be removed +notification.group.setup.sdk=JDK configured