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 jPanelContentEast
= null;
48 private JPanel jPanelContentCenter
= null;
49 private JButton jButtonCancel
= null;
50 private JButton jButtonOk
= null;
51 private ICheckBoxList checkBoxList
= null;
54 private JScrollPane jScrollPane
= null;
58 public void actionPerformed(ActionEvent arg0
) {
60 if (arg0
.getSource() == jButtonOk
){
65 if (arg0
.getSource() == jButtonCancel
){
71 * This method initializes jPanel
73 * @return javax.swing.JPanel
75 private JPanel
getJPanelContentEast() {
76 if (jPanelContentEast
== null) {
77 FlowLayout flowLayout
= new FlowLayout();
78 flowLayout
.setVgap(10);
79 jPanelContentEast
= new JPanel();
80 jPanelContentEast
.setLayout(flowLayout
);
81 jPanelContentEast
.setPreferredSize(new java
.awt
.Dimension(100,30));
82 jPanelContentEast
.add(getJButtonOk(), null);
83 jPanelContentEast
.add(getJButtonCancel(), null);
85 return jPanelContentEast
;
89 * This method initializes jPanel4
91 * @return javax.swing.JPanel
93 private JPanel
getJPanelContentCenter() {
94 if (jPanelContentCenter
== null) {
95 jPanelContentCenter
= new JPanel();
96 jPanelContentCenter
.setLayout(new FlowLayout());
97 jPanelContentCenter
.add(getJScrollPane(), null);
100 return jPanelContentCenter
;
104 * This method initializes jButton
106 * @return javax.swing.JButton
108 private JButton
getJButtonCancel() {
109 if (jButtonCancel
== null) {
110 jButtonCancel
= new JButton();
111 jButtonCancel
.setPreferredSize(new java
.awt
.Dimension(80,20));
112 jButtonCancel
.setText("Cancel");
113 jButtonCancel
.addActionListener(this);
115 return jButtonCancel
;
119 * This method initializes jButton2
121 * @return javax.swing.JButton
123 private JButton
getJButtonOk() {
124 if (jButtonOk
== null) {
125 jButtonOk
= new JButton();
126 jButtonOk
.setPreferredSize(new java
.awt
.Dimension(80,20));
127 jButtonOk
.setText("Ok");
128 jButtonOk
.setActionCommand("GenGuidValue");
129 jButtonOk
.addActionListener(this);
135 * This method initializes jScrollPane
137 * @return javax.swing.JScrollPane
139 private JScrollPane
getJScrollPane() {
140 if (jScrollPane
== null) {
141 jScrollPane
= new JScrollPane();
142 jScrollPane
.setPreferredSize(new java
.awt
.Dimension(300,100));
143 jScrollPane
.setViewportView(getICheckBoxList());
148 private ICheckBoxList
getICheckBoxList() {
149 if (checkBoxList
== null) {
150 checkBoxList
= new ICheckBoxList();
151 checkBoxList
.setBounds(new java
.awt
.Rectangle(40,20,177,74));
157 public void initList(Vector
<String
> v
){
158 checkBoxList
.setAllItems(v
);
160 public Vector
<String
> getList(){
161 Vector
<String
> v
= checkBoxList
.getAllCheckedItemsString();
165 public void setList(String s
){
166 Vector
<String
> v
= new Vector
<String
>();
168 checkBoxList
.setAllItemsUnchecked();
171 String
[] sArray
= s
.split(" ");
172 for (int i
= 0; i
< sArray
.length
; ++i
){
175 checkBoxList
.initCheckedItem(true, v
);
178 * This is the default constructor
180 public GenListDialog() {
185 public GenListDialog(ActionListener i
){
187 jButtonOk
.addActionListener(i
);
192 * This method initializes this
196 private void initialize() {
197 this.setSize(466, 157);
198 this.setDefaultCloseOperation(javax
.swing
.WindowConstants
.DISPOSE_ON_CLOSE
);
200 this.setTitle("List");
201 this.setContentPane(getJContentPane());
206 * This method initializes jContentPane
208 * @return javax.swing.JPanel
210 private JPanel
getJContentPane() {
211 if (jContentPane
== null) {
212 jContentPane
= new JPanel();
213 jContentPane
.setLayout(new BorderLayout());
214 jContentPane
.add(getJPanelContentEast(), java
.awt
.BorderLayout
.EAST
);
215 jContentPane
.add(getJPanelContentCenter(), java
.awt
.BorderLayout
.CENTER
);
221 Start the window at the center of screen
224 protected void centerWindow(int intWidth
, int intHeight
) {
225 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
226 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
230 Start the window at the center of screen
233 protected void centerWindow() {
234 centerWindow(this.getSize().width
, this.getSize().height
);
239 } // @jve:decl-index=0:visual-constraint="10,10"