Saner set of notification groups for IDE and plugin updates

GitOrigin-RevId: d8d6dc697d4cfc769a406f24446db4ed9577d2cc
This commit is contained in:
Dmitry Jemerov
2022-01-20 18:44:57 +00:00
committed by intellij-monorepo-bot
parent 46f980986e
commit 866b0c8409
11 changed files with 33 additions and 26 deletions
@@ -1815,8 +1815,10 @@ notification.group.missing.keymap=Missing keymap
notification.group.plugins.suggestion=Plugin suggestions available
notification.content.keymap.successfully.activated=Keymap {0} successfully activated
notification.content.keymap.successfully.installed=Keymap {0} successfully installed
notification.group.ide.and.plugin.updates=IDE and plugin updates
notification.group.plugin.updates=Plugin updates
notification.group.ide.and.plugin.updates=IDE and plugin updates available
notification.group.plugin.updates=Plugins installed or updated
notification.group.ide.update.results=IDE updates installed
notification.group.leftover.directories=Leftover IDE directories found
action.text.install.keymap=Install {0} Keymap
action.text.search.for.keymap=Search for {0} Keymap plugin
action.separator.file.templates=File templates
@@ -69,8 +69,9 @@ public class WhatsNewAction extends AnAction implements DumbAware {
String name = ApplicationNamesInfo.getInstance().getFullProductName();
String version = ApplicationInfo.getInstance().getShortVersion();
String content = IdeBundle.message("whats.new.notification.text", name, version, url);
UpdateChecker.getNotificationGroup()
UpdateChecker.getNotificationGroupForIdeUpdateResults()
.createNotification(notificationTitle, content, NotificationType.INFORMATION)
.setDisplayId("ide.whats.new")
.setListener(NotificationListener.URL_OPENING_LISTENER)
.notify(project);
}
@@ -25,7 +25,6 @@ import com.intellij.ide.ui.UIThemeProvider
import com.intellij.ide.util.TipDialog
import com.intellij.idea.IdeaLogger
import com.intellij.lang.Language
import com.intellij.notification.NotificationGroupManager
import com.intellij.notification.NotificationType
import com.intellij.notification.NotificationsManager
import com.intellij.notification.impl.NotificationsManagerImpl
@@ -56,6 +55,7 @@ import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.project.Project
import com.intellij.openapi.project.ProjectManager
import com.intellij.openapi.project.impl.ProjectManagerImpl
import com.intellij.openapi.updateSettings.impl.UpdateChecker
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.util.IconLoader
import com.intellij.openapi.util.NlsContexts
@@ -93,8 +93,6 @@ import kotlin.collections.component2
private val LOG = logger<DynamicPlugins>()
private val classloadersFromUnloadedPlugins = mutableMapOf<PluginId, WeakList<PluginClassLoader>>()
private const val GROUP_ID = "Dynamic plugin installation"
object DynamicPlugins {
@JvmStatic
@JvmOverloads
@@ -689,7 +687,7 @@ object DynamicPlugins {
}
internal fun notify(@NlsContexts.NotificationContent text: String, notificationType: NotificationType, vararg actions: AnAction) {
val notification = NotificationGroupManager.getInstance().getNotificationGroup(GROUP_ID).createNotification(text, notificationType)
val notification = UpdateChecker.getNotificationGroupForPluginUpdateResults().createNotification(text, notificationType)
for (action in actions) {
notification.addAction(action)
}
@@ -302,7 +302,7 @@ public final class PluginManagerMain {
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
String title = IdeBundle.message("updates.notification.title", ApplicationNamesInfo.getInstance().getFullProductName());
String action = IdeBundle.message("ide.restart.required.notification", app.isRestartCapable() ? 1 : 0);
UpdateChecker.getNotificationGroup()
UpdateChecker.getNotificationGroupForPluginUpdateResults()
.createNotification(title, NotificationType.INFORMATION)
.setDisplayId("plugins.updated.suggest.restart")
.addAction(new NotificationAction(action) {
@@ -17,6 +17,7 @@ import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.ui.popup.Balloon;
import com.intellij.openapi.updateSettings.impl.UpdateChecker;
import com.intellij.openapi.util.Condition;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nls;
@@ -87,8 +88,7 @@ public final class PluginBooleanOptionDescriptor extends BooleanOptionDescriptio
@NotNull @Nls String content,
boolean enabled) {
String title = IdeBundle.message(enabled ? "plugins.auto.enabled.notification.title" : "plugins.auto.disabled.notification.title");
Notification switchNotification = NotificationGroupManager.getInstance()
.getNotificationGroup("Plugin Update Results")
Notification switchNotification = UpdateChecker.getNotificationGroupForPluginUpdateResults()
.createNotification(content, NotificationType.INFORMATION)
.setDisplayId("plugin.auto.switch")
.setTitle(title)
@@ -180,8 +180,7 @@ public final class PluginBooleanOptionDescriptor extends BooleanOptionDescriptio
return;
}
Notification newNotification = NotificationGroupManager.getInstance()
.getNotificationGroup("IDE and Plugin Updates")
Notification newNotification = UpdateChecker.getNotificationGroupForIdeUpdateResults()
.createNotification(
IdeBundle.message("plugins.changed.notification.content", ApplicationNamesInfo.getInstance().getFullProductName()),
NotificationType.INFORMATION)
@@ -10,6 +10,7 @@ import com.intellij.internal.statistic.eventLog.events.EventId;
import com.intellij.internal.statistic.eventLog.events.EventId1;
import com.intellij.internal.statistic.eventLog.events.EventId2;
import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector;
import com.intellij.notification.NotificationGroupManager;
import com.intellij.notification.NotificationType;
import com.intellij.openapi.application.ConfigImportHelper.ConfigDirsSearchResult;
import com.intellij.openapi.application.ex.ApplicationEx;
@@ -105,13 +106,13 @@ public final class OldDirectoryCleaner {
Stats.completed(groups.size(), groups.stream().mapToLong(g -> g.size).sum());
}
else if (!groups.isEmpty()) {
UpdateChecker.getNotificationGroup()
NotificationGroupManager.getInstance().getNotificationGroup("notification.group.leftover.directories")
.createNotification(message("old.dirs.notification.text"), NotificationType.INFORMATION)
.addAction(createSimpleExpiring(message("old.dirs.notification.action"), () -> confirmAndDelete(project, groups)))
.notify(project);
}
else {
UpdateChecker.getNotificationGroup()
NotificationGroupManager.getInstance().getNotificationGroup("notification.group.leftover.directories")
.createNotification(message("old.dirs.not.found.notification.text"), NotificationType.INFORMATION)
.notify(project);
}
@@ -263,7 +264,7 @@ public final class OldDirectoryCleaner {
if (!errors.isEmpty()) {
@NlsSafe String content = String.join("<br>", errors);
UpdateChecker.getNotificationGroup()
NotificationGroupManager.getInstance().getNotificationGroup("notification.group.leftover.directories")
.createNotification(message("old.dirs.delete.error"), content, NotificationType.WARNING)
.addAction(ShowLogAction.notificationAction())
.notify(project);
@@ -206,7 +206,7 @@ final class PluginUpdateDialog extends DialogWrapper {
}
if (downloaders.size() == installedDescriptors.size()) {
UpdateChecker.getNotificationGroupForUpdateResults()
UpdateChecker.getNotificationGroupForPluginUpdateResults()
.createNotification(getUpdateNotificationMessage(installedDescriptors),
NotificationType.INFORMATION)
.setDisplayId("plugins.updated.without.restart")
@@ -101,9 +101,13 @@ object UpdateChecker {
NotificationGroupManager.getInstance().getNotificationGroup("IDE and Plugin Updates")
@JvmStatic
fun getNotificationGroupForUpdateResults(): NotificationGroup =
fun getNotificationGroupForPluginUpdateResults(): NotificationGroup =
NotificationGroupManager.getInstance().getNotificationGroup("Plugin Update Results")
@JvmStatic
fun getNotificationGroupForIdeUpdateResults(): NotificationGroup =
NotificationGroupManager.getInstance().getNotificationGroup("IDE Update Results")
/**
* For scheduled update checks.
*/
@@ -241,7 +241,7 @@ final class UpdateCheckerService {
String title = IdeBundle.message("updates.notification.title", ApplicationNamesInfo.getInstance().getFullProductName());
String message = blogPost == null ? IdeBundle.message("update.snap.message")
: IdeBundle.message("update.snap.message.with.blog.post", StringUtil.escapeXmlEntities(blogPost));
UpdateChecker.getNotificationGroup()
UpdateChecker.getNotificationGroupForIdeUpdateResults()
.createNotification(title, message, NotificationType.INFORMATION)
.setListener(NotificationListener.URL_OPENING_LISTENER)
.setDisplayId("ide.updated.by.snap")
@@ -291,7 +291,7 @@ final class UpdateCheckerService {
String title = IdeBundle.message("update.installed.notification.title");
String text = new HtmlBuilder().appendWithSeparators(HtmlChunk.text(", "), links).wrapWith("html").toString();
UpdateChecker.getNotificationGroupForUpdateResults()
UpdateChecker.getNotificationGroupForPluginUpdateResults()
.createNotification(title, text, NotificationType.INFORMATION)
.setListener((__, e) -> showPluginConfigurable(e, project)) // benign leak - notifications are disposed of on project close
.setDisplayId("plugins.updated.after.restart")
@@ -246,7 +246,7 @@ public final class UpdateInfoDialog extends AbstractUpdateDialog {
String title = IdeBundle.message("updates.notification.title", ApplicationNamesInfo.getInstance().getFullProductName());
String downloadUrl = UpdateInfoPanel.downloadUrl(myLoadedResult.getNewBuild(), myLoadedResult.getUpdatedChannel());
String message = IdeBundle.message("update.downloading.patch.error", e.getMessage(), downloadUrl);
UpdateChecker.getNotificationGroup()
UpdateChecker.getNotificationGroupForIdeUpdateResults()
.createNotification(title, message, NotificationType.ERROR)
.setListener(NotificationListener.URL_OPENING_LISTENER)
.setDisplayId("ide.patch.download.failed")
@@ -266,7 +266,7 @@ public final class UpdateInfoDialog extends AbstractUpdateDialog {
else {
String title = IdeBundle.message("updates.notification.title", ApplicationNamesInfo.getInstance().getFullProductName());
String message = IdeBundle.message("update.ready.message");
UpdateChecker.getNotificationGroup()
UpdateChecker.getNotificationGroupForIdeUpdateResults()
.createNotification(title, message, NotificationType.INFORMATION)
.setListener(new NotificationListener.Adapter() {
@Override
@@ -1240,17 +1240,19 @@
<notificationGroup id="Project Settings" displayType="BALLOON" bundle="messages.IdeBundle" key="notification.group.project.settings"/>
<notificationGroup id="Settings Error" displayType="BALLOON" bundle="messages.IdeBundle" key="notification.group.settings.error"/>
<notificationGroup id="Heap Dump Analysis" displayType="STICKY_BALLOON" bundle="messages.DiagnosticBundle" key="notification.group.heap.dump.analysis"/>
<notificationGroup id="Dynamic plugin installation" displayType="BALLOON" isLogByDefault="false"/>
<notificationGroup id="KeymapMissing" displayType="STICKY_BALLOON" bundle="messages.KeyMapBundle" key="notification.group.keymap.missing"/>
<notificationGroup id="KeymapInstalled" displayType="BALLOON" bundle="messages.KeyMapBundle" key="notification.group.keymap.installed"/>
<notificationGroup id="IDE and Plugin Updates" displayType="STICKY_BALLOON"
bundle="messages.IdeBundle" key="notification.group.ide.and.plugin.updates"
notificationIds="plugins.updated.suggest.restart;ide.update.installed;ide.update.channel.switched;
ide.updated.by.snap;ide.patch.download.failed;ide.update.suggest.restart;ide.update.available;
plugins.update.available;external.components.available;no.updates.available;plugins.updated.restart.required"/>
notificationIds="ide.update.channel.switched;ide.update.available;
plugins.update.available;external.components.available;no.updates.available;dart.sdk.update.available"/>
<notificationGroup id="IDE Update Results" displayType="STICKY_BALLOON" bundle="messages.IdeBundle" key="notification.group.ide.update.results"
notificationIds="ide.update.installed;ide.updated.by.snap;ide.patch.download.failed;ide.update.suggest.restart;ide.whats.new"/>
<notificationGroup id="Plugin Update Results" displayType="BALLOON"
bundle="messages.IdeBundle" key="notification.group.plugin.updates"
notificationIds="plugins.updated.without.restart;plugins.updated.after.restart;plugin.auto.switch"/>
notificationIds="plugins.updated.without.restart;plugins.updated.after.restart;plugin.auto.switch;plugins.updated.restart.required;
plugins.updated.suggest.restart"/>
<notificationGroup id="leftover.ide.directories" displayType="BALLOON" bundle="messages.IdeBundle" key="notification.group.leftover.directories"/>
<notificationGroup id="Built-in Server" displayType="STICKY_BALLOON"/>
<notificationGroup id="Password Safe" displayType="STICKY_BALLOON"/>
<notificationGroup id="Tutorials" displayType="BALLOON"/>