1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package coras.client.ui;
22
23 import java.awt.Frame;
24
25 import javax.swing.JDialog;
26
27 import javax.swing.JButton;
28 /***
29 * @author fvr
30 *
31 * To change the template for this generated type comment go to
32 * Window - Preferences - Java - Code Generation - Code and Comments
33 */
34 public class StartupWizard extends JDialog {
35
36 public static final int CREATE_PROJECT = 1;
37 public static final int OPEN_PROJECT = 2;
38 public static final int START_USING = 3;
39 public static final int QUIT = 4;
40
41 private javax.swing.JPanel jContentPane = null;
42
43 private javax.swing.JButton newProjectButton = null;
44 private javax.swing.JButton openProjectButton = null;
45 private javax.swing.JButton quitButton = null;
46
47 private int result = 0;
48
49 private JButton startUsingButton = null;
50 /***
51 * This is the default constructor
52 */
53 public StartupWizard() {
54 this(null);
55 }
56
57 public StartupWizard(Frame owner) {
58 super(owner);
59 initialize();
60 }
61
62 public int getResult() {
63 return result;
64 }
65
66 /***
67 * This method initializes this
68 *
69 * @return void
70 */
71 private void initialize() {
72
73 this.setBounds(0, 0, 200, 200);
74 this.setContentPane(getJContentPane());
75 this.setTitle("Startup wizard");
76 this.setModal(true);
77 this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
78 }
79 /***
80 * This method initializes jContentPane
81 *
82 * @return javax.swing.JPanel
83 */
84 private javax.swing.JPanel getJContentPane() {
85 if(jContentPane == null) {
86 jContentPane = new javax.swing.JPanel();
87 java.awt.GridLayout layGridLayout5 = new java.awt.GridLayout();
88 jContentPane.setLayout(layGridLayout5);
89 layGridLayout5.setRows(4);
90 layGridLayout5.setColumns(1);
91 layGridLayout5.setHgap(5);
92 layGridLayout5.setVgap(5);
93 jContentPane.add(getNewProjectButton(), null);
94 jContentPane.add(getOpenProjectButton(), null);
95 jContentPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(5,5,5,5));
96 jContentPane.add(getStartUsingButton(), null);
97 jContentPane.add(getQuitButton(), null);
98 }
99 return jContentPane;
100 }
101 /***
102 * This method initializes jButton
103 *
104 * @return javax.swing.JButton
105 */
106 private javax.swing.JButton getNewProjectButton() {
107 if (newProjectButton == null) {
108 newProjectButton = new javax.swing.JButton();
109 newProjectButton.setText("Create new project");
110 newProjectButton.setMnemonic(java.awt.event.KeyEvent.VK_N);
111 newProjectButton.addActionListener(new java.awt.event.ActionListener() {
112 public void actionPerformed(java.awt.event.ActionEvent e) {
113 result = CREATE_PROJECT;
114 dispose();
115 }
116 });
117 }
118 return newProjectButton;
119 }
120 /***
121 * This method initializes jButton
122 *
123 * @return javax.swing.JButton
124 */
125 private javax.swing.JButton getOpenProjectButton() {
126 if (openProjectButton == null) {
127 openProjectButton = new javax.swing.JButton();
128 openProjectButton.setText("Open project");
129 openProjectButton.setMnemonic(java.awt.event.KeyEvent.VK_O);
130 openProjectButton.addActionListener(new java.awt.event.ActionListener() {
131 public void actionPerformed(java.awt.event.ActionEvent e) {
132 result = OPEN_PROJECT;
133 dispose();
134 }
135 });
136 }
137 return openProjectButton;
138 }
139 /***
140 * This method initializes jButton1
141 *
142 * @return javax.swing.JButton
143 */
144 private javax.swing.JButton getQuitButton() {
145 if (quitButton == null) {
146 quitButton = new javax.swing.JButton();
147 quitButton.setText("Exit tool");
148 quitButton.setMnemonic(java.awt.event.KeyEvent.VK_X);
149 quitButton.addActionListener(new java.awt.event.ActionListener() {
150 public void actionPerformed(java.awt.event.ActionEvent e) {
151 result = QUIT;
152 dispose();
153 }
154 });
155 }
156 return quitButton;
157 }
158 /***
159 * This method initializes jButton
160 *
161 * @return javax.swing.JButton
162 */
163 private JButton getStartUsingButton() {
164 if (startUsingButton == null) {
165 startUsingButton = new JButton();
166 startUsingButton.setText("Start using CORAS tool");
167 startUsingButton.setMnemonic(java.awt.event.KeyEvent.VK_S);
168 startUsingButton.addActionListener(new java.awt.event.ActionListener() {
169 public void actionPerformed(java.awt.event.ActionEvent e) {
170 result = START_USING;
171 dispose();
172 }
173 });
174 }
175 return startUsingButton;
176 }
177 }