/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
String SYSTEM_MESSAGES_GROUP_ID = "System Messages";
void notify(@NotNull Notification notification);
- void register(@NotNull final String groupDisplayName, @NotNull final NotificationDisplayType defaultDisplayType);
- void register(@NotNull final String groupDisplayName, @NotNull final NotificationDisplayType defaultDisplayType, boolean shouldLog);
- void register(@NotNull final String groupDisplayName, @NotNull final NotificationDisplayType defaultDisplayType, boolean shouldLog, boolean shouldReadAloud);
+
+ void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType);
+ void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType, boolean shouldLog);
+ void register(@NotNull String groupDisplayName, @NotNull NotificationDisplayType defaultDisplayType, boolean shouldLog, boolean shouldReadAloud);
@SuppressWarnings({"UtilityClassWithoutPrivateConstructor"})
class Bus {
/**
* Registration is OPTIONAL: BALLOON display type will be used by default.
- * @deprecated use {@link com.intellij.notification.NotificationGroup}
+ * @deprecated use {@link NotificationGroup}
*/
@SuppressWarnings("JavaDoc")
public static void register(@NotNull final String group_id, @NotNull final NotificationDisplayType defaultDisplayType) {
private static void doNotify(Notification notification, @Nullable Project project) {
if (project != null && !project.isDisposed()) {
project.getMessageBus().syncPublisher(TOPIC).notify(notification);
- } else {
+ }
+ else {
Application app = ApplicationManager.getApplication();
if (!app.isDisposed()) {
app.getMessageBus().syncPublisher(TOPIC).notify(notification);
}
if (needToRestart) {
- PluginManagerMain.notifyPluginsWereInstalled(list.size() == 1 ? list.get(0).getName() : null, null);
+ PluginManagerMain.notifyPluginsUpdated(null);
}
}
if (onSuccess != null) {
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
-import com.intellij.openapi.application.ex.ApplicationEx;
-import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.extensions.PluginId;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
chooseAndInstall(new InstalledPluginsTableModel(), new Consumer<Pair<File, IdeaPluginDescriptor>>() {
@Override
public void consume(Pair<File, IdeaPluginDescriptor> pair) {
- ApplicationEx app = ApplicationManagerEx.getApplicationEx();
- int response = app.isRestartCapable() ? PluginManagerConfigurable.showRestartIDEADialog() : PluginManagerConfigurable.showShutDownIDEADialog();
- if (response == Messages.YES) {
- app.restart(true);
- }
+ PluginManagerConfigurable.shutdownOrRestartApp();
}
}, null);
}
}
else if (myPlugins2Enable != null && ENABLE.equals(description)) {
disabledPlugins.removeAll(myPlugins2Enable);
- PluginManagerMain.notifyPluginsWereUpdated("Changes were applied", null);
+ PluginManagerMain.notifyPluginsUpdated(null);
}
try {
import com.intellij.ide.IdeBundle;
import com.intellij.openapi.application.ApplicationNamesInfo;
-import com.intellij.openapi.application.ex.ApplicationEx;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.options.BaseConfigurable;
import com.intellij.openapi.options.Configurable;
}
@Override
+ @NotNull
public String getHelpTopic() {
return ID;
}
}
if (myPluginManagerMain.isRequireShutdown()) {
- final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
-
- int response = app.isRestartCapable() ? showRestartIDEADialog() : showShutDownIDEADialog();
- if (response == Messages.YES) {
- app.restart(true);
+ if (showRestartDialog() == Messages.YES) {
+ ApplicationManagerEx.getApplicationEx().restart(true);
}
else {
myPluginManagerMain.ignoreChanges();
}
@Messages.YesNoResult
- public static int showShutDownIDEADialog() {
- return showShutDownIDEADialog(IdeBundle.message("title.plugins.changed"));
- }
-
- @Messages.YesNoResult
- private static int showShutDownIDEADialog(final String title) {
- String message = IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
- return Messages.showYesNoDialog(message, title, "Shut Down", POSTPONE, Messages.getQuestionIcon());
+ public static int showRestartDialog() {
+ return showRestartDialog(IdeBundle.message("update.notifications.title"));
}
@Messages.YesNoResult
- public static int showRestartIDEADialog() {
- return showRestartIDEADialog(IdeBundle.message("title.plugins.changed"));
+ public static int showRestartDialog(@NotNull String title) {
+ String action = IdeBundle.message(ApplicationManagerEx.getApplicationEx().isRestartCapable() ? "ide.restart.action" : "ide.shutdown.action");
+ String message = IdeBundle.message("ide.restart.required.message", action, ApplicationNamesInfo.getInstance().getFullProductName());
+ return Messages.showYesNoDialog(message, title, action, IdeBundle.message("ide.postpone.action"), Messages.getQuestionIcon());
}
- @Messages.YesNoResult
- private static int showRestartIDEADialog(final String title) {
- String message = IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName());
- return Messages.showYesNoDialog(message, title, "Restart", POSTPONE, Messages.getQuestionIcon());
+ public static void shutdownOrRestartApp() {
+ shutdownOrRestartApp(IdeBundle.message("update.notifications.title"));
}
- public static void shutdownOrRestartApp(String title) {
- final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
- int response = app.isRestartCapable() ? showRestartIDEADialog(title) : showShutDownIDEADialog(title);
- if (response == Messages.YES) app.restart(true);
+ public static void shutdownOrRestartApp(@NotNull String title) {
+ if (showRestartDialog(title) == Messages.YES) {
+ ApplicationManagerEx.getApplicationEx().restart(true);
+ }
}
@Override
@Override
@Nullable
public Runnable enableSearch(final String option) {
- return new Runnable(){
+ return new Runnable() {
@Override
public void run() {
- if (myPluginManagerMain == null) return;
- myPluginManagerMain.filter(option);
+ if (myPluginManagerMain != null) {
+ myPluginManagerMain.filter(option);
+ }
}
};
}
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.updateSettings.impl.UpdateChecker;
import com.intellij.openapi.updateSettings.impl.UpdateSettings;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
return false;
}
-
- public static void notifyPluginsWereInstalled(@Nullable String pluginName, final Project project) {
- notifyPluginsWereUpdated(pluginName != null
- ? "Plugin \'" + pluginName + "\' was successfully installed"
- : "Plugins were installed", project);
- }
-
- public static void notifyPluginsWereUpdated(final String title, @Nullable final Project project) {
+ public static void notifyPluginsUpdated(@Nullable Project project) {
final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
- final boolean restartCapable = app.isRestartCapable();
- String message =
- restartCapable ? IdeBundle.message("message.idea.restart.required", ApplicationNamesInfo.getInstance().getFullProductName())
- : IdeBundle.message("message.idea.shutdown.required", ApplicationNamesInfo.getInstance().getFullProductName());
- message += "<br><a href=";
- message += restartCapable ? "\"restart\">Restart now" : "\"shutdown\">Shutdown";
- message += "</a>";
- PLUGIN_LIFECYCLE_NOTIFICATION_GROUP
- .createNotification(title,
- XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION,
- new NotificationListener() {
- @Override
- public void hyperlinkUpdate(@NotNull Notification notification,
- @NotNull HyperlinkEvent event) {
- notification.expire();
- if (restartCapable) {
- app.restart(true);
- }
- else {
- app.exit(false, true);
- }
- }
- }).notify(project);
+ String title = IdeBundle.message("update.notifications.title");
+ String action = IdeBundle.message(app.isRestartCapable() ? "ide.restart.action" : "ide.shutdown.action");
+ String message = IdeBundle.message("ide.restart.required.notification", action, ApplicationNamesInfo.getInstance().getFullProductName());
+ NotificationListener listener = new NotificationListener() {
+ @Override
+ public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
+ notification.expire();
+ app.restart(true);
+ }
+ };
+ UpdateChecker.NOTIFICATIONS.createNotification(title, XmlStringUtil.wrapInHtml(message), NotificationType.INFORMATION, listener).notify(project);
}
public class MyPluginsFilter extends FilterComponent {
protected AbstractUpdateDialog(boolean enableLink) {
super(true);
myEnableLink = enableLink;
- setTitle(IdeBundle.message("updates.info.dialog.title"));
+ setTitle(IdeBundle.message("update.notifications.title"));
}
protected AbstractUpdateDialog(Component parent, boolean enableLink) {
super(parent, true);
myEnableLink = enableLink;
- setTitle(IdeBundle.message("updates.info.dialog.title"));
+ setTitle(IdeBundle.message("update.notifications.title"));
}
@Override
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.progress.Task;
import com.intellij.ui.TableUtil;
-import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
UpdateChecker.saveDisabledToUpdatePlugins();
boolean updated = UpdateChecker.installPluginUpdates(myUploadedPlugins, indicator);
if (updated && !myPlatformUpdate) {
- String pluginName = null;
- if (myUploadedPlugins.size() == 1) {
- PluginDownloader plugin = ContainerUtil.getFirstItem(myUploadedPlugins);
- if (plugin != null) {
- pluginName = plugin.getPluginName();
- }
- }
- PluginManagerMain.notifyPluginsWereInstalled(pluginName, null);
+ PluginManagerMain.notifyPluginsUpdated(null);
}
}
});
import com.intellij.ide.plugins.*;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.*;
-import com.intellij.openapi.application.ApplicationInfo;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.application.ApplicationNamesInfo;
-import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.application.*;
import com.intellij.openapi.application.ex.ApplicationInfoEx;
import com.intellij.openapi.diagnostic.IdeaLoggingEvent;
import com.intellij.openapi.diagnostic.LogUtil;
import com.intellij.util.io.HttpRequests;
import com.intellij.util.io.URLUtil;
import com.intellij.util.ui.UIUtil;
+import com.intellij.xml.util.XmlStringUtil;
import org.apache.http.client.utils.URIBuilder;
import org.jdom.JDOMException;
import org.jetbrains.annotations.Contract;
SUCCESS, FAILED, CANCELED
}
- private static final NotNullLazyValue<NotificationGroup> GROUP = new NotNullLazyValue<NotificationGroup>() {
- @NotNull
- @Override
- protected NotificationGroup compute() {
- return new NotificationGroup(IdeBundle.message("update.available.group"), NotificationDisplayType.STICKY_BALLOON, true);
- }
- };
+ public static final NotificationGroup NOTIFICATIONS =
+ new NotificationGroup(IdeBundle.message("update.notifications.group"), NotificationDisplayType.STICKY_BALLOON, true);
@NonNls private static final String INSTALLATION_UID = "installation.uid";
@NonNls private static final String DISABLED_UPDATE = "disabled_update.txt";
}
}
- private static void showNotification(@Nullable Project project, String message, boolean error, final @Nullable Runnable runnable) {
+ private static void showNotification(@Nullable Project project, String message, boolean error, @Nullable final Runnable runnable) {
NotificationListener listener = null;
if (runnable != null) {
listener = new NotificationListener() {
};
}
- String title = IdeBundle.message("updates.info.dialog.title");
+ String title = IdeBundle.message("update.notifications.title");
NotificationType type = error ? NotificationType.ERROR : NotificationType.INFORMATION;
- Notifications.Bus.notify(GROUP.getValue().createNotification(title, message, type, listener), project);
+ NOTIFICATIONS.createNotification(title, XmlStringUtil.wrapInHtml(message), type, listener).notify(project);
}
public static void addUpdateRequestParameter(@NotNull String name, @NotNull String value) {
final Runnable notifyRunnable = new Runnable() {
@Override
public void run() {
- PluginManagerMain.notifyPluginsWereInstalled(null, myProject);
+ PluginManagerMain.notifyPluginsUpdated(myProject);
}
};
for (String pluginId : pluginsToEnable) {
column.plugins.rate=Rating
plugin.info.not.available=n/a
plugin.info.unknown=unknown
-message.idea.shutdown.required=Shut down {0} to activate changes in plugins?
-message.idea.restart.required=Restart {0} to activate changes in plugins?
+ide.restart.required.message={0} {1} to activate changes in plugins?
+ide.restart.required.notification=<a href="#">{0}</a> {1} to activate changes in plugins?
+ide.restart.action=Restart
+ide.shutdown.action=Shutdown
+ide.postpone.action=Postpone
title.plugins=Plugins
title.plugins.changed=Plugins Changed
plugin.status.not.specified=(not specified)
updates.error.connection.title=Connection Error
updates.error.connection.failed=Connection failed. Please check your network connection and try again.
updates.error.plugin.description.failed=Failed to load plugin descriptions from: \"{0}\"
-updates.info.dialog.title=Update Info
+update.notifications.title=Platform and Plugin Updates
+update.notifications.group=Platform and Plugin Updates
updates.channel.name.message=<b>{0}</b>: {1}
updates.channel.key.needed=You can evaluate the new version for {0} days or buy a license key or an upgrade online.
updates.channel.existing.key=The new version can be used with your existing license key.
checkbox.allow.line.numbers=Allow Line Numbers
checkbox.allow.vcs.annotations=Allow VCS Annotations
presentation.mode.fon.size=Font size\:
-update.available.group=Update Checker
loading.editors=Loading files...