[platform] allows a manual patch application (IDEA-160700)

This commit is contained in:
Roman Shevchenko
2016-09-05 15:34:11 +03:00
parent 38a19cfe27
commit a27346e0f9
3 changed files with 35 additions and 4 deletions
@@ -776,7 +776,7 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
exitCode = Restarter.scheduleRestart(beforeRestart);
}
catch (IOException e) {
LOG.warn("Cannot restart", e);
LOG.error("Cannot restart", e);
}
}
System.exit(exitCode);
@@ -31,12 +31,15 @@ import com.intellij.openapi.application.impl.ApplicationImpl;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.ui.JBColor;
import com.intellij.ui.LicensingFacade;
import com.intellij.ui.components.JBLabel;
import com.intellij.util.SystemProperties;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.DateFormatUtil;
import org.apache.http.client.utils.URIBuilder;
@@ -52,6 +55,8 @@ import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.intellij.openapi.util.Pair.pair;
@@ -130,8 +135,9 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
protected Action[] createActions() {
List<Action> actions = ContainerUtil.newArrayList();
if (myPatch != null && ApplicationManager.getApplication().isRestartCapable()) {
actions.add(new AbstractAction(IdeBundle.message("updates.download.and.restart.button")) {
if (myPatch != null) {
boolean canRestart = ApplicationManager.getApplication().isRestartCapable();
actions.add(new AbstractAction(IdeBundle.message(canRestart ? "updates.download.and.restart.button" : "updates.apply.manually.button")) {
{
setEnabled(!myWriteProtected);
}
@@ -213,7 +219,12 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
}
ApplicationEx app = ApplicationManagerEx.getApplicationEx();
app.invokeLater(() -> ((ApplicationImpl)app).exit(false, true, true, command));
if (ApplicationManager.getApplication().isRestartCapable()) {
app.invokeLater(() -> ((ApplicationImpl)app).exit(false, true, true, command));
}
else {
showPatchInstructions(command);
}
}
}.queue();
}
@@ -224,6 +235,23 @@ class UpdateInfoDialog extends AbstractUpdateDialog {
BrowserUtil.browse(augmentUrl(url));
}
private static void showPatchInstructions(String[] command) {
String product = ApplicationNamesInfo.getInstance().getLowercaseProductName();
String version = ApplicationInfo.getInstance().getFullVersion();
File file = new File(SystemProperties.getUserHome(), product + "-" + version + "-patch.txt");
try {
String text = Stream.of(command).map(s -> s.indexOf(' ') > 0 ? '"' + s + '"' : s).collect(Collectors.joining(" "));
FileUtil.writeToFile(file, text);
}
catch (Exception e) {
Logger.getInstance(UpdateInstaller.class).error(e);
return;
}
String title = IdeBundle.message("update.notifications.title"), message = IdeBundle.message("update.apply.manually.message", file);
ApplicationManager.getApplication().invokeLater(() -> Messages.showInfoMessage(message, title));
}
private static class ButtonAction extends AbstractAction {
private final String myUrl;
@@ -929,6 +929,7 @@ updates.plugins.ready.header=<html><b>Plugins from configured hosts are ready to
updates.configure.label=To configure automatic update settings, see the <b><a href=\"updates\">Updates</a></b> dialog of your IDE {0}.
updates.incompatible.plugins.found={0,choice,1#Plugin|2#Plugins} incompatible with the new build found:{0,choice,1#' '|2#'<br/>'} {1}
updates.download.and.restart.button=Up&date and Restart
updates.apply.manually.button=Up&date Manually
updates.more.info.button=&More Info...
updates.ignore.update.button=&Ignore This Update
updates.remind.later.button=&Remind Me Later
@@ -966,6 +967,8 @@ update.sni.disabled.error=Secure connection is impossible with 'jsse.enableSNIEx
update.sni.disabled.message=We wanted your IDE to receive upgrades over a secure connection. \
Unfortunately, this doesn't work with the 'jsse.enableSNIExtension' property set to 'false', so the option was disabled. \
You can enable it again in <a href="disable">settings</a> after setting the property to 'true'.
update.apply.manually.message=Unfortunately, the IDE is not capable of an automatic update on your system.\n \
Please quit the IDE and apply the patch manually by invoking a command from this file:\n{0}.
hierarchy.method.next.occurence.name=Go to next method
hierarchy.method.prev.occurence.name=Go to previous method