1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui;
21
22 import java.awt.Component;
23
24 import javax.swing.JOptionPane;
25
26 import org.xnap.XNap;
27 import org.xnap.gui.component.DefaultWizardDialog;
28 import org.xnap.gui.wizard.FilesWizardPanel;
29 import org.xnap.gui.wizard.GeneralWizardPanel;
30 import org.xnap.gui.wizard.IntroWizardPanel;
31 import org.xnap.gui.wizard.LicenseWizardPanel;
32 import org.xnap.gui.wizard.NetworkWizardPanel;
33 import org.xnap.gui.wizard.NoteWizardPanel;
34 import org.xnap.gui.wizard.PluginWizardPanel;
35 import org.xnap.util.Preferences;
36
37 public class StartupWizardDialog extends DefaultWizardDialog
38 {
39
40
41
42
43
44 boolean startup;
45
46 boolean noteRead = false;
47
48
49
50 public StartupWizardDialog(boolean startup)
51 {
52 this.startup = startup;
53
54 setTitle(XNap.tr("XNap Setup Wizard"));
55 setModal(true);
56
57 if (startup) {
58 addPanel(new IntroWizardPanel(this));
59 addPanel(new LicenseWizardPanel());
60 addPanel(new NoteWizardPanel());
61
62 getFinishAction().setEnabled(false);
63 getNextAction().setEnabled(false);
64 }
65 else {
66 noteRead = true;
67 }
68
69 addPanel(new GeneralWizardPanel());
70 addPanel(new FilesWizardPanel());
71 addPanel(new NetworkWizardPanel());
72 addPanel(new PluginWizardPanel());
73 }
74
75
76
77 public void close()
78 {
79 if (!isOkay() && startup) {
80 if (JOptionPane.showConfirmDialog
81 (this, XNap.tr("This will close XNap. Are you sure?"),
82 XNap.tr("Cancel"),
83 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE)
84 == JOptionPane.YES_OPTION) {
85 System.exit(0);
86 }
87 }
88 else {
89 if (startup) {
90 Preferences.getInstance().setSeenStartupWizard(true);
91 }
92 dispose();
93 }
94 }
95
96 public void setNoteRead(boolean noteRead)
97 {
98 this.noteRead = noteRead;
99 getFinishAction().setEnabled(noteRead);
100 }
101
102 public static void showDialog(Component c, boolean startup)
103 {
104 StartupWizardDialog me = new StartupWizardDialog(startup);
105 me.show(c);
106 }
107
108 protected void panelChanged(SettingsPanel panel)
109 {
110 if (panel instanceof IntroWizardPanel) {
111 ((IntroWizardPanel)panel).shown();
112 }
113 else if (panel instanceof PluginWizardPanel) {
114 ((PluginWizardPanel)panel).shown();
115 }
116 }
117
118 }