]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/GenListDialog.java
Add two files for List editor.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / GenListDialog.java
1 /** @file
2 Java class GenListDialog.
3
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
9
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.
12 **/
13 package org.tianocore.frameworkwizard.platform.ui;
14
15 import java.awt.BorderLayout;
16 import java.awt.Dimension;
17 import java.awt.Toolkit;
18
19 import javax.swing.JPanel;
20 import javax.swing.JDialog;
21
22 import javax.swing.JButton;
23
24
25 import java.awt.FlowLayout;
26 import java.awt.event.ActionEvent;
27 import java.awt.event.ActionListener;
28 import java.util.Vector;
29
30 import javax.swing.JScrollPane;
31
32 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
33
34
35 /**
36 Dialog for List generation.
37 @since PackageEditor 1.0
38 **/
39 public class GenListDialog extends JDialog implements ActionListener{
40
41 /**
42 *
43 */
44 private static final long serialVersionUID = 1L;
45
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;
56
57
58 private JScrollPane jScrollPane = null;
59
60
61
62 public void actionPerformed(ActionEvent arg0) {
63 // TODO Auto-generated method stub
64 if (arg0.getSource() == jButton1){
65 checkBoxList.setAllItemsUnchecked();
66 }
67
68 if (arg0.getSource() == jButton2){
69
70 this.dispose();
71 }
72
73 if (arg0.getSource() == jButton){
74 this.dispose();
75 }
76 }
77
78 /**
79 * This method initializes jPanel
80 *
81 * @return javax.swing.JPanel
82 */
83 private JPanel getJPanel() {
84 if (jPanel == null) {
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);
93 }
94 return jPanel;
95 }
96
97 /**
98 * This method initializes jPanel1
99 *
100 * @return javax.swing.JPanel
101 */
102 private JPanel getJPanel1() {
103 if (jPanel1 == null) {
104 jPanel1 = new JPanel();
105 }
106 return jPanel1;
107 }
108
109 /**
110 * This method initializes jPanel2
111 *
112 * @return javax.swing.JPanel
113 */
114 private JPanel getJPanel2() {
115 if (jPanel2 == null) {
116 jPanel2 = new JPanel();
117 }
118 return jPanel2;
119 }
120
121 /**
122 * This method initializes jPanel3
123 *
124 * @return javax.swing.JPanel
125 */
126 private JPanel getJPanel3() {
127 if (jPanel3 == null) {
128 jPanel3 = new JPanel();
129 }
130 return jPanel3;
131 }
132
133 /**
134 * This method initializes jPanel4
135 *
136 * @return javax.swing.JPanel
137 */
138 private JPanel getJPanel4() {
139 if (jPanel4 == null) {
140 jPanel4 = new JPanel();
141 jPanel4.setLayout(new FlowLayout());
142 jPanel4.add(getJScrollPane(), null);
143
144 }
145 return jPanel4;
146 }
147
148 /**
149 * This method initializes jButton
150 *
151 * @return javax.swing.JButton
152 */
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);
159 }
160 return jButton;
161 }
162
163 /**
164 * This method initializes jButton1
165 *
166 * @return javax.swing.JButton
167 */
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);
176 }
177 return jButton1;
178 }
179
180 /**
181 * This method initializes jButton2
182 *
183 * @return javax.swing.JButton
184 */
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);
192 }
193 return jButton2;
194 }
195
196 /**
197 * This method initializes jScrollPane
198 *
199 * @return javax.swing.JScrollPane
200 */
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());
206 }
207 return jScrollPane;
208 }
209
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");
219 // v.add("GUID");
220 // v.add("HII_PACKAGE_LIST");
221 // v.add("HOB");
222 // v.add("TOKEN_SPACE_GUID");
223 //
224 // checkBoxList.setAllItems(v);
225 }
226 return checkBoxList;
227 }
228
229 public void initList(Vector<String> v){
230 checkBoxList.setAllItems(v);
231 }
232 public Vector<String> getList(){
233 Vector<String> v = checkBoxList.getAllCheckedItemsString();
234 return v;
235 }
236
237 public void setList(String s){
238 Vector<String> v = new Vector<String>();
239 if (s == null) {
240 checkBoxList.setAllItemsUnchecked();
241 return;
242 }
243 String[] sArray = s.split(" ");
244 for (int i = 0; i < sArray.length; ++i){
245 v.add(sArray[i]);
246 }
247 checkBoxList.initCheckedItem(true, v);
248 }
249 /**
250 * This is the default constructor
251 */
252 public GenListDialog() {
253 super();
254 initialize();
255 }
256
257 public GenListDialog(ActionListener i){
258 this();
259 jButton2.addActionListener(i);
260
261 }
262
263 /**
264 * This method initializes this
265 *
266 * @return void
267 */
268 private void initialize() {
269 this.setSize(466, 157);
270 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
271 this.setModal(true);
272 this.setTitle("List");
273 this.setContentPane(getJContentPane());
274 this.centerWindow();
275 }
276
277 /**
278 * This method initializes jContentPane
279 *
280 * @return javax.swing.JPanel
281 */
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);
291 }
292 return jContentPane;
293 }
294
295 /**
296 Start the window at the center of screen
297
298 **/
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);
302 }
303
304 /**
305 Start the window at the center of screen
306
307 **/
308 protected void centerWindow() {
309 centerWindow(this.getSize().width, this.getSize().height);
310 }
311
312
313
314 } // @jve:decl-index=0:visual-constraint="10,10"