Browse Source

Fixes issue 934: Migration Wizard and First Run Wizard

git-svn-id: http://svn.dmdirc.com/trunk@3563 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Gregory Holmes 16 years ago
parent
commit
3ed787e774

+ 11
- 6
src/com/dmdirc/ui/swing/SwingController.java View File

@@ -84,7 +84,7 @@ public final class SwingController implements UIController {
84 84
     public synchronized MainFrame getMainWindow() {
85 85
         return getMainFrame();
86 86
     }
87
-    
87
+
88 88
     /**
89 89
      * Retrieves the main window used by this UI.
90 90
      *
@@ -192,22 +192,27 @@ public final class SwingController implements UIController {
192 192
             /** {@inheritDoc} */
193 193
             @Override
194 194
             public void run() {
195
-                wizard = new SwingFirstRunWizard(firstRun);
196
-                wizard.display();
197
-                wizard.getWizardDialog().addWizardListener(new WizardListener() {
195
+                final WizardListener listener = new WizardListener() {
198 196
 
197
+                    /** {@inheritDoc} */
198
+                    @Override
199 199
                     public void wizardFinished() {
200 200
                         synchronized (SwingController.this) {
201 201
                             SwingController.this.notifyAll();
202 202
                         }
203 203
                     }
204 204
 
205
+                    /** {@inheritDoc} */
206
+                    @Override
205 207
                     public void wizardCancelled() {
206 208
                         synchronized (SwingController.this) {
207 209
                             SwingController.this.notifyAll();
208 210
                         }
209 211
                     }
210
-                });
212
+                };
213
+                wizard = new SwingFirstRunWizard(firstRun);
214
+                wizard.getWizardDialog().addWizardListener(listener);
215
+                wizard.display();
211 216
             }
212 217
             });
213 218
         try {
@@ -371,7 +376,7 @@ public final class SwingController implements UIController {
371 376
             }
372 377
         });
373 378
     }
374
-    
379
+
375 380
     /** {@inheritDoc} */
376 381
     @Override
377 382
     public String getUserInput(final String prompt) {

+ 3
- 7
src/com/dmdirc/ui/swing/components/SwingInputField.java View File

@@ -31,9 +31,6 @@ import java.awt.event.ActionEvent;
31 31
 import java.awt.event.ActionListener;
32 32
 import java.awt.event.KeyListener;
33 33
 
34
-import java.util.Map;
35
-import javax.swing.ActionMap;
36
-import javax.swing.InputMap;
37 34
 import javax.swing.JLabel;
38 35
 import javax.swing.JTextField;
39 36
 import javax.swing.event.DocumentEvent;
@@ -58,10 +55,6 @@ public class SwingInputField extends JTextComponent implements InputField,
58 55
     private JTextField textField;
59 56
     /** Line wrap indicator. */
60 57
     private JLabel wrapIndicator;
61
-    /** Action maps. */
62
-    private Map<Integer, ActionMap> actionsMaps;
63
-    /** Input maps. */
64
-    private Map<Integer, InputMap> inputMaps;
65 58
 
66 59
     /**
67 60
      * Instantiates a new swing input field.
@@ -211,6 +204,7 @@ public class SwingInputField extends JTextComponent implements InputField,
211 204
      * 
212 205
      * @param clipboard Text to replace selection with
213 206
      */
207
+    @Override
214 208
     public void replaceSelection(String clipboard) {
215 209
         textField.replaceSelection(clipboard);
216 210
     }
@@ -220,6 +214,7 @@ public class SwingInputField extends JTextComponent implements InputField,
220 214
      * 
221 215
      * @param optionColour Colour for the caret
222 216
      */
217
+    @Override
223 218
     public void setCaretColor(Color optionColour) {
224 219
         textField.setCaretColor(optionColour);
225 220
     }
@@ -241,6 +236,7 @@ public class SwingInputField extends JTextComponent implements InputField,
241 236
      */
242 237
     @Override
243 238
     public void setBackground(Color optionColour) {
239
+        System.out.println(textField);
244 240
         textField.setBackground(optionColour);
245 241
     }
246 242
 

+ 1
- 1
src/com/dmdirc/ui/swing/dialogs/wizard/WizardDialog.java View File

@@ -134,7 +134,7 @@ public final class WizardDialog extends StandardDialog implements ActionListener
134 134
      * @param step Step to add
135 135
      */
136 136
     public void addStep(final Step step) {
137
-        wizard.add(step);
137
+        wizard.addStep(step);
138 138
     }
139 139
     
140 140
     /**

+ 42
- 22
src/com/dmdirc/ui/swing/dialogs/wizard/WizardPanel.java View File

@@ -124,7 +124,8 @@ public class WizardPanel extends JPanel implements ActionListener,
124 124
         titlePanel.setBackground(Color.WHITE);
125 125
         titlePanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0,
126 126
                 Color.BLACK));
127
-        titlePanel.setBorder(new EtchedLineBorder(EtchedBorder.LOWERED, BorderSide.BOTTOM));
127
+        titlePanel.setBorder(new EtchedLineBorder(EtchedBorder.LOWERED,
128
+                BorderSide.BOTTOM));
128 129
 
129 130
         final JPanel progressPanel = new JPanel(new MigLayout("fill"));
130 131
         progressPanel.add(progressLabel, "growx");
@@ -132,7 +133,8 @@ public class WizardPanel extends JPanel implements ActionListener,
132 133
         progressPanel.add(next, "sg button");
133 134
         progressPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0,
134 135
                 Color.BLACK));
135
-        progressPanel.setBorder(new EtchedLineBorder(EtchedBorder.LOWERED, BorderSide.TOP));
136
+        progressPanel.setBorder(new EtchedLineBorder(EtchedBorder.LOWERED,
137
+                BorderSide.TOP));
136 138
 
137 139
         setLayout(new MigLayout("fill, wrap 1, ins 0"));
138 140
         add(titlePanel, "growx");
@@ -258,7 +260,9 @@ public class WizardPanel extends JPanel implements ActionListener,
258 260
      * @param listener
259 261
      */
260 262
     public void addStepListener(final StepListener listener) {
261
-        stepListeners.add(StepListener.class, listener);
263
+        synchronized (stepListeners) {
264
+            stepListeners.add(StepListener.class, listener);
265
+        }
262 266
     }
263 267
 
264 268
     /**
@@ -267,7 +271,9 @@ public class WizardPanel extends JPanel implements ActionListener,
267 271
      * @param listener
268 272
      */
269 273
     public void removeStepListener(final StepListener listener) {
270
-        stepListeners.remove(StepListener.class, listener);
274
+        synchronized (stepListeners) {
275
+            stepListeners.remove(StepListener.class, listener);
276
+        }
271 277
     }
272 278
 
273 279
     /**
@@ -276,7 +282,9 @@ public class WizardPanel extends JPanel implements ActionListener,
276 282
      * @param listener
277 283
      */
278 284
     public void addWizardListener(final WizardListener listener) {
279
-        stepListeners.add(WizardListener.class, listener);
285
+        synchronized (stepListeners) {
286
+            stepListeners.add(WizardListener.class, listener);
287
+        }
280 288
     }
281 289
 
282 290
     /**
@@ -285,7 +293,9 @@ public class WizardPanel extends JPanel implements ActionListener,
285 293
      * @param listener
286 294
      */
287 295
     public void removeWizardListener(final WizardListener listener) {
288
-        stepListeners.remove(WizardListener.class, listener);
296
+        synchronized (stepListeners) {
297
+            stepListeners.remove(WizardListener.class, listener);
298
+        }
289 299
     }
290 300
 
291 301
     /**
@@ -294,10 +304,12 @@ public class WizardPanel extends JPanel implements ActionListener,
294 304
      * @param step Step to be displayed
295 305
      */
296 306
     private void fireStepAboutToBeDisplayed(final Step step) {
297
-        List<StepListener> listeners =
298
-                stepListeners.get(StepListener.class);
299
-        for (StepListener listener : listeners) {
300
-            listener.stepAboutToDisplay(step);
307
+        synchronized (stepListeners) {
308
+            List<StepListener> listeners =
309
+                    stepListeners.get(StepListener.class);
310
+            for (StepListener listener : listeners) {
311
+                listener.stepAboutToDisplay(step);
312
+            }
301 313
         }
302 314
     }
303 315
 
@@ -307,10 +319,12 @@ public class WizardPanel extends JPanel implements ActionListener,
307 319
      * @param step step thats been hidden
308 320
      */
309 321
     private void fireStepHidden(final Step step) {
310
-        List<StepListener> listeners =
311
-                stepListeners.get(StepListener.class);
312
-        for (StepListener listener : listeners) {
313
-            listener.stepHidden(step);
322
+        synchronized (stepListeners) {
323
+            List<StepListener> listeners =
324
+                    stepListeners.get(StepListener.class);
325
+            for (StepListener listener : listeners) {
326
+                listener.stepHidden(step);
327
+            }
314 328
         }
315 329
     }
316 330
 
@@ -318,10 +332,13 @@ public class WizardPanel extends JPanel implements ActionListener,
318 332
      * Fires wizard finished events.
319 333
      */
320 334
     private void fireWizardFinished() {
321
-        List<WizardListener> listeners =
322
-                stepListeners.get(WizardListener.class);
323
-        for (WizardListener listener : listeners) {
324
-            listener.wizardFinished();
335
+        synchronized (stepListeners) {
336
+            List<WizardListener> listeners =
337
+                    stepListeners.get(WizardListener.class);
338
+            for (WizardListener listener : listeners) {
339
+                System.out.println("finished: " + listener);
340
+                listener.wizardFinished();
341
+            }
325 342
         }
326 343
     }
327 344
 
@@ -329,10 +346,13 @@ public class WizardPanel extends JPanel implements ActionListener,
329 346
      * Fires wizard cancelled events.
330 347
      */
331 348
     protected void fireWizardCancelled() {
332
-        List<WizardListener> listeners =
333
-                stepListeners.get(WizardListener.class);
334
-        for (WizardListener listener : listeners) {
335
-            listener.wizardCancelled();
349
+        synchronized (stepListeners) {
350
+            List<WizardListener> listeners =
351
+                    stepListeners.get(WizardListener.class);
352
+            for (WizardListener listener : listeners) {
353
+                System.out.println("cancelled: " + listener);
354
+                listener.wizardCancelled();
355
+            }
336 356
         }
337 357
     }
338 358
 }

+ 9
- 13
src/com/dmdirc/ui/swing/dialogs/wizard/firstrun/SwingFirstRunWizard.java View File

@@ -36,7 +36,6 @@ import com.dmdirc.util.resourcemanager.ResourceManager;
36 36
 import java.io.File;
37 37
 import java.io.IOException;
38 38
 import java.util.ArrayList;
39
-import java.util.List;
40 39
 import java.util.Map;
41 40
 import java.util.Map.Entry;
42 41
 
@@ -61,6 +60,11 @@ public final class SwingFirstRunWizard implements WizardListener,
61 60
      */
62 61
     public SwingFirstRunWizard(final boolean firstRun) {
63 62
         this.firstRun = firstRun;
63
+        
64
+        wizardDialog =
65
+                new WizardDialog(firstRun ? "Setup wizard" : "Migration wizard",
66
+                new ArrayList<Step>(), this, null);
67
+        wizardDialog.addWizardListener(this);
64 68
     }
65 69
 
66 70
     /** {@inheritDoc} */
@@ -186,21 +190,13 @@ public final class SwingFirstRunWizard implements WizardListener,
186 190
     /** {@inheritDoc} */
187 191
     @Override
188 192
     public void display() {
189
-        final List<Step> steps =
190
-                new ArrayList<Step>();
191
-
192 193
         if (firstRun) {
193
-            steps.add(new FirstRunExtractionStep());
194
-            steps.add(new CommunicationStep());
195
-            steps.add(new ProfileStep());
194
+            wizardDialog.addStep(new FirstRunExtractionStep());
195
+            wizardDialog.addStep(new CommunicationStep());
196
+            wizardDialog.addStep(new ProfileStep());
196 197
         } else {
197
-            steps.add(new MigrationExtrationStep());
198
+            wizardDialog.addStep(new MigrationExtrationStep());
198 199
         }
199
-        
200
-        wizardDialog =
201
-                new WizardDialog(firstRun ? "Setup wizard" : "Migration wizard",
202
-                steps, this, null);
203
-        wizardDialog.addWizardListener(this);
204 200
         wizardDialog.display();
205 201
     }
206 202
 

Loading…
Cancel
Save