Pārlūkot izejas kodu

fixes issue 2112

tags/0.6.3m1rc1
Gregory Holmes 15 gadus atpakaļ
vecāks
revīzija
7d44480289

+ 16
- 0
src/com/dmdirc/installer/Step.java Parādīt failu

@@ -23,6 +23,8 @@
23 23
 
24 24
 package com.dmdirc.installer;
25 25
 
26
+import java.awt.Image;
27
+
26 28
 /**
27 29
  * Simple step interface.
28 30
  */
@@ -34,4 +36,18 @@ public interface Step {
34 36
      * @return Step name
35 37
      */
36 38
     public abstract String getStepName();
39
+    
40
+    /**
41
+     * Returns the description for this step.
42
+     * 
43
+     * @return Step description
44
+     */
45
+    public abstract String getStepDescription();
46
+    
47
+    /**
48
+     * Returns the icon for this step.
49
+     * 
50
+     * @return Step icon
51
+     */
52
+    public abstract Image getIcon();
37 53
 }

+ 18
- 14
src/com/dmdirc/installer/ui/InstallerDialog.java Parādīt failu

@@ -58,12 +58,13 @@ public class InstallerDialog extends JFrame implements ActionListener {
58 58
     public static final int SMALL_GAP = 5;
59 59
 
60 60
     /**
61
-     *
61
+     * Instantiates a new installer dialog
62
+     * 
62 63
      * @param dialogTitle
63 64
      */
64 65
     public InstallerDialog(final String dialogTitle) {
65 66
         super(dialogTitle);
66
-        title = new TitlePanel(dialogTitle);
67
+        title = new TitlePanel(null);
67 68
         wizard = new WizardPanel(this);
68 69
         control = new WizardControlPanel();
69 70
         listeners = new ListenerList();
@@ -96,19 +97,20 @@ public class InstallerDialog extends JFrame implements ActionListener {
96 97
     }
97 98
 
98 99
     /**
99
-     *
100
+     * Adds a step.
100 101
      * 
101
-     * @param step
102
+     * @param step Step to add
102 103
      */
103 104
     public void addStep(final SwingStep step) {
104 105
         wizard.addStep(step);
105 106
     }
106 107
 
107 108
     /**
108
-     *
109
+     * Displays the installer.
109 110
      */
110 111
     public void display() {
111 112
         wizard.display();
113
+        title.setStep(wizard.getCurrentStep());
112 114
         control.setTotal(wizard.getTotalSteps());
113 115
         control.setProgress(wizard.getCurrentStepIndex());
114 116
         addWindowListener(new WindowAdapter() {
@@ -127,8 +129,9 @@ public class InstallerDialog extends JFrame implements ActionListener {
127 129
     }
128 130
 
129 131
     /**
130
-     *
131
-     * @param steps 
132
+     * Displays the installer with these steps added.
133
+     * 
134
+     * @param steps Steps to add
132 135
      */
133 136
     public void display(final List<Step> steps) {
134 137
         final List<SwingStep> swingSteps = new ArrayList<SwingStep>();
@@ -141,27 +144,27 @@ public class InstallerDialog extends JFrame implements ActionListener {
141 144
     }
142 145
 
143 146
     /**
147
+     * Enables the next step.
144 148
      *
145
-     *
146
-     * @param enable
149
+     * @param enable true to enable false to disable
147 150
      */
148 151
     public void enableNextStep(final boolean enable) {
149 152
         control.getNextButton().setEnabled(enable);
150 153
     }
151 154
 
152 155
     /**
156
+     * Enables the previous step.
153 157
      *
154
-     *
155
-     * @param enable
158
+     * @param enable true to enable false to disable
156 159
      */
157 160
     public void enablePreviousStep(final boolean enable) {
158 161
         control.getPrevButton().setEnabled(enable);
159 162
     }
160 163
 
161 164
     /**
162
-     *
165
+     * shows the cancel confirmation.
163 166
      * 
164
-     * @return
167
+     * @return true if confirmed
165 168
      */
166 169
     public boolean showCancelConfirmation() {
167 170
         return JOptionPane.showConfirmDialog(this,
@@ -318,7 +321,7 @@ public class InstallerDialog extends JFrame implements ActionListener {
318 321
         } catch (IllegalAccessException ex) {
319 322
             throw new UnsupportedOperationException("Unable to switch to the " +
320 323
                                                     "system look and feel", ex);
321
-        }
324
+        }   
322 325
 
323 326
         UIManager.put("swing.useSystemFontSettings", true);
324 327
         UIManager.put("swing.boldMetal", false);
@@ -346,6 +349,7 @@ public class InstallerDialog extends JFrame implements ActionListener {
346 349
         } else {
347 350
             return;
348 351
         }
352
+        title.setStep(shownStep);
349 353
         if (shownStep != null) {
350 354
             fireStepAboutToBeDisplayed(shownStep);
351 355
         }

+ 13
- 0
src/com/dmdirc/installer/ui/StepConfirm.java Parādīt failu

@@ -25,6 +25,7 @@ package com.dmdirc.installer.ui;
25 25
 import com.dmdirc.installer.TextStep;
26 26
 
27 27
 import java.awt.BorderLayout;
28
+import java.awt.Image;
28 29
 import javax.swing.SwingUtilities;
29 30
 
30 31
 /**
@@ -56,6 +57,18 @@ public final class StepConfirm extends SwingStep implements TextStep {
56 57
         return "Confirm";
57 58
     }
58 59
 
60
+    /** {@inheritDoc} */
61
+    @Override
62
+    public Image getIcon() {
63
+        return null;
64
+    }
65
+
66
+    /** {@inheritDoc} */
67
+    @Override
68
+    public String getStepDescription() {
69
+        return "";
70
+    }
71
+
59 72
     /** {@inheritDoc} */
60 73
     @Override
61 74
     public void addText(final String text) {

+ 13
- 0
src/com/dmdirc/installer/ui/StepError.java Parādīt failu

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.installer.ui;
24 24
 
25 25
 import java.awt.BorderLayout;
26
+import java.awt.Image;
26 27
 
27 28
 /**
28 29
  * This step shows an unable to install error
@@ -59,4 +60,16 @@ public final class StepError extends SwingStep {
59 60
     public String getStepName() {
60 61
         return "Error";
61 62
     }
63
+
64
+    /** {@inheritDoc} */
65
+    @Override
66
+    public Image getIcon() {
67
+        return null;
68
+    }
69
+
70
+    /** {@inheritDoc} */
71
+    @Override
72
+    public String getStepDescription() {
73
+        return "";
74
+    }
62 75
 }

+ 13
- 0
src/com/dmdirc/installer/ui/StepInstall.java Parādīt failu

@@ -26,6 +26,7 @@ import com.dmdirc.installer.TextStep;
26 26
 
27 27
 import java.awt.BorderLayout;
28 28
 
29
+import java.awt.Image;
29 30
 import javax.swing.JScrollPane;
30 31
 import javax.swing.SwingUtilities;
31 32
 
@@ -63,6 +64,18 @@ public final class StepInstall extends SwingStep implements TextStep {
63 64
         return "Install";
64 65
     }
65 66
 
67
+    /** {@inheritDoc} */
68
+    @Override
69
+    public Image getIcon() {
70
+        return null;
71
+    }
72
+
73
+    /** {@inheritDoc} */
74
+    @Override
75
+    public String getStepDescription() {
76
+        return "";
77
+    }
78
+
66 79
     /** {@inheritDoc} */
67 80
     @Override
68 81
     public synchronized void addText(final String text) {

+ 13
- 0
src/com/dmdirc/installer/ui/StepSettings.java Parādīt failu

@@ -29,6 +29,7 @@ import com.dmdirc.installer.Installer.ShortcutType;
29 29
 
30 30
 import java.awt.GridBagConstraints;
31 31
 import java.awt.GridBagLayout;
32
+import java.awt.Image;
32 33
 import java.awt.Insets;
33 34
 import javax.swing.Box;
34 35
 import javax.swing.JCheckBox;
@@ -122,6 +123,18 @@ public final class StepSettings extends SwingStep implements Settings {
122 123
         return "Settings";
123 124
     }
124 125
 
126
+    /** {@inheritDoc} */
127
+    @Override
128
+    public Image getIcon() {
129
+        return null;
130
+    }
131
+
132
+    /** {@inheritDoc} */
133
+    @Override
134
+    public String getStepDescription() {
135
+        return "";
136
+    }
137
+
125 138
     /** {@inheritDoc} */
126 139
     @Override
127 140
     public boolean getShortcutMenuState() {

+ 15
- 1
src/com/dmdirc/installer/ui/StepWelcome.java Parādīt failu

@@ -19,10 +19,12 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
-
23 22
 package com.dmdirc.installer.ui;
24 23
 
25 24
 import java.awt.BorderLayout;
25
+import java.awt.Image;
26
+import java.awt.Toolkit;
27
+import java.net.URL;
26 28
 
27 29
 /**
28 30
  * Tells the user what this application does
@@ -61,4 +63,16 @@ public final class StepWelcome extends SwingStep {
61 63
     public String getStepName() {
62 64
         return "Welcome";
63 65
     }
66
+
67
+    /** {@inheritDoc} */
68
+    @Override
69
+    public Image getIcon() {
70
+        return null;
71
+    }
72
+
73
+    /** {@inheritDoc} */
74
+    @Override
75
+    public String getStepDescription() {
76
+        return "";
77
+    }
64 78
 }

+ 28
- 10
src/com/dmdirc/installer/ui/TitlePanel.java Parādīt failu

@@ -23,12 +23,12 @@
23 23
 
24 24
 package com.dmdirc.installer.ui;
25 25
 
26
+import com.dmdirc.installer.Step;
26 27
 import com.dmdirc.installer.ui.EtchedLineBorder.BorderSide;
27 28
 
28 29
 import java.awt.BorderLayout;
29 30
 import java.awt.Color;
30 31
 
31
-import java.awt.Toolkit;
32 32
 import javax.swing.ImageIcon;
33 33
 import javax.swing.JLabel;
34 34
 import javax.swing.JPanel;
@@ -41,22 +41,25 @@ public class TitlePanel extends JPanel {
41 41
 
42 42
     private static final long serialVersionUID = 7173184984913948951L;
43 43
     private final JLabel title;
44
+    private final JLabel image;
44 45
 
45 46
     /**
46 47
      * Instantiates a new title panel.
47 48
      * 
48
-     * @param titleText Initial title text
49
+     * @param step Initial title text
49 50
      */
50
-    public TitlePanel(final String titleText) {
51
+    public TitlePanel(final Step step) {
51 52
         super(new BorderLayout());
52
-        title = new JLabel(titleText);
53
+        
54
+        title = new JLabel();
55
+        image = new JLabel();
56
+        
57
+        setStep(step);
53 58
 
54 59
         title.setFont(title.getFont().deriveFont((float) (title.getFont().
55 60
                 getSize() * 1.5)));
56 61
         add(title, BorderLayout.CENTER);
57
-        add(new JLabel(new ImageIcon(Toolkit.getDefaultToolkit().createImage(Thread.
58
-                currentThread().getContextClassLoader().getResource(
59
-                "com/dmdirc/res/icon.png")))), BorderLayout.EAST);
62
+        add(image, BorderLayout.EAST);
60 63
         setBackground(Color.WHITE);
61 64
         setBorder(new EtchedLineBorder(EtchedBorder.RAISED, BorderSide.BOTTOM));
62 65
     }
@@ -64,9 +67,24 @@ public class TitlePanel extends JPanel {
64 67
     /**
65 68
      * Sets the title text.
66 69
      *
67
-     * @param titleText new title text
70
+     * @param step new title text
68 71
      */
69
-    public void setText(final String titleText) {
70
-        title.setText(titleText);
72
+    public void setStep(final Step step) {
73
+        if (step == null) {
74
+            title.setText("");
75
+            image.setIcon(null);
76
+            return;
77
+        }
78
+        
79
+        if ("".equals(step.getStepDescription())) {
80
+            title.setText(step.getStepName());
81
+        } else {
82
+            title.setText(step.getStepName() + "\n" + step.getStepDescription());
83
+        }
84
+        if (step.getIcon() == null) {
85
+            image.setIcon(null);
86
+        } else {
87
+            image.setIcon(new ImageIcon(step.getIcon()));
88
+        }
71 89
     }
72 90
 }

+ 4
- 0
src/com/dmdirc/installer/ui/WizardControlPanel.java Parādīt failu

@@ -132,6 +132,10 @@ public class WizardControlPanel extends JPanel {
132 132
         updateProgressLabel();
133 133
         if (step + 1 == total) {
134 134
             next.setText("Finish");
135
+        } else if (step == 0) {
136
+            prev.setEnabled(false);
137
+        } else if (step > 0) {
138
+            prev.setEnabled(true);
135 139
         } else {
136 140
             next.setText("Next \u00BB");
137 141
         }

Notiek ielāde…
Atcelt
Saglabāt