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
.JComponent
;
20 import javax
.swing
.JPanel
;
21 import javax
.swing
.JDialog
;
22 import javax
.swing
.KeyStroke
;
24 import javax
.swing
.JButton
;
27 import java
.awt
.FlowLayout
;
28 import java
.awt
.event
.ActionEvent
;
29 import java
.awt
.event
.ActionListener
;
30 import java
.awt
.event
.KeyEvent
;
31 import java
.util
.Vector
;
33 import javax
.swing
.JScrollPane
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
39 Dialog for List generation.
40 @since PackageEditor 1.0
42 public class GenListDialog
extends JDialog
implements ActionListener
{
47 private static final long serialVersionUID
= 1L;
49 private JPanel jContentPane
= null;
50 private JPanel jPanelContentEast
= null;
51 private JPanel jPanelContentCenter
= null;
52 private JButton jButtonCancel
= null;
53 private JButton jButtonOk
= null;
54 private ICheckBoxList checkBoxList
= null;
57 private JScrollPane jScrollPane
= null;
61 public void actionPerformed(ActionEvent arg0
) {
63 if (arg0
.getSource() == jButtonOk
){
68 if (arg0
.getSource() == jButtonCancel
){
74 * This method initializes jPanel
76 * @return javax.swing.JPanel
78 private JPanel
getJPanelContentEast() {
79 if (jPanelContentEast
== null) {
80 FlowLayout flowLayout
= new FlowLayout();
81 flowLayout
.setVgap(10);
82 jPanelContentEast
= new JPanel();
83 jPanelContentEast
.setLayout(flowLayout
);
84 jPanelContentEast
.setPreferredSize(new java
.awt
.Dimension(100,30));
85 jPanelContentEast
.add(getJButtonOk(), null);
86 jPanelContentEast
.add(getJButtonCancel(), null);
88 return jPanelContentEast
;
92 * This method initializes jPanel4
94 * @return javax.swing.JPanel
96 private JPanel
getJPanelContentCenter() {
97 if (jPanelContentCenter
== null) {
98 jPanelContentCenter
= new JPanel();
99 jPanelContentCenter
.setLayout(new FlowLayout());
100 jPanelContentCenter
.add(getJScrollPane(), null);
103 return jPanelContentCenter
;
107 * This method initializes jButton
109 * @return javax.swing.JButton
111 private JButton
getJButtonCancel() {
112 if (jButtonCancel
== null) {
113 jButtonCancel
= new JButton();
114 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(80,20));
115 jButtonCancel
.setText("Cancel");
116 jButtonCancel
.addActionListener(this);
117 jButtonCancel
.registerKeyboardAction(this, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
119 return jButtonCancel
;
123 * This method initializes jButton2
125 * @return javax.swing.JButton
127 private JButton
getJButtonOk() {
128 if (jButtonOk
== null) {
129 jButtonOk
= new JButton();
130 jButtonOk
.setPreferredSize(new java
.awt
.Dimension(80,20));
131 jButtonOk
.setText("Ok");
132 jButtonOk
.setActionCommand("GenGuidValue");
133 jButtonOk
.addActionListener(this);
139 * This method initializes jScrollPane
141 * @return javax.swing.JScrollPane
143 private JScrollPane
getJScrollPane() {
144 if (jScrollPane
== null) {
145 jScrollPane
= new JScrollPane();
146 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(300,100));
147 jScrollPane
.setViewportView(getICheckBoxList());
152 private ICheckBoxList
getICheckBoxList() {
153 if (checkBoxList
== null) {
154 checkBoxList
= new ICheckBoxList();
155 checkBoxList
.setBounds(new java
.awt
.Rectangle(40,20,177,74));
161 public void initList(Vector
<String
> v
){
162 checkBoxList
.setAllItems(v
);
164 public Vector
<String
> getList(){
165 Vector
<String
> v
= checkBoxList
.getAllCheckedItemsString();
169 public void setList(String s
){
170 Vector
<String
> v
= new Vector
<String
>();
172 checkBoxList
.setAllItemsUnchecked();
175 String
[] sArray
= s
.split(" ");
176 for (int i
= 0; i
< sArray
.length
; ++i
){
179 checkBoxList
.initCheckedItem(true, v
);
182 * This is the default constructor
184 public GenListDialog() {
189 public GenListDialog(ActionListener i
){
191 jButtonOk
.addActionListener(i
);
192 jButtonOk
.registerKeyboardAction(i
, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
196 * This method initializes this
200 private void initialize() {
201 this.setSize(466, 157);
202 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
204 this.setTitle("List");
205 this.setContentPane(getJContentPane());
210 * This method initializes jContentPane
212 * @return javax.swing.JPanel
214 private JPanel
getJContentPane() {
215 if (jContentPane
== null) {
216 jContentPane
= new JPanel();
217 jContentPane
.setLayout(new BorderLayout());
218 jContentPane
.add(getJPanelContentEast(), java
.awt
.BorderLayout
.EAST
);
219 jContentPane
.add(getJPanelContentCenter(), java
.awt
.BorderLayout
.CENTER
);
225 Start the window at the center of screen
228 protected void centerWindow(int intWidth
, int intHeight
) {
229 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
230 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
234 Start the window at the center of screen
237 protected void centerWindow() {
238 centerWindow(this.getSize().width
, this.getSize().height
);
243 } // @jve:decl-index=0:visual-constraint="10,10"