IDEA-218594 Plugins: ugly dialogs on downloading failure

GitOrigin-RevId: eb6195f9a8a131fba9ca160b50a8120cb5270188
This commit is contained in:
Alexander Lobas
2019-09-26 13:33:28 +00:00
committed by intellij-monorepo-bot
parent 85b6063978
commit 270a018ec4
5 changed files with 26 additions and 5 deletions
@@ -37,6 +37,7 @@ public class PluginInstallOperation {
private boolean myAllowInstallWithoutRestart = false;
private final List<PendingDynamicPluginInstall> myPendingDynamicPluginInstalls = new ArrayList<>();
private boolean myRestartRequired = false;
private boolean myShownErrors;
public PluginInstallOperation(@NotNull List<PluginNode> pluginsToInstall,
List<? extends IdeaPluginDescriptor> allPlugins,
@@ -74,6 +75,10 @@ public class PluginInstallOperation {
return myDependant;
}
public boolean isShownErrors() {
return myShownErrors;
}
private void updateUrls() {
boolean unknownNodes = false;
for (PluginNode node : myPluginsToInstall) {
@@ -228,6 +233,8 @@ public class PluginInstallOperation {
}
}
myShownErrors = false;
PluginDownloader downloader = PluginDownloader.createDownloader(pluginNode, pluginNode.getRepositoryName(), null);
if (downloader.prepareToInstall(myIndicator)) {
@@ -250,6 +257,7 @@ public class PluginInstallOperation {
}
}
else {
myShownErrors = downloader.isShownErrors();
return false;
}
@@ -45,7 +45,7 @@ public class InstallPluginInfo {
closeStatusBarIndicator();
}
public synchronized void finish(boolean success, boolean cancel, boolean restartRequired) {
public synchronized void finish(boolean success, boolean cancel, boolean showErrors, boolean restartRequired) {
if (myPluginModel == null) {
MyPluginModel.finishInstall(myDescriptor);
closeStatusBarIndicator();
@@ -55,7 +55,7 @@ public class InstallPluginInfo {
}
}
else if (!cancel) {
myPluginModel.finishInstall(myDescriptor, success, true, restartRequired);
myPluginModel.finishInstall(myDescriptor, success, showErrors, restartRequired);
}
}
@@ -341,6 +341,7 @@ public class MyPluginModel extends InstalledPluginsTableModel implements PluginM
ApplicationManager.getApplication().executeOnPooledThread(() -> {
boolean cancel = false;
boolean error = false;
boolean showErrors = true;
boolean restartRequired = true;
try {
@@ -352,6 +353,7 @@ public class MyPluginModel extends InstalledPluginsTableModel implements PluginM
}
error = !operation.isSuccess();
showErrors = !operation.isShownErrors();
restartRequired = operation.isRestartRequired();
}
catch (ProcessCanceledException e) {
@@ -364,8 +366,10 @@ public class MyPluginModel extends InstalledPluginsTableModel implements PluginM
boolean success = !error;
boolean _cancel = cancel;
boolean _showErrors = showErrors;
boolean finalRestartRequired = restartRequired;
ApplicationManager.getApplication().invokeLater(() -> info.finish(success, _cancel, finalRestartRequired), ModalityState.any());
ApplicationManager.getApplication()
.invokeLater(() -> info.finish(success, _cancel, _showErrors, finalRestartRequired), ModalityState.any());
});
}
@@ -491,7 +495,7 @@ public class MyPluginModel extends InstalledPluginsTableModel implements PluginM
needRestart = true;
}
if (!success && showErrors) {
Messages.showErrorDialog("Plugin " + descriptor.getName() + " download or installing failed",
Messages.showErrorDialog("Plugin \"" + descriptor.getName() + "\" download or installing failed",
IdeBundle.message("action.download.and.install.plugin"));
}
}
@@ -58,6 +58,8 @@ public class PluginDownloader {
private File myFile;
private File myOldFile;
private boolean myShownErrors;
private PluginDownloader(IdeaPluginDescriptor descriptor, String url, BuildNumber buildNumber) {
myPluginId = descriptor.getPluginId().getIdString();
myPluginName = descriptor.getName();
@@ -115,7 +117,13 @@ public class PluginDownloader {
return myFile;
}
public boolean isShownErrors() {
return myShownErrors;
}
public boolean prepareToInstall(@NotNull ProgressIndicator indicator) throws IOException {
myShownErrors = false;
if (myFile != null) {
return true;
}
@@ -146,6 +154,7 @@ public class PluginDownloader {
if (myFile == null) {
Application app = ApplicationManager.getApplication();
if (app != null) {
myShownErrors = true;
if (errorMessage == null) {
errorMessage = IdeBundle.message("unknown.error");
}
@@ -548,7 +548,7 @@ macro.fileprompt.preview=<filename>
macro.sourcepath.entry=Entry in the sourcepath the element belongs to
macro.project.sourcepath=Project's sourcepath
error.plugins.should.not.have.cyclic.dependencies=Plugins should not have cyclic dependencies:
error.plugin.was.not.installed=Plugin {0} was not installed: {1}
error.plugin.was.not.installed=Plugin "{0}" was not installed: {1}
title.failed.to.download=Failed to Download
error.plugins.were.not.loaded=Error loading plugins:\n{0}\nPlugins were not loaded.\nCorrect the above error and restart IDEA.
title.plugin.error=Plugin Error