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
.JFrame
;
21 import javax
.swing
.JPanel
;
22 import javax
.swing
.JDialog
;
23 import javax
.swing
.KeyStroke
;
25 import javax
.swing
.JButton
;
28 import java
.awt
.FlowLayout
;
29 import java
.awt
.event
.ActionEvent
;
30 import java
.awt
.event
.ActionListener
;
31 import java
.awt
.event
.KeyEvent
;
32 import java
.util
.Vector
;
34 import javax
.swing
.JScrollPane
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
40 Dialog for List generation.
41 @since PackageEditor 1.0
43 public class GenListDialog
extends JDialog
implements ActionListener
{
48 private static final long serialVersionUID
= 1L;
50 private JPanel jContentPane
= null;
51 private JPanel jPanelContentEast
= null;
52 private JPanel jPanelContentCenter
= null;
53 private JButton jButtonCancel
= null;
54 private JButton jButtonOk
= null;
55 private ICheckBoxList checkBoxList
= null;
58 private JScrollPane jScrollPane
= null;
62 public void actionPerformed(ActionEvent arg0
) {
64 if (arg0
.getSource() == jButtonOk
){
69 if (arg0
.getSource() == jButtonCancel
){
75 * This method initializes jPanel
77 * @return javax.swing.JPanel
79 private JPanel
getJPanelContentEast() {
80 if (jPanelContentEast
== null) {
81 FlowLayout flowLayout
= new FlowLayout();
82 flowLayout
.setVgap(10);
83 jPanelContentEast
= new JPanel();
84 jPanelContentEast
.setLayout(flowLayout
);
85 jPanelContentEast
.setPreferredSize(new java
.awt
.Dimension(100,30));
86 jPanelContentEast
.add(getJButtonOk(), null);
87 jPanelContentEast
.add(getJButtonCancel(), null);
89 return jPanelContentEast
;
93 * This method initializes jPanel4
95 * @return javax.swing.JPanel
97 private JPanel
getJPanelContentCenter() {
98 if (jPanelContentCenter
== null) {
99 jPanelContentCenter
= new JPanel();
100 jPanelContentCenter
.setLayout(new FlowLayout());
101 jPanelContentCenter
.add(getJScrollPane(), null);
104 return jPanelContentCenter
;
108 * This method initializes jButton
110 * @return javax.swing.JButton
112 private JButton
getJButtonCancel() {
113 if (jButtonCancel
== null) {
114 jButtonCancel
= new JButton();
115 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(80,20));
116 jButtonCancel
.setText("Cancel");
117 jButtonCancel
.addActionListener(this);
118 jButtonCancel
.registerKeyboardAction(this, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
120 return jButtonCancel
;
124 * This method initializes jButton2
126 * @return javax.swing.JButton
128 private JButton
getJButtonOk() {
129 if (jButtonOk
== null) {
130 jButtonOk
= new JButton();
131 jButtonOk
.setPreferredSize(new java
.awt
.Dimension(80,20));
132 jButtonOk
.setText("Ok");
133 jButtonOk
.setActionCommand("GenGuidValue");
134 jButtonOk
.addActionListener(this);
140 * This method initializes jScrollPane
142 * @return javax.swing.JScrollPane
144 private JScrollPane
getJScrollPane() {
145 if (jScrollPane
== null) {
146 jScrollPane
= new JScrollPane();
147 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(300,100));
148 jScrollPane
.setViewportView(getICheckBoxList());
153 private ICheckBoxList
getICheckBoxList() {
154 if (checkBoxList
== null) {
155 checkBoxList
= new ICheckBoxList();
156 checkBoxList
.setBounds(new java
.awt
.Rectangle(40,20,177,74));
162 public void initList(Vector
<String
> v
){
163 checkBoxList
.setAllItems(v
);
165 public Vector
<String
> getList(){
166 Vector
<String
> v
= checkBoxList
.getAllCheckedItemsString();
170 public void setList(String s
){
171 Vector
<String
> v
= new Vector
<String
>();
173 checkBoxList
.setAllItemsUnchecked();
176 String
[] sArray
= s
.split(" ");
177 for (int i
= 0; i
< sArray
.length
; ++i
){
180 checkBoxList
.initCheckedItem(true, v
);
183 * This is the default constructor
185 public GenListDialog(JFrame frame
) {
190 public GenListDialog(ActionListener i
, JFrame frame
){
192 jButtonOk
.addActionListener(i
);
193 jButtonOk
.registerKeyboardAction(i
, KeyStroke
.getKeyStroke(KeyEvent
.VK_ENTER
, 0, false), JComponent
.WHEN_FOCUSED
);
197 * This method initializes this
201 private void initialize() {
202 this.setSize(466, 157);
203 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
205 this.setTitle("List");
206 this.setContentPane(getJContentPane());
211 * This method initializes jContentPane
213 * @return javax.swing.JPanel
215 private JPanel
getJContentPane() {
216 if (jContentPane
== null) {
217 jContentPane
= new JPanel();
218 jContentPane
.setLayout(new BorderLayout());
219 jContentPane
.add(getJPanelContentEast(), java
.awt
.BorderLayout
.EAST
);
220 jContentPane
.add(getJPanelContentCenter(), java
.awt
.BorderLayout
.CENTER
);
226 Start the window at the center of screen
229 protected void centerWindow(int intWidth
, int intHeight
) {
230 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
231 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
235 Start the window at the center of screen
238 protected void centerWindow() {
239 centerWindow(this.getSize().width
, this.getSize().height
);
244 } // @jve:decl-index=0:visual-constraint="10,10"