File Source: InstallerListener.java
/*
P/P * Method: com.dmdirc.installer.InstallerListener__static_init
*/
1 /*
2 *
3 * Copyright (c) 2006-2008 Chris Smith, Shane Mc Cormack, Gregory Holmes
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24 package com.dmdirc.installer;
25
26 import com.dmdirc.installer.Installer.ShortcutType;
27 import com.dmdirc.installer.ui.InstallerDialog;
28
29 /**
30 * Listeners to all wizard and step changes and responds accordingly.
31 */
32 public class InstallerListener implements WizardListener, StepListener {
33
34 private Main main;
35
36 /**
37 * Instantiates a new installer listener.
38 *
39 * @param main Installer entry point
40 */
/*
P/P * Method: void com.dmdirc.installer.InstallerListener(Main)
*
* Postconditions:
* this.main == main
* init'ed(this.main)
*/
41 public InstallerListener(final Main main) {
42 this.main = main;
43 }
44
45 /** {@inheritDoc} */
46 @Override
47 public void wizardFinished() {
/*
P/P * Method: void wizardFinished()
*
* Preconditions:
* this.main != null
*
* Presumptions:
* com.dmdirc.installer.Main:getWizardFrame(...)@49 != null
*/
48 main.disposeOfInstaller();
49 Main.getWizardFrame().dispose();
50 }
51
52 /** {@inheritDoc} */
53 @Override
54 public void wizardCancelled() {
/*
P/P * Method: void wizardCancelled()
*
* Presumptions:
* com.dmdirc.installer.Main:getWizardFrame(...)@55 != null
* com.dmdirc.installer.Main:getWizardFrame(...)@57 != null
*
* Test Vectors:
* com.dmdirc.installer.ui.InstallerDialog:showCancelConfirmation(...)@55: {0}, {1}
* java.lang.String:equals(...)@55: {1}, {0}
*/
55 if (!"Install".equals(Main.getWizardFrame().getCurrentStepName()) && Main.getWizardFrame().
56 showCancelConfirmation()) {
57 Main.getWizardFrame().dispose();
58 }
59 }
60
61 /** {@inheritDoc} */
62 @Override
63 public void stepAboutToDisplay(final Step step) {
/*
P/P * Method: void stepAboutToDisplay(Step)
*
* Preconditions:
* step != null
*
* Test Vectors:
* java.lang.String:equals(...)@64: {0}, {1}
* java.lang.String:equals(...)@66: {0}, {1}
*/
64 if ("Install".equals(step.getStepName())) {
65 installerToBeDisplayed(step);
66 } else if ("Confirm".equals(step.getStepName())) {
67 confirmToBeDisplayed(step);
68 }
69 }
70
71 /** {@inheritDoc} */
72 @Override
73 public void stepHidden(final Step step) {
74 //Ignore
/*
P/P * Method: void stepHidden(Step)
*/
75 }
76
77 private void installerToBeDisplayed(final Step step) {
/*
P/P * Method: void installerToBeDisplayed(Step)
*
* Presumptions:
* com.dmdirc.installer.Main:getInstaller(...)@81 != null
* com.dmdirc.installer.Main:getInstaller(...)@82 != null
* com.dmdirc.installer.Main:getWizardFrame(...)@78 != null
*/
78 final InstallerDialog dialog = Main.getWizardFrame();
79 dialog.enableNextStep(false);
80 dialog.enablePreviousStep(false);
81 Main.getInstaller().setInstallStep((TextStep) dialog.getStep("Install"));
82 Main.getInstaller().start();
83 }
84
85 private void confirmToBeDisplayed(final Step step) {
/*
P/P * Method: void confirmToBeDisplayed(Step)
*
* Presumptions:
* com.dmdirc.installer.Main:getInstaller(...)@101 != null
* com.dmdirc.installer.Main:getInstaller(...)@106 != null
* com.dmdirc.installer.Main:getInstaller(...)@90 != null
* com.dmdirc.installer.Main:getInstaller(...)@96 != null
* com.dmdirc.installer.Main:getWizardFrame(...)@122 != null
* ...
*
* Test Vectors:
* java.lang.String:isEmpty(...)@118: {0}, {1}
*/
86 String shortcutText = "";
87
88 final Settings settings = (Settings) Main.getWizardFrame().getStep(1);
89
90 if (Main.getInstaller().supportsShortcut(ShortcutType.MENU) && settings.
91 getShortcutMenuState()) {
92 shortcutText = shortcutText + " - Create " + Main.getInstaller().
93 getMenuName() + " shortcut\n";
94 }
95
96 if (Main.getInstaller().supportsShortcut(ShortcutType.DESKTOP) &&
97 settings.getShortcutDesktopState()) {
98 shortcutText = shortcutText + " - Create desktop shortcut\n";
99 }
100
101 if (Main.getInstaller().supportsShortcut(ShortcutType.QUICKLAUNCH) &&
102 settings.getShortcutQuickState()) {
103 shortcutText = shortcutText + " - Create Quick Launch shortcut\n";
104 }
105
106 if (Main.getInstaller().supportsShortcut(ShortcutType.PROTOCOL) &&
107 settings.getShortcutProtocolState()) {
108 shortcutText = shortcutText +
109 " - Make DMDirc handle irc:// links\n";
110 }
111
112
113 final String installLocation = settings.getInstallLocation();
114
115
116 if (step instanceof TextStep) {
117 final TextStep textStep = (TextStep) step;
118 if (installLocation.isEmpty()) {
119 textStep.setText(
120 "You have chosen an invalid install location\n\n" +
121 "Please press the \"Previous\" button to go back and correct it.");
122 Main.getWizardFrame().enableNextStep(false);
123 } else {
124 textStep.setText(
125 "Please review your chosen settings:\n\n" +
126 " - Install Location:\n" + " " + installLocation +
127 "\n" + shortcutText + "\n" + "If you wish to change " +
128 "any of these settings, press the \"Previous\" " +
129 "button, otherwise click \"Next\" to begin the installation");
130 Main.getWizardFrame().enableNextStep(true);
131 }
132 }
133 }
134 }
SofCheck Inspector Build Version : 2.17854
| InstallerListener.java |
2009-Jun-25 01:54:24 |
| InstallerListener.class |
2009-Sep-02 17:04:16 |