]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/CreateMdkPkg/src/org/tianocore/packaging/workspace/ui/LicenseAgreement.java
Initial import.
[mirror_edk2.git] / Tools / Source / CreateMdkPkg / src / org / tianocore / packaging / workspace / ui / LicenseAgreement.java
1 /** @file
2
3 The class is used to show a License Agreement page in
4 the process of setup
5
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 package org.tianocore.packaging.workspace.ui;
18
19 import java.awt.event.ActionEvent;
20 import java.awt.event.ActionListener;
21 import java.awt.event.WindowEvent;
22
23 import javax.swing.JButton;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JRadioButton;
27 import javax.swing.JScrollPane;
28 import javax.swing.JTextArea;
29
30 import org.tianocore.packaging.common.ui.IFrame;
31
32 /**
33 The class is used to show a License Agreement page in
34 the process of setup
35
36 @since CreateMdkPkg 1.0
37
38 **/
39 public class LicenseAgreement extends IFrame implements ActionListener {
40
41 ///
42 /// Define class Serial Version UID
43 ///
44 private static final long serialVersionUID = 5507683268692334188L;
45
46 //
47 // Define class members
48 //
49 private JPanel jContentPane = null;
50
51 private JTextArea jTextArea = null;
52
53 private JTextArea jTextArea1 = null;
54
55 private JPanel jPanel = null;
56
57 private JButton jButtonBack = null;
58
59 private JButton jButtonNext = null;
60
61 private JButton jButtonCancel = null;
62
63 private JLabel jLabel = null;
64
65 private JRadioButton jRadioButtonAgree = null;
66
67 private JRadioButton jRadioButtonDisagree = null;
68
69 private JScrollPane jScrollPane = null;
70
71 private JTextArea jTextArea2 = null;
72
73 private JLabel jLabel1 = null;
74
75 private Welcome w = null;
76
77 private SelectDestinationDirectory sdd = null;
78
79 /**
80 This method initializes jTextArea
81
82 @return javax.swing.JTextArea jTextArea
83
84 **/
85 private JTextArea getJTextArea() {
86 if (jTextArea == null) {
87 jTextArea = new JTextArea();
88 jTextArea.setLocation(new java.awt.Point(0, 0));
89 jTextArea.setText(" License Agreement");
90 jTextArea.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
91 jTextArea.setEditable(false);
92 jTextArea.setSize(new java.awt.Dimension(495, 20));
93 }
94 return jTextArea;
95 }
96
97 /**
98 This method initializes jTextArea1
99
100 @return javax.swing.JTextArea jTextArea1
101
102 **/
103 private JTextArea getJTextArea1() {
104 if (jTextArea1 == null) {
105 jTextArea1 = new JTextArea();
106 jTextArea1.setLocation(new java.awt.Point(0, 20));
107 jTextArea1.setText(" Please read the following important information before continuing.");
108 jTextArea1.setEditable(false);
109 jTextArea1.setSize(new java.awt.Dimension(495, 35));
110 }
111 return jTextArea1;
112 }
113
114 /**
115 This method initializes jPanel
116
117 @return javax.swing.JPanel jPanel
118
119 **/
120 private JPanel getJPanel() {
121 if (jPanel == null) {
122 jLabel1 = new JLabel();
123 jLabel1.setText(" this agreement before continuing with the installation.");
124 jLabel1.setLocation(new java.awt.Point(30, 35));
125 jLabel1.setSize(new java.awt.Dimension(435, 20));
126 jLabel = new JLabel();
127 jLabel.setText("Please read the following License Agreement. You must accept the terms of");
128 jLabel.setLocation(new java.awt.Point(30, 15));
129 jLabel.setSize(new java.awt.Dimension(435, 20));
130 jPanel = new JPanel();
131 jPanel.setLayout(null);
132 jPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
133 jPanel.setSize(new java.awt.Dimension(494, 251));
134 jPanel.setLocation(new java.awt.Point(0, 55));
135 jPanel.add(jLabel, null);
136 jPanel.add(getJRadioButtonAgree(), null);
137 jPanel.add(getJRadioButtonDisagree(), null);
138 jPanel.add(getJScrollPane(), null);
139 jPanel.add(jLabel1, null);
140 }
141 return jPanel;
142 }
143
144 /**
145 This method initializes jButtonBack
146
147 @return javax.swing.JButton jButtonBack
148
149 **/
150 private JButton getJButtonBack() {
151 if (jButtonBack == null) {
152 jButtonBack = new JButton();
153 jButtonBack.setText("Back");
154 jButtonBack.setSize(new java.awt.Dimension(90, 20));
155 jButtonBack.setLocation(new java.awt.Point(200, 315));
156 jButtonBack.setMnemonic('B');
157 jButtonBack.addActionListener(this);
158 }
159 return jButtonBack;
160 }
161
162 /**
163 This method initializes jButtonNext
164
165 @return javax.swing.JButton jButtonNext
166
167 **/
168 private JButton getJButtonNext() {
169 if (jButtonNext == null) {
170 jButtonNext = new JButton();
171 jButtonNext.setText("Next");
172 jButtonNext.setBounds(new java.awt.Rectangle(292, 315, 90, 20));
173 jButtonNext.setEnabled(false);
174 jButtonNext.setMnemonic('N');
175 jButtonNext.addActionListener(this);
176 }
177 return jButtonNext;
178 }
179
180 /**
181 This method initializes jButtonCancel
182
183 @return javax.swing.JButton jButtonCancel
184
185 **/
186 private JButton getJButtonCancel() {
187 if (jButtonCancel == null) {
188 jButtonCancel = new JButton();
189 jButtonCancel.setText("Cancel");
190 jButtonCancel.setBounds(new java.awt.Rectangle(390, 315, 90, 20));
191 jButtonCancel.setMnemonic('C');
192 jButtonCancel.addActionListener(this);
193 }
194 return jButtonCancel;
195 }
196
197 /**
198 This method initializes jRadioButtonAgree
199
200 @return javax.swing.JRadioButton jRadioButtonAgree
201
202 **/
203 private JRadioButton getJRadioButtonAgree() {
204 if (jRadioButtonAgree == null) {
205 jRadioButtonAgree = new JRadioButton();
206 jRadioButtonAgree.setText("I accept the agreement");
207 jRadioButtonAgree.setLocation(new java.awt.Point(30, 200));
208 jRadioButtonAgree.setSize(new java.awt.Dimension(156, 19));
209 jRadioButtonAgree.addActionListener(this);
210 }
211 return jRadioButtonAgree;
212 }
213
214 /**
215 This method initializes jRadioButtonDisagree
216
217 @return javax.swing.JRadioButton jRadioButtonDisagree
218
219 **/
220 private JRadioButton getJRadioButtonDisagree() {
221 if (jRadioButtonDisagree == null) {
222 jRadioButtonDisagree = new JRadioButton();
223 jRadioButtonDisagree.setText("I do not accept the agreement");
224 jRadioButtonDisagree.setLocation(new java.awt.Point(30, 220));
225 jRadioButtonDisagree.setSize(new java.awt.Dimension(248, 19));
226 jRadioButtonDisagree.addActionListener(this);
227 }
228 return jRadioButtonDisagree;
229 }
230
231 /**
232 This method initializes jScrollPane
233
234 @return javax.swing.JScrollPane jScrollPane
235
236 **/
237 private JScrollPane getJScrollPane() {
238 if (jScrollPane == null) {
239 jScrollPane = new JScrollPane();
240 jScrollPane.setSize(new java.awt.Dimension(435, 140));
241 jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
242 jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
243 jScrollPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
244 jScrollPane.setViewportView(getJTextArea2());
245 jScrollPane.setLocation(new java.awt.Point(30, 55));
246 }
247 return jScrollPane;
248 }
249
250 /**
251 This method initializes jTextArea2
252
253 @return javax.swing.JTextArea jTextArea2
254
255 **/
256 private JTextArea getJTextArea2() {
257 if (jTextArea2 == null) {
258 jTextArea2 = new JTextArea();
259 jTextArea2.setEditable(false);
260 jTextArea2.setWrapStyleWord(false);
261 jTextArea2.setLineWrap(true);
262 jTextArea2.setText("Copyright (c) 2006, Intel Corp.\n"
263 + "All rights reserved. This program and the accompanying materials "
264 + "are licensed and made available under the terms and conditions of the BSD License "
265 + "which may be found at http://opensource.org/licenses/bsd-license.php\n\n\n"
266 + "THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, "
267 + "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.");
268 }
269 return jTextArea2;
270 }
271
272 /**
273 Main class, used for test
274
275 @param args
276
277 **/
278 public static void main(String[] args) {
279 LicenseAgreement la = new LicenseAgreement();
280 la.setVisible(true);
281 }
282
283 /**
284 This is the default constructor
285
286 **/
287 public LicenseAgreement() {
288 super();
289 init();
290 }
291
292 /**
293 This is the override constructor
294
295 @param welcome The input data of Welcome
296
297 **/
298 public LicenseAgreement(Welcome welcome) {
299 super();
300 init();
301 w = welcome;
302 }
303
304 /**
305 This method initializes this
306
307 **/
308 private void init() {
309 this.setSize(500, 390);
310 this.setContentPane(getJContentPane());
311 this.setTitle("Setup - License Agreement");
312 this.centerWindow();
313 this.getRootPane().setDefaultButton(jButtonNext);
314 }
315
316 /**
317 This method initializes jContentPane
318
319 @return javax.swing.JPanel jContentPane
320
321 **/
322 private JPanel getJContentPane() {
323 if (jContentPane == null) {
324 jContentPane = new JPanel();
325 jContentPane.setLayout(null);
326 jContentPane.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
327 jContentPane.add(getJTextArea(), null);
328 jContentPane.add(getJTextArea1(), null);
329 jContentPane.add(getJPanel(), null);
330 jContentPane.add(getJButtonBack(), null);
331 jContentPane.add(getJButtonNext(), null);
332 jContentPane.add(getJButtonCancel(), null);
333 }
334 return jContentPane;
335 }
336
337 /* (non-Javadoc)
338 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
339 *
340 * Override actionPerformed to listen all actions
341 *
342 */
343 public void actionPerformed(ActionEvent arg0) {
344 Object obj = arg0.getSource();
345 //
346 // Disable button next when select jRadioButtonDisagree
347 //
348 if (obj == jRadioButtonDisagree) {
349 if (jRadioButtonDisagree.isSelected()) {
350 jRadioButtonAgree.setSelected(false);
351 jButtonNext.setEnabled(false);
352 jButtonNext.setFocusable(false);
353 }
354 if (!jRadioButtonAgree.isSelected() && !jRadioButtonDisagree.isSelected()) {
355 jRadioButtonDisagree.setSelected(true);
356 }
357 }
358
359 //
360 // Enable button next when select jRadioButtonAgree
361 //
362 if (obj == jRadioButtonAgree) {
363 if (jRadioButtonAgree.isSelected()) {
364 jRadioButtonDisagree.setSelected(false);
365 jButtonNext.setEnabled(true);
366 jButtonNext.setFocusable(true);
367 }
368 if (!jRadioButtonAgree.isSelected() && !jRadioButtonDisagree.isSelected()) {
369 jRadioButtonAgree.setSelected(true);
370 }
371 }
372
373 if (obj == jButtonBack) {
374 this.setVisible(false);
375 w.setVisible(true);
376 }
377
378 //
379 // Show next page when click button Next
380 //
381 if (obj == jButtonNext) {
382 if (sdd == null) {
383 sdd = new SelectDestinationDirectory(this);
384 }
385 this.setVisible(false);
386 sdd.setVisible(true);
387 }
388
389 if (obj == jButtonCancel) {
390 this.onExit();
391 }
392 }
393
394 /* (non-Javadoc)
395 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
396 *
397 * Override windowClosing to show confirm quit dialog
398 *
399 */
400 public void windowClosing(WindowEvent arg0) {
401 this.onExit();
402 }
403 }