Java 类com.intellij.util.Restarter 实例源码

项目:consulo    文件:CustomizeDownloadAndStartStepPanel.java   
@Nonnull
private static String getStartName() {
  boolean supported = Restarter.isSupported();
  if(supported) {
    return "Start using " + ApplicationNamesInfo.getInstance().getFullProductName();
  }
  else {
    return "Manual start " + ApplicationNamesInfo.getInstance().getFullProductName();
  }
}
项目:intellij-ce-playground    文件:Main.java   
private static void installPatch() throws Exception {
  String platform = System.getProperty(PLATFORM_PREFIX_PROPERTY, "idea");
  String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase(Locale.US);
  String tempDir = System.getProperty("java.io.tmpdir");

  // always delete previous patch copy
  File patchCopy = new File(tempDir, patchFileName + "_copy");
  File log4jCopy = new File(tempDir, "log4j.jar." + platform + "_copy");
  File jnaUtilsCopy = new File(tempDir, "jna-platform.jar." + platform + "_copy");
  File jnaCopy = new File(tempDir, "jna.jar." + platform + "_copy");
  if (!FileUtilRt.delete(patchCopy) || !FileUtilRt.delete(log4jCopy) || !FileUtilRt.delete(jnaUtilsCopy) || !FileUtilRt.delete(jnaCopy)) {
    throw new IOException("Cannot delete temporary files in " + tempDir);
  }

  File patch = new File(tempDir, patchFileName);
  if (!patch.exists()) return;

  File log4j = new File(PathManager.getLibPath(), "log4j.jar");
  if (!log4j.exists()) throw new IOException("Log4J is missing: " + log4j);

  File jnaUtils = new File(PathManager.getLibPath(), "jna-platform.jar");
  if (!jnaUtils.exists()) throw new IOException("jna-platform.jar is missing: " + jnaUtils);

  File jna = new File(PathManager.getLibPath(), "jna.jar");
  if (!jna.exists()) throw new IOException("jna is missing: " + jna);

  copyFile(patch, patchCopy, true);
  copyFile(log4j, log4jCopy, false);
  copyFile(jna, jnaCopy, false);
  copyFile(jnaUtils, jnaUtilsCopy, false);

  int status = 0;
  if (Restarter.isSupported()) {
    List<String> args = new ArrayList<String>();

    if (SystemInfoRt.isWindows) {
      File launcher = new File(PathManager.getBinPath(), "VistaLauncher.exe");
      args.add(Restarter.createTempExecutable(launcher).getPath());
      Restarter.createTempExecutable(new File(PathManager.getBinPath(), "restarter.exe"));
    }

    //noinspection SpellCheckingInspection
    String java = getJava();
    Collections.addAll(args,
                       java,
                       "-Xmx750m",
                       "-Djna.nosys=true",
                       "-Djna.boot.library.path=",
                       "-Djna.debug_load=true",
                       "-Djna.debug_load.jna=true",
                       "-classpath",
                       patchCopy.getPath() + pathSeparator + log4jCopy.getPath() + pathSeparator + jnaCopy.getPath() + pathSeparator + jnaUtilsCopy.getPath(),
                       "-Djava.io.tmpdir=" + tempDir,
                       "-Didea.updater.log=" + PathManager.getLogPath(),
                       "-Dswing.defaultlaf=" + UIManager.getSystemLookAndFeelClassName(),
                       "com.intellij.updater.Runner",
                       "install",
                       PathManager.getHomePath());

    status = Restarter.scheduleRestart(ArrayUtilRt.toStringArray(args));
  }
  else {
    String message = "Patch update is not supported - please do it manually";
    showMessage("Update Error", message, true);
  }

  System.exit(status);
}
项目:tools-idea    文件:Main.java   
private static void installPatch() throws IOException {
  String platform = System.getProperty("idea.platform.prefix", "idea");
  String patchFileName = ("jetbrains.patch.jar." + platform).toLowerCase();
  File originalPatchFile = new File(System.getProperty("java.io.tmpdir"), patchFileName);
  File copyPatchFile = new File(System.getProperty("java.io.tmpdir"), patchFileName + "_copy");

  // always delete previous patch copy
  if (!FileUtilRt.delete(copyPatchFile)) {
    throw new IOException("Cannot create temporary patch file");
  }

  if (!originalPatchFile.exists()) {
    return;
  }

  if (!originalPatchFile.renameTo(copyPatchFile) || !FileUtilRt.delete(originalPatchFile)) {
    throw new IOException("Cannot create temporary patch file");
  }

  int status = 0;
  if (Restarter.isSupported()) {
    List<String> args = new ArrayList<String>();

    if (SystemInfo.isWindows) {
      File launcher = new File(PathManager.getBinPath(), "VistaLauncher.exe");
      args.add(Restarter.createTempExecutable(launcher).getPath());
    }

    Collections.addAll(args,
                       System.getProperty("java.home") + "/bin/java",
                       "-Xmx500m",
                       "-classpath",
                       copyPatchFile.getPath(),
                       "com.intellij.updater.Runner",
                       "install",
                       PathManager.getHomePath());

    status = Restarter.scheduleRestart(ArrayUtilRt.toStringArray(args));
  }
  else {
    String message = "Patch update is not supported - please do it manually";
    showMessage("Update Error", message, true);
  }

  System.exit(status);
}