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 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Copyright (c) 2006-2007 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.SpecialStep;
  25. import com.dmdirc.ui.swing.dialogs.wizard.TextStep;
  26. import com.dmdirc.ui.swing.dialogs.wizard.Step;
  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.BorderFactory;
  31. import javax.swing.JTextArea;
  32. /**
  33. * This confirms the settings chosen in the previous step
  34. */
  35. public final class StepInstall extends Step implements SpecialStep, TextStep {
  36. /**
  37. * A version number for this class. It should be changed whenever the class
  38. * structure is changed (or anything else that would prevent serialized
  39. * objects being unserialized with the new class).
  40. */
  41. private static final long serialVersionUID = 2;
  42. /** Text area showing the install information */
  43. private JTextArea infoLabel = new JTextArea("Beginning Install");
  44. /**
  45. * Creates a new instance of StepInstall.
  46. */
  47. public StepInstall() {
  48. super();
  49. setLayout(new BorderLayout());
  50. setBorder(BorderFactory.createEmptyBorder(LARGE_BORDER, LARGE_BORDER, SMALL_BORDER, LARGE_BORDER));
  51. infoLabel.setEditable(false);
  52. infoLabel.setWrapStyleWord(true);
  53. infoLabel.setLineWrap(true);
  54. infoLabel.setHighlighter(null);
  55. infoLabel.setBackground(getBackground());
  56. infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, SMALL_BORDER, 0));
  57. add(infoLabel, BorderLayout.CENTER);
  58. }
  59. /**
  60. * Add text to the infolabel.
  61. *
  62. * @param text Text to add to infoLabel
  63. */
  64. public synchronized void addText(final String text) {
  65. infoLabel.setText(infoLabel.getText() + text +"\n");
  66. }
  67. /**
  68. * Display Step.
  69. */
  70. public void showStep() {
  71. Main.getWizardDialog().enableNextStep(false);
  72. Main.getWizardDialog().enablePreviousStep(false);
  73. Main.getInstaller().setInstallStep(this);
  74. Main.getInstaller().start();
  75. }
  76. /**
  77. * Perform the installation.
  78. */
  79. public void performInstall(final Installer myInstaller) {
  80. infoLabel.setText("Beginning Install..\n");
  81. final String location = ((StepSettings) Main.getWizardDialog().getStep(1)).getInstallLocation();
  82. addText("Installing files to: "+location);
  83. myInstaller.doSetup(location);
  84. StepSettings settings = ((StepSettings) Main.getWizardDialog().getStep(1));
  85. if (Main.getInstaller().supportsShortcut(ShortcutType.MENU)) {
  86. if (settings.getShortcutMenuState()) {
  87. addText("Setting up Menu shortcut");
  88. myInstaller.setupShortcut(location, ShortcutType.MENU);
  89. } else {
  90. addText("Not setting up Menu shortcut");
  91. }
  92. }
  93. if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP)) {
  94. if (settings.getShortcutDesktopState()) {
  95. addText("Setting up Desktop shortcut");
  96. myInstaller.setupShortcut(location, ShortcutType.DESKTOP);
  97. } else {
  98. addText("Not setting up Desktop shortcut");
  99. }
  100. }
  101. if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH)) {
  102. if (settings.getShortcutQuickState()) {
  103. addText("Setting up Quick Launch shortcut");
  104. myInstaller.setupShortcut(location, ShortcutType.QUICKLAUNCH);
  105. } else {
  106. addText("Not setting up Quick Launch shortcut");
  107. }
  108. }
  109. addText("");
  110. addText("Installation finished\n");
  111. Main.getWizardDialog().enableNextStep(true);
  112. }
  113. }