PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/installer/ConsoleInstall.java

#
Java | 130 lines | 85 code | 21 blank | 24 comment | 18 complexity | f5e58a3eec7a8721f32eb765b4f18bd4 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * ConsoleInstall.java
  3. * Copyright (C) 1999, 2000 Slava Pestov
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. */
  19. package installer;
  20. import java.io.*;
  21. import java.util.Vector;
  22. /*
  23. * Performs text-only installation.
  24. */
  25. public class ConsoleInstall
  26. {
  27. public ConsoleInstall()
  28. {
  29. installer = new Install();
  30. String appName = installer.getProperty("app.name");
  31. String appVersion = installer.getProperty("app.version");
  32. BufferedReader in = new BufferedReader(new InputStreamReader(
  33. System.in));
  34. System.out.println("*** " + appName + " " + appVersion + " installer");
  35. OperatingSystem os = OperatingSystem.getOperatingSystem();
  36. String installDir = OperatingSystem.getOperatingSystem()
  37. .getInstallDirectory(appName,appVersion);
  38. System.out.print("Installation directory [" + installDir + "]: ");
  39. System.out.flush();
  40. String _installDir = readLine(in);
  41. if(_installDir.length() != 0)
  42. installDir = _installDir;
  43. String binDir = OperatingSystem.getOperatingSystem()
  44. .getShortcutDirectory(appName,appVersion);
  45. if(binDir != null)
  46. {
  47. System.out.print("Shortcut directory [" + binDir + "]: ");
  48. System.out.flush();
  49. String _binDir = readLine(in);
  50. if(_binDir.length() != 0)
  51. binDir = _binDir;
  52. }
  53. int compCount = installer.getIntProperty("comp.count");
  54. Vector components = new Vector(compCount);
  55. System.out.println("*** Program components to install");
  56. for(int i = 0; i < compCount; i++)
  57. {
  58. String fileset = installer.getProperty("comp." + i + ".fileset");
  59. String osDep = installer.getProperty("comp." + i + ".os");
  60. if(osDep != null)
  61. {
  62. if(!OperatingSystem.getOperatingSystem()
  63. .getClass().getName().endsWith(osDep))
  64. {
  65. continue;
  66. }
  67. }
  68. System.out.print("Install "
  69. + installer.getProperty("comp." + i + ".name")
  70. + " ("
  71. + installer.getProperty("comp." + i + ".disk-size")
  72. + "Kb) [Y/n]? ");
  73. String line = readLine(in);
  74. if(line.length() == 0 || line.charAt(0) == 'y'
  75. || line.charAt(0) == 'Y')
  76. components.addElement(fileset);
  77. }
  78. System.out.println("*** Starting installation...");
  79. ConsoleProgress progress = new ConsoleProgress();
  80. InstallThread thread = new InstallThread(
  81. installer,progress,installDir,binDir,
  82. 0 /* XXX */,components);
  83. thread.start();
  84. }
  85. // private members
  86. private Install installer;
  87. private String readLine(BufferedReader in)
  88. {
  89. try
  90. {
  91. String line = in.readLine();
  92. if(line == null)
  93. {
  94. System.err.println("\nEOF in input!");
  95. System.exit(1);
  96. // can't happen
  97. throw new InternalError();
  98. }
  99. return line;
  100. }
  101. catch(IOException io)
  102. {
  103. System.err.println("\nI/O error: " + io);
  104. System.exit(1);
  105. // can't happen
  106. throw new InternalError();
  107. }
  108. }
  109. }