2 Java class GenListDialog.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
15 import java
.awt
.BorderLayout
;
16 import java
.awt
.Dimension
;
17 import java
.awt
.Toolkit
;
19 import javax
.swing
.JPanel
;
20 import javax
.swing
.JDialog
;
22 import javax
.swing
.JButton
;
25 import java
.awt
.FlowLayout
;
26 import java
.awt
.event
.ActionEvent
;
27 import java
.awt
.event
.ActionListener
;
28 import java
.util
.Vector
;
30 import javax
.swing
.JScrollPane
;
32 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
36 Dialog for List generation.
37 @since PackageEditor 1.0
39 public class GenListDialog
extends JDialog
implements ActionListener
{
44 private static final long serialVersionUID
= 1L;
46 private JPanel jContentPane
= null;
47 private JPanel jPanel
= null;
48 private JPanel jPanel1
= null;
49 private JPanel jPanel2
= null;
50 private JPanel jPanel3
= null;
51 private JPanel jPanel4
= null;
52 private JButton jButton
= null;
53 private JButton jButton1
= null;
54 private JButton jButton2
= null;
55 private ICheckBoxList checkBoxList
= null;
58 private JScrollPane jScrollPane
= null;
62 public void actionPerformed(ActionEvent arg0
) {
63 // TODO Auto-generated method stub
64 if (arg0
.getSource() == jButton1
){
65 checkBoxList
.setAllItemsUnchecked();
68 if (arg0
.getSource() == jButton2
){
73 if (arg0
.getSource() == jButton
){
79 * This method initializes jPanel
81 * @return javax.swing.JPanel
83 private JPanel
getJPanel() {
85 FlowLayout flowLayout
= new FlowLayout();
86 flowLayout
.setVgap(10);
87 jPanel
= new JPanel();
88 jPanel
.setLayout(flowLayout
);
89 jPanel
.setPreferredSize(new java
.awt
.Dimension(100,30));
90 jPanel
.add(getJButton1(), null);
91 jPanel
.add(getJButton2(), null);
92 jPanel
.add(getJButton(), null);
98 * This method initializes jPanel1
100 * @return javax.swing.JPanel
102 private JPanel
getJPanel1() {
103 if (jPanel1
== null) {
104 jPanel1
= new JPanel();
110 * This method initializes jPanel2
112 * @return javax.swing.JPanel
114 private JPanel
getJPanel2() {
115 if (jPanel2
== null) {
116 jPanel2
= new JPanel();
122 * This method initializes jPanel3
124 * @return javax.swing.JPanel
126 private JPanel
getJPanel3() {
127 if (jPanel3
== null) {
128 jPanel3
= new JPanel();
134 * This method initializes jPanel4
136 * @return javax.swing.JPanel
138 private JPanel
getJPanel4() {
139 if (jPanel4
== null) {
140 jPanel4
= new JPanel();
141 jPanel4
.setLayout(new FlowLayout());
142 jPanel4
.add(getJScrollPane(), null);
149 * This method initializes jButton
151 * @return javax.swing.JButton
153 private JButton
getJButton() {
154 if (jButton
== null) {
155 jButton
= new JButton();
156 jButton
.setPreferredSize(new java
.awt
.Dimension(80,20));
157 jButton
.setText("Cancel");
158 jButton
.addActionListener(this);
164 * This method initializes jButton1
166 * @return javax.swing.JButton
168 private JButton
getJButton1() {
169 if (jButton1
== null) {
170 jButton1
= new JButton();
171 jButton1
.setPreferredSize(new java
.awt
.Dimension(80,20));
172 jButton1
.setHorizontalTextPosition(javax
.swing
.SwingConstants
.LEADING
);
173 jButton1
.setText("Clear");
174 jButton1
.setVisible(false);
175 jButton1
.addActionListener(this);
181 * This method initializes jButton2
183 * @return javax.swing.JButton
185 private JButton
getJButton2() {
186 if (jButton2
== null) {
187 jButton2
= new JButton();
188 jButton2
.setPreferredSize(new java
.awt
.Dimension(80,20));
189 jButton2
.setText("Ok");
190 jButton2
.setActionCommand("GenGuidValue");
191 jButton2
.addActionListener(this);
197 * This method initializes jScrollPane
199 * @return javax.swing.JScrollPane
201 private JScrollPane
getJScrollPane() {
202 if (jScrollPane
== null) {
203 jScrollPane
= new JScrollPane();
204 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(300,100));
205 jScrollPane
.setViewportView(getICheckBoxList());
210 private ICheckBoxList
getICheckBoxList() {
211 if (checkBoxList
== null) {
212 checkBoxList
= new ICheckBoxList();
213 checkBoxList
.setBounds(new java
.awt
.Rectangle(40,20,177,74));
214 // Vector<String> v = new Vector<String>();
215 // v.add("DATA_HUB_RECORD");
216 // v.add("EFI_EVENT");
217 // v.add("EFI_SYSTEM_CONFIGURATION_TABLE");
218 // v.add("EFI_VARIABLE");
220 // v.add("HII_PACKAGE_LIST");
222 // v.add("TOKEN_SPACE_GUID");
224 // checkBoxList.setAllItems(v);
229 public void initList(Vector
<String
> v
){
230 checkBoxList
.setAllItems(v
);
232 public Vector
<String
> getList(){
233 Vector
<String
> v
= checkBoxList
.getAllCheckedItemsString();
237 public void setList(String s
){
238 Vector
<String
> v
= new Vector
<String
>();
240 checkBoxList
.setAllItemsUnchecked();
243 String
[] sArray
= s
.split(" ");
244 for (int i
= 0; i
< sArray
.length
; ++i
){
247 checkBoxList
.initCheckedItem(true, v
);
250 * This is the default constructor
252 public GenListDialog() {
257 public GenListDialog(ActionListener i
){
259 jButton2
.addActionListener(i
);
264 * This method initializes this
268 private void initialize() {
269 this.setSize(466, 157);
270 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
272 this.setTitle("List");
273 this.setContentPane(getJContentPane());
278 * This method initializes jContentPane
280 * @return javax.swing.JPanel
282 private JPanel
getJContentPane() {
283 if (jContentPane
== null) {
284 jContentPane
= new JPanel();
285 jContentPane
.setLayout(new BorderLayout());
286 jContentPane
.add(getJPanel(), java
.awt
.BorderLayout
.EAST
);
287 jContentPane
.add(getJPanel1(), java
.awt
.BorderLayout
.WEST
);
288 jContentPane
.add(getJPanel2(), java
.awt
.BorderLayout
.NORTH
);
289 jContentPane
.add(getJPanel3(), java
.awt
.BorderLayout
.SOUTH
);
290 jContentPane
.add(getJPanel4(), java
.awt
.BorderLayout
.CENTER
);
296 Start the window at the center of screen
299 protected void centerWindow(int intWidth
, int intHeight
) {
300 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
301 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
305 Start the window at the center of screen
308 protected void centerWindow() {
309 centerWindow(this.getSize().width
, this.getSize().height
);
314 } // @jve:decl-index=0:visual-constraint="10,10"