1
2
3
4 package ca.spaz.cron.user;
5
6 import java.awt.*;
7
8 import javax.swing.*;
9
10 import ca.spaz.cron.CRONOMETER;
11 import ca.spaz.cron.targets.TargetEditor;
12 import ca.spaz.wizard.*;
13
14 public class NewUserWizard {
15 private static final String SETUP_NEW_USER = "Setup New User";
16
17 public static void createNewUser(User user) {
18 Wizard w = new Wizard(CRONOMETER.getInstance(), SETUP_NEW_USER);
19
20 w.addWizardPanel(new IntroductionPanel());
21
22 w.addWizardPanel(new USDAImportWizardPanel());
23
24 w.addWizardPanel(new UserInfoWizardPanel(user));
25 w.addWizardPanel(new TargetsPanel(user));
26
27 w.addWizardPanel(new WizardPanel() {
28 public String getWizardPanelTitle() {
29 return "Preferences";
30 }
31 public void commitChanges() {
32 }
33 public boolean isValid() {
34 return true;
35 }
36 });
37
38 w.startWizard();
39 }
40
41
42 public static class IntroductionPanel extends WizardPanel {
43 public IntroductionPanel() {
44 JLabel info = new JLabel("<html><div align=\"center\">" +
45 "The following wizard will guide you through creating " +
46 "a new user profile. More blather, welcomes, and exciting " +
47 "instructions can go here. Hoorah. Perhaps even some pretty " +
48 "pictures of smiling people eating celery.</div>"+
49 "</html>", JLabel.CENTER);
50 info.setPreferredSize(new Dimension(200,200));
51 this.setLayout(new BorderLayout());
52 this.setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
53 this.add(info, BorderLayout.NORTH);
54 }
55
56 public String getWizardPanelTitle() {
57 return "Introduction";
58 }
59
60 public void commitChanges() {}
61 public boolean isValid() {
62 return true;
63 }
64 }
65
66 public static class TargetsPanel extends WizardPanel {
67 public TargetsPanel(User user) {
68 this.setLayout(new BorderLayout());
69 this.add(new TargetEditor(user), BorderLayout.CENTER);
70 }
71
72 public String getWizardPanelTitle() {
73 return "Targets";
74 }
75
76 public void commitChanges() {}
77
78 public boolean isValid() {
79 return true;
80 }
81 }
82
83
84 }