You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StepInstall.java 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.installer;
  23. import com.dmdirc.installer.Installer.ShortcutType;
  24. import com.dmdirc.ui.swing.dialogs.wizard.Step;
  25. import com.dmdirc.ui.swing.dialogs.wizard.StepListener;
  26. import com.dmdirc.ui.swing.dialogs.wizard.WizardFrame;
  27. import static com.dmdirc.ui.swing.UIUtilities.LARGE_BORDER;
  28. import static com.dmdirc.ui.swing.UIUtilities.SMALL_BORDER;
  29. import java.awt.BorderLayout;
  30. import javax.swing.UIManager;
  31. import javax.swing.BorderFactory;
  32. import javax.swing.JTextArea;
  33. import javax.swing.JScrollPane;
  34. /**
  35. * This confirms the settings chosen in the previous step
  36. */
  37. public final class StepInstall extends Step implements StepListener {
  38. /**
  39. * A version number for this class. It should be changed whenever the class
  40. * structure is changed (or anything else that would prevent serialized
  41. * objects being unserialized with the new class).
  42. */
  43. private static final long serialVersionUID = 2;
  44. /** Text area showing the install information */
  45. private final JTextArea infoLabel = new JTextArea("Beginning Install");
  46. /** Scroll pane holding text area */
  47. final JScrollPane scrollPane;
  48. /**
  49. * Creates a new instance of StepInstall.
  50. * @param dialog parent wizard dialog
  51. */
  52. public StepInstall(final WizardFrame dialog) {
  53. super();
  54. dialog.addStepListener(this);
  55. setLayout(new BorderLayout());
  56. setBorder(BorderFactory.createEmptyBorder(LARGE_BORDER, LARGE_BORDER, SMALL_BORDER, LARGE_BORDER));
  57. infoLabel.setFont(UIManager.getFont("Label.font"));
  58. infoLabel.setEditable(false);
  59. infoLabel.setWrapStyleWord(true);
  60. infoLabel.setLineWrap(true);
  61. infoLabel.setHighlighter(null);
  62. infoLabel.setOpaque(false);
  63. infoLabel.setFont(UIManager.getFont("TextField.font"));
  64. // infoLabel.setBackground(getBackground());
  65. infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, SMALL_BORDER, 0));
  66. scrollPane = new JScrollPane(infoLabel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  67. add(scrollPane, BorderLayout.CENTER);
  68. }
  69. /**
  70. * Add text to the infolabel.
  71. *
  72. * @param text Text to add to infoLabel
  73. */
  74. public synchronized void addText(final String text) {
  75. infoLabel.setText(infoLabel.getText() + text +"\n");
  76. infoLabel.setCaretPosition(infoLabel.getText().length());
  77. }
  78. /**
  79. * Perform the installation.
  80. */
  81. public void performInstall(final Installer myInstaller) {
  82. infoLabel.setText("Beginning Install..\n");
  83. final String location = ((StepSettings) Main.getWizardFrame().getStep(1)).getInstallLocation();
  84. addText("Installing files to: "+location);
  85. if (!myInstaller.doSetup(location)) {
  86. addText("");
  87. addText("Installation failed\n");
  88. Main.getWizardFrame().enableNextStep(true);
  89. return;
  90. }
  91. StepSettings settings = ((StepSettings) Main.getWizardFrame().getStep(1));
  92. if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
  93. if (settings.getShortcutMenuState()) {
  94. addText("Setting up Menu shortcut");
  95. myInstaller.setupShortcut(location, ShortcutType.MENU);
  96. } else {
  97. addText("Not setting up Menu shortcut");
  98. }
  99. }
  100. if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
  101. if (settings.getShortcutDesktopState()) {
  102. addText("Setting up Desktop shortcut");
  103. myInstaller.setupShortcut(location, ShortcutType.DESKTOP);
  104. } else {
  105. addText("Not setting up Desktop shortcut");
  106. }
  107. }
  108. if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
  109. if (settings.getShortcutQuickState()) {
  110. addText("Setting up Quick Launch shortcut");
  111. myInstaller.setupShortcut(location, ShortcutType.QUICKLAUNCH);
  112. } else {
  113. addText("Not setting up Quick Launch shortcut");
  114. }
  115. }
  116. if (Main.getInstaller().supportsShortcut(ShortcutType.UNINSTALLER)) {
  117. addText("Creating uninstaller");
  118. myInstaller.setupShortcut(location, ShortcutType.UNINSTALLER);
  119. }
  120. if (Main.getInstaller().supportsShortcut(ShortcutType.PROTOCOL)) {
  121. if (settings.getShortcutProtocolState()) {
  122. addText("Setting up irc:// handler");
  123. myInstaller.setupShortcut(location, ShortcutType.PROTOCOL);
  124. } else {
  125. addText("Not setting up irc:// handler");
  126. }
  127. }
  128. myInstaller.postInstall(location);
  129. addText("");
  130. addText("Installation finished\n");
  131. Main.getWizardFrame().enableNextStep(true);
  132. }
  133. /** {@inheritDoc} */
  134. @Override
  135. public void stepAboutToDisplay(final Step step) {
  136. if (step != this) { return; }
  137. Main.getWizardFrame().enableNextStep(false);
  138. Main.getWizardFrame().enablePreviousStep(false);
  139. Main.getInstaller().setInstallStep(this);
  140. Main.getInstaller().start();
  141. }
  142. /** {@inheritDoc} */
  143. @Override
  144. public void stepHidden(final Step step) {
  145. //Ignore
  146. }
  147. }