git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdLibClassDecls.java
CommitLineData
a13899c5 1/** @file\r
2 Java class SpdLibClassDecls is GUI for create library definition elements of spd file.\r
3 \r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13package org.tianocore.frameworkwizard.packaging.ui;\r
14\r
15import java.awt.BorderLayout;\r
16import java.awt.Dimension;\r
17import java.awt.Toolkit;\r
18import java.awt.event.ActionEvent;\r
19import java.awt.event.ActionListener;\r
20import java.awt.event.ComponentEvent;\r
21import java.awt.event.FocusAdapter;\r
22import java.awt.event.FocusEvent;\r
23import java.awt.event.FocusListener;\r
24import java.io.File;\r
25import java.util.Vector;\r
26\r
27import javax.swing.AbstractAction;\r
28import javax.swing.DefaultListModel;\r
29import javax.swing.JFileChooser;\r
30import javax.swing.JOptionPane;\r
31import javax.swing.JPanel;\r
32import javax.swing.JRadioButton;\r
33import javax.swing.JTable;\r
34import javax.swing.JTextField;\r
35import javax.swing.JComboBox;\r
36import javax.swing.JLabel;\r
37import javax.swing.JList;\r
38import javax.swing.JScrollPane;\r
39import javax.swing.JButton;\r
40import javax.swing.JFrame;\r
41import javax.swing.ListSelectionModel;\r
42import javax.swing.event.InternalFrameAdapter;\r
43import javax.swing.event.InternalFrameEvent;\r
44import javax.swing.event.ListSelectionEvent;\r
45import javax.swing.event.ListSelectionListener;\r
46import javax.swing.event.TableModelEvent;\r
47import javax.swing.event.TableModelListener;\r
48import javax.swing.table.DefaultTableModel;\r
49import javax.swing.table.TableModel;\r
50\r
51import org.tianocore.PackageSurfaceAreaDocument;\r
52import org.tianocore.frameworkwizard.common.DataType;\r
53import org.tianocore.frameworkwizard.common.Tools;\r
54import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
55import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
56import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
57\r
58import javax.swing.JCheckBox;\r
59\r
60/**\r
61 GUI for create library definition elements of spd file.\r
62 \r
63 @since PackageEditor 1.0\r
64**/\r
65public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{\r
66 static JFrame frame;\r
67 \r
68 private JTable jTable = null;\r
69\r
70 private DefaultTableModel model = null;\r
71\r
72 private JPanel jContentPane = null;\r
73\r
74 private JRadioButton jRadioButtonAdd = null;\r
75\r
76 private JRadioButton jRadioButtonSelect = null;\r
77\r
78 private JTextField jTextFieldAdd = null;\r
79\r
80 private JComboBox jComboBoxSelect = null;\r
81\r
82 private JScrollPane jScrollPane = null;\r
83\r
84 private JButton jButtonAdd = null;\r
85\r
86 private JButton jButtonRemove = null;\r
87\r
88 private JButton jButtonClearAll = null;\r
89\r
90 private JButton jButtonCancel = null;\r
91\r
92 private JButton jButtonOk = null;\r
93\r
94 private JLabel jLabel = null;\r
95\r
96 private JTextField jTextField = null;\r
97\r
98 private JButton jButtonBrowse = null;\r
99 \r
100 private StarLabel jStarLabel1 = null;\r
101 \r
102 private StarLabel jStarLabel2 = null;\r
103 \r
104 private SpdFileContents sfc = null;\r
105\r
106 private JLabel jLabel1 = null;\r
107 \r
108 private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,53"\r
109 \r
110 private int selectedRow = -1;\r
111\r
112 private StarLabel starLabel = null;\r
113\r
114 private JLabel jLabel2 = null;\r
115\r
116 private JTextField jTextFieldHelp = null;\r
117\r
118 private JLabel jLabel3 = null;\r
119\r
120 private JTextField jTextField1 = null;\r
121\r
122 private JLabel jLabel4 = null;\r
123\r
124 private JTextField jTextField2 = null;\r
125\r
126 private JLabel jLabel5 = null;\r
127\r
128 private JCheckBox jCheckBox = null;\r
129\r
130 private JCheckBox jCheckBox1 = null;\r
131\r
132 private JCheckBox jCheckBox2 = null;\r
133\r
134 private JCheckBox jCheckBox3 = null;\r
135\r
136 private JLabel jLabel6 = null;\r
137 \r
138 private JScrollPane jScrollPaneArch = null;\r
139 \r
140 private ICheckBoxList iCheckBoxListArch = null;\r
141\r
142 /**\r
143 This method initializes this\r
144 \r
145 **/\r
146 private void initialize() {\r
147 \r
148 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
149\r
150 }\r
151\r
152 /**\r
153 This method initializes jRadioButtonAdd \r
154 \r
155 @return javax.swing.JRadioButton \r
156 **/\r
157 private JRadioButton getJRadioButtonAdd() {\r
158 if (jRadioButtonAdd == null) {\r
159 jRadioButtonAdd = new JRadioButton();\r
160 jRadioButtonAdd.setBounds(new java.awt.Rectangle(9,63,197,20));\r
161 jRadioButtonAdd.setText("Library Class Name");\r
162 jRadioButtonAdd.addActionListener(this);\r
163 jRadioButtonAdd.setSelected(true);\r
164 jRadioButtonAdd.setVisible(false);\r
165 }\r
166 return jRadioButtonAdd;\r
167 }\r
168\r
169 /**\r
170 This method initializes jRadioButtonSelect \r
171 \r
172 @return javax.swing.JRadioButton \r
173 **/\r
174 private JRadioButton getJRadioButtonSelect() {\r
175 if (jRadioButtonSelect == null) {\r
176 jRadioButtonSelect = new JRadioButton();\r
177 jRadioButtonSelect.setBounds(new java.awt.Rectangle(9,10,198,20));\r
178 jRadioButtonSelect.setText("Select Existing Library Class");\r
179 jRadioButtonSelect.addActionListener(this);\r
180 jRadioButtonSelect.setSelected(true);\r
181 jRadioButtonSelect.setVisible(false);\r
182 }\r
183 return jRadioButtonSelect;\r
184 }\r
185\r
186 /**\r
187 This method initializes jTextFieldAdd \r
188 \r
189 @return javax.swing.JTextField \r
190 **/\r
191 private JTextField getJTextFieldAdd() {\r
192 if (jTextFieldAdd == null) {\r
193 jTextFieldAdd = new JTextField();\r
194 jTextFieldAdd.setBounds(new java.awt.Rectangle(122,6,343,20));\r
195 jTextFieldAdd.setPreferredSize(new java.awt.Dimension(260,20));\r
196 jTextFieldAdd.setEnabled(true);\r
197 }\r
198 return jTextFieldAdd;\r
199 }\r
200\r
201 /**\r
202 This method initializes jComboBoxSelect \r
203 \r
204 @return javax.swing.JComboBox \r
205 **/\r
206 private JComboBox getJComboBoxSelect() {\r
207 if (jComboBoxSelect == null) {\r
208 jComboBoxSelect = new JComboBox();\r
209 jComboBoxSelect.setBounds(new java.awt.Rectangle(220, 10, 260, 20));\r
210 jComboBoxSelect.setPreferredSize(new java.awt.Dimension(260,22));\r
211 jComboBoxSelect.setEnabled(true);\r
212 jComboBoxSelect.setVisible(false);\r
213 }\r
214 return jComboBoxSelect;\r
215 }\r
216\r
217 /**\r
218 This method initializes jScrollPane \r
219 \r
220 @return javax.swing.JScrollPane \r
221 **/\r
222 private JScrollPane getJScrollPane() {\r
223 if (jScrollPane == null) {\r
224 jScrollPane = new JScrollPane();\r
225 jScrollPane.setBounds(new java.awt.Rectangle(12,302,351,164));\r
226 jScrollPane.setPreferredSize(new java.awt.Dimension(330,150));\r
227 jScrollPane.setViewportView(getJTable());\r
228 }\r
229 return jScrollPane;\r
230 }\r
231\r
232 /**\r
233 This method initializes jTable \r
234 \r
235 @return javax.swing.JTable \r
236 **/\r
237 private JTable getJTable() {\r
238 if (jTable == null) {\r
239 model = new DefaultTableModel();\r
240 jTable = new JTable(model);\r
241 jTable.setRowHeight(20);\r
242 jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
243 model.addColumn("LibraryClass");\r
244 model.addColumn("IncludeHeader");\r
245 model.addColumn("HelpText");\r
246 model.addColumn("RecommendedInstance");\r
247 model.addColumn("InstanceVersion");\r
248 model.addColumn("SupportedArch");\r
249 model.addColumn("SupportedModule");\r
250 \r
251 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
252 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
253 public void valueChanged(ListSelectionEvent e) {\r
254 if (e.getValueIsAdjusting()){\r
255 return;\r
256 }\r
257 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
258 if (lsm.isSelectionEmpty()) {\r
259 return;\r
260 }\r
261 else{\r
262 selectedRow = lsm.getMinSelectionIndex();\r
263 }\r
264 }\r
265 });\r
266 \r
267 jTable.getModel().addTableModelListener(this);\r
268\r
269 }\r
270 return jTable;\r
271 }\r
272 \r
273 \r
274 public void tableChanged(TableModelEvent arg0) {\r
275 // TODO Auto-generated method stub\r
276 int row = arg0.getFirstRow();\r
277 TableModel m = (TableModel)arg0.getSource();\r
278 if (arg0.getType() == TableModelEvent.UPDATE){\r
279 String lib = m.getValueAt(row, 0) + "";\r
280 String hdr = m.getValueAt(row, 1) + "";\r
281 String hlp = m.getValueAt(row, 2) + "";\r
282 String guid = m.getValueAt(row, 3) + "";\r
283 String ver = m.getValueAt(row, 4) + "";\r
284 String arch = null;\r
285 if (m.getValueAt(row, 5) != null) {\r
286 arch = m.getValueAt(row, 5).toString();\r
287 }\r
288 String module = null;\r
289 if (m.getValueAt(row, 6) != null) {\r
290 module = m.getValueAt(row, 6).toString();\r
291 }\r
292 sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, ver, arch, module);\r
293 }\r
294 }\r
295\r
296 /**\r
297 This method initializes jButtonAdd \r
298 \r
299 @return javax.swing.JButton \r
300 **/\r
301 private JButton getJButtonAdd() {\r
302 if (jButtonAdd == null) {\r
303 jButtonAdd = new JButton();\r
304 jButtonAdd.setBounds(new java.awt.Rectangle(374,303,90,20));\r
305 jButtonAdd.setText("Add");\r
306 jButtonAdd.addActionListener(this);\r
307 }\r
308 return jButtonAdd;\r
309 }\r
310\r
311 /**\r
312 This method initializes jButtonRemove \r
313 \r
314 @return javax.swing.JButton \r
315 **/\r
316 private JButton getJButtonRemove() {\r
317 if (jButtonRemove == null) {\r
318 jButtonRemove = new JButton();\r
319 jButtonRemove.setBounds(new java.awt.Rectangle(374,381,90,20));\r
320 jButtonRemove.setText("Remove");\r
321 jButtonRemove.addActionListener(this);\r
322 }\r
323 return jButtonRemove;\r
324 }\r
325\r
326 /**\r
327 This method initializes jButtonRemoveAll \r
328 \r
329 @return javax.swing.JButton \r
330 **/\r
331 private JButton getJButtonClearAll() {\r
332 if (jButtonClearAll == null) {\r
333 jButtonClearAll = new JButton();\r
334 jButtonClearAll.setBounds(new java.awt.Rectangle(374,411,90,20));\r
335 jButtonClearAll.setText("Clear All");\r
336 jButtonClearAll.addActionListener(this);\r
337 }\r
338 return jButtonClearAll;\r
339 }\r
340\r
341 /**\r
342 This method initializes jButtonCancel \r
343 \r
344 @return javax.swing.JButton \r
345 **/\r
346 private JButton getJButtonCancel() {\r
347 if (jButtonCancel == null) {\r
348 jButtonCancel = new JButton();\r
349 jButtonCancel.setPreferredSize(new java.awt.Dimension(90, 20));\r
350 jButtonCancel.setLocation(new java.awt.Point(390, 305));\r
351 jButtonCancel.setText("Cancel");\r
352 jButtonCancel.setSize(new java.awt.Dimension(90, 20));\r
353 jButtonCancel.setVisible(false);\r
354 jButtonCancel.addActionListener(this);\r
355 }\r
356 return jButtonCancel;\r
357 }\r
358\r
359 /**\r
360 This method initializes jButton \r
361 \r
362 @return javax.swing.JButton \r
363 **/\r
364 private JButton getJButtonOk() {\r
365 if (jButtonOk == null) {\r
366 jButtonOk = new JButton();\r
367 jButtonOk.setSize(new java.awt.Dimension(90, 20));\r
368 jButtonOk.setText("OK");\r
369 jButtonOk.setLocation(new java.awt.Point(290, 305));\r
370 jButtonOk.setVisible(false);\r
371 jButtonOk.addActionListener(this);\r
372 }\r
373 return jButtonOk;\r
374 }\r
375\r
376 /**\r
377 This is the default constructor\r
378 **/\r
379 public SpdLibClassDecls() {\r
380 super();\r
381 initialize();\r
382 init();\r
383 \r
384 }\r
385\r
386 public SpdLibClassDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){\r
387 this();\r
388 sfc = new SpdFileContents(inPsa);\r
389 init(sfc);\r
390 }\r
391 /**\r
392 This method initializes this\r
393 \r
394 @return void\r
395 **/\r
396 private void init() {\r
397 \r
398 this.setContentPane(getJContentPane());\r
399 this.setTitle("Library Class Declarations");\r
400 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));\r
401 this.setVisible(true);\r
402 this.addInternalFrameListener(new InternalFrameAdapter(){\r
403 public void internalFrameDeactivated(InternalFrameEvent e){\r
404 if (jTable.isEditing()) {\r
405 jTable.getCellEditor().stopCellEditing();\r
406 }\r
407 }\r
408 });\r
409 initFrame();\r
410 }\r
411\r
412 private void init(SpdFileContents sfc) {\r
413 if (sfc.getSpdLibClassDeclarationCount() == 0) {\r
414 return ;\r
415 }\r
416 //\r
417 // initialize table using SpdFileContents object\r
418 //\r
419 String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][7];\r
420 sfc.getSpdLibClassDeclarations(saa);\r
421 int i = 0;\r
422 while (i < saa.length) {\r
423 model.addRow(saa[i]);\r
424 i++;\r
425 }\r
426 }\r
427 private JScrollPane getJContentPane(){\r
428 if (topScrollPane == null){\r
429 topScrollPane = new JScrollPane();\r
430 topScrollPane.setSize(new java.awt.Dimension(483,500));\r
431 topScrollPane.setViewportView(getJContentPane1());\r
432 }\r
433 return topScrollPane;\r
434 }\r
435 /**\r
436 This method initializes jContentPane\r
437 \r
438 @return javax.swing.JPanel\r
439 **/\r
440 private JPanel getJContentPane1() {\r
441 if (jContentPane == null) {\r
442 jLabel6 = new JLabel();\r
443 jLabel6.setBounds(new java.awt.Rectangle(16,252,108,16));\r
444 jLabel6.setText("Supported Module");\r
445 jLabel6.setEnabled(true);\r
446 jLabel5 = new JLabel();\r
447 jLabel5.setBounds(new java.awt.Rectangle(16,215,93,16));\r
448 jLabel5.setText("Supported Arch");\r
449 jLabel5.setEnabled(true);\r
450 jLabel4 = new JLabel();\r
451 jLabel4.setBounds(new java.awt.Rectangle(16,160,196,16));\r
452 jLabel4.setEnabled(true);\r
453 jLabel4.setText("Recommended Instance Version");\r
454 jLabel3 = new JLabel();\r
455 jLabel3.setBounds(new java.awt.Rectangle(17,112,175,16));\r
456 jLabel3.setEnabled(true);\r
457 jLabel3.setText("Recommended Instance GUID");\r
458 jLabel2 = new JLabel();\r
459 jLabel2.setBounds(new java.awt.Rectangle(16,33,82,20));\r
460 jLabel2.setText("Help Text");\r
461 starLabel = new StarLabel();\r
462 starLabel.setBounds(new java.awt.Rectangle(1,33,10,20));\r
463 jLabel1 = new JLabel();\r
464 jLabel1.setBounds(new java.awt.Rectangle(16,6,82,20));\r
465 jLabel1.setText("Library Class");\r
466 jStarLabel1 = new StarLabel();\r
467 jStarLabel1.setLocation(new java.awt.Point(1,7));\r
468 jStarLabel2 = new StarLabel();\r
469 jStarLabel2.setLocation(new java.awt.Point(1,56));\r
470 jLabel = new JLabel();\r
471 jLabel.setBounds(new java.awt.Rectangle(16,56,199,22));\r
472 jLabel.setText("Include Header for Specified Class");\r
473 \r
474 jContentPane = new JPanel();\r
475 jContentPane.setPreferredSize(new Dimension(480, 400));\r
476 jContentPane.setLayout(null);\r
477 jContentPane.add(jLabel, null);\r
478 jContentPane.add(jStarLabel1, null);\r
479 jContentPane.add(jStarLabel2, null);\r
480 jContentPane.add(getJRadioButtonAdd(), null);\r
481 jContentPane.add(getJRadioButtonSelect(), null);\r
482 jContentPane.add(getJTextFieldAdd(), null);\r
483 jContentPane.add(getJComboBoxSelect(), null);\r
484 jContentPane.add(getJScrollPane(), null);\r
485 jContentPane.add(getJButtonAdd(), null);\r
486 jContentPane.add(getJButtonRemove(), null);\r
487 jContentPane.add(getJButtonClearAll(), null);\r
488 jContentPane.add(getJButtonCancel(), null);\r
489 jContentPane.add(getJButtonOk(), null);\r
490 \r
491 jContentPane.add(getJTextField(), null);\r
492 jContentPane.add(getJButtonBrowse(), null);\r
493 jContentPane.add(jLabel1, null);\r
494 jContentPane.add(starLabel, null);\r
495 jContentPane.add(jLabel2, null);\r
496 jContentPane.add(getJTextFieldHelp(), null);\r
497 jContentPane.add(jLabel3, null);\r
498 jContentPane.add(getJTextField1(), null);\r
499 jContentPane.add(jLabel4, null);\r
500 jContentPane.add(getJTextField2(), null);\r
501 jContentPane.add(jLabel5, null);\r
502 jContentPane.add(getJCheckBox(), null);\r
503 jContentPane.add(getJCheckBox1(), null);\r
504 jContentPane.add(getJCheckBox2(), null);\r
505 jContentPane.add(getJCheckBox3(), null);\r
506 jContentPane.add(jLabel6, null);\r
507 \r
508 jContentPane.add(getJScrollPaneArch(), null);\r
509 }\r
510 \r
511 return jContentPane;\r
512 }\r
513\r
514 /**\r
515 fill ComboBoxes with pre-defined contents\r
516 **/\r
517 private void initFrame() {\r
518 jComboBoxSelect.addItem("BaseCpuICacheFlush");\r
519 jComboBoxSelect.addItem("BaseDebugLibNull");\r
520 jComboBoxSelect.addItem("BaseDebugLibReportStatusCode");\r
521 jComboBoxSelect.addItem("BaseIoLibIntrinsic");\r
522 jComboBoxSelect.addItem("BaseLib");\r
523 jComboBoxSelect.addItem("BaseMemoryLib");\r
524 jComboBoxSelect.addItem("BaseMemoryLibMmx");\r
525 jComboBoxSelect.addItem("BaseMemoryLibSse2");\r
526 jComboBoxSelect.addItem("BasePeCoffGetEntryPointLib");\r
527 jComboBoxSelect.addItem("BasePeCoffLib");\r
528 jComboBoxSelect.addItem("BasePrintLib");\r
529 jComboBoxSelect.addItem("BaseReportStatusCodeLibNull");\r
530 jComboBoxSelect.addItem("CommonPciCf8Lib");\r
531 jComboBoxSelect.addItem("CommonPciExpressLib");\r
532 jComboBoxSelect.addItem("CommonPciLibCf8");\r
533 jComboBoxSelect.addItem("CommonPciLibPciExpress");\r
534 jComboBoxSelect.addItem("DxeCoreEntryPoint");\r
535 jComboBoxSelect.addItem("DxeHobLib");\r
536 jComboBoxSelect.addItem("DxeIoLibCpuIo");\r
537 jComboBoxSelect.addItem("DxeLib");\r
538 jComboBoxSelect.addItem("DxePcdLib");\r
539 jComboBoxSelect.addItem("DxeReportStatusCodeLib");\r
540 jComboBoxSelect.addItem("DxeServicesTableLib");\r
541 jComboBoxSelect.addItem("PeiCoreEntryPoint");\r
542 jComboBoxSelect.addItem("PeiMemoryLib");\r
543 jComboBoxSelect.addItem("PeimEntryPoint");\r
544 jComboBoxSelect.addItem("PeiReportStatusCodeLib");\r
545 jComboBoxSelect.addItem("PeiServicesTablePointerLib");\r
546 jComboBoxSelect.addItem("PeiServicesTablePointerLibMm7");\r
547 jComboBoxSelect.addItem("UefiDebugLibConOut");\r
548 jComboBoxSelect.addItem("UefiDebugLibStdErr");\r
549 jComboBoxSelect.addItem("UefiDriverEntryPointMultiple");\r
550 jComboBoxSelect.addItem("UefiDriverEntryPointSingle");\r
551 jComboBoxSelect.addItem("UefiDriverEntryPointSingleUnload");\r
552 jComboBoxSelect.addItem("UefiDriverModelLib");\r
553 jComboBoxSelect.addItem("UefiDriverModelLibNoConfigNoDiag");\r
554 jComboBoxSelect.addItem("UefiLib");\r
555 jComboBoxSelect.addItem("UefiMemoryLib");\r
556\r
557 }\r
558\r
559 /* (non-Javadoc)\r
560 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
561 */\r
562 public void actionPerformed(ActionEvent arg0) {\r
563 if (arg0.getSource() == jButtonOk) {\r
564 this.save();\r
565 this.dispose();\r
566\r
567 }\r
568 if (arg0.getSource() == jButtonCancel) {\r
569 this.dispose();\r
570 }\r
571\r
572 if (arg0.getSource() == jButtonAdd) {\r
573 \r
574 //ToDo: check before add\r
575 String[] row = {null, null, null, jTextField1.getText(), jTextField2.getText(), null, null};\r
576 row[0] = jTextFieldAdd.getText();\r
577 row[1] = jTextField.getText().replace('\\', '/');\r
578 row[2] = jTextFieldHelp.getText();\r
579 row[5] = booleanToString(jCheckBox.isSelected(), jCheckBox1.isSelected(), jCheckBox2.isSelected(), jCheckBox3.isSelected());\r
580 if (row[5].length() == 0){\r
581 row[5] = null;\r
582 }\r
583 row[6] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());\r
584 if (row[6].length() == 0){\r
585 row[6] = null;\r
586 }\r
587 model.addRow(row);\r
588 sfc.genSpdLibClassDeclarations(row[0], row[3], row[1], row[2], row[5], null, null, row[4], null, row[6]);\r
589 \r
590 }\r
591 //\r
592 // remove selected line\r
593 //\r
594 if (arg0.getSource() == jButtonRemove) {\r
595 if (jTable.isEditing()){\r
596 jTable.getCellEditor().stopCellEditing();\r
597 }\r
598 int rowSelected = selectedRow;\r
599 if (rowSelected >= 0) {\r
600 model.removeRow(rowSelected);\r
601 sfc.removeSpdLibClass(rowSelected);\r
602 }\r
603 }\r
604\r
605 if (arg0.getSource() == jButtonClearAll) {\r
606 if (model.getRowCount() == 0) {\r
607 return;\r
608 }\r
609 \r
610 model.setRowCount(0);\r
611 sfc.removeSpdLibClass();\r
612 }\r
613\r
614 if (arg0.getSource() == jRadioButtonAdd) {\r
615 if (jRadioButtonAdd.isSelected()) {\r
616 jRadioButtonSelect.setSelected(false);\r
617 jTextFieldAdd.setEnabled(true);\r
618 jComboBoxSelect.setEnabled(false);\r
619 }\r
620 if (!jRadioButtonSelect.isSelected() && !jRadioButtonAdd.isSelected()) {\r
621 jRadioButtonAdd.setSelected(true);\r
622 jTextFieldAdd.setEnabled(true);\r
623 jComboBoxSelect.setEnabled(false);\r
624 }\r
625 }\r
626\r
627 if (arg0.getSource() == jRadioButtonSelect) {\r
628 if (jRadioButtonSelect.isSelected()) {\r
629 jRadioButtonAdd.setSelected(false);\r
630 jTextFieldAdd.setEnabled(false);\r
631 jComboBoxSelect.setEnabled(true);\r
632 }\r
633 if (!jRadioButtonSelect.isSelected() && !jRadioButtonAdd.isSelected()) {\r
634 jRadioButtonSelect.setSelected(true);\r
635 jTextFieldAdd.setEnabled(false);\r
636 jComboBoxSelect.setEnabled(true);\r
637 }\r
638 }\r
639 }\r
640\r
641 \r
642 /**\r
643 Add contents in list to sfc\r
644 **/\r
645 protected void save() {\r
646 \r
647 }\r
648\r
649 /**\r
650 This method initializes jTextField \r
651 \r
652 @return javax.swing.JTextField \r
653 **/\r
654 private JTextField getJTextField() {\r
655 if (jTextField == null) {\r
656 jTextField = new JTextField();\r
657 jTextField.setBounds(new java.awt.Rectangle(16,83,346,21));\r
658 jTextField.setPreferredSize(new java.awt.Dimension(260,20));\r
659 }\r
660 return jTextField;\r
661 }\r
662\r
663 /**\r
664 This method initializes jButtonBrowse \r
665 \r
666 @return javax.swing.JButton \r
667 **/\r
668 private JButton getJButtonBrowse() {\r
669 if (jButtonBrowse == null) {\r
670 jButtonBrowse = new JButton();\r
671 jButtonBrowse.setBounds(new java.awt.Rectangle(376,82,90,20));\r
672 jButtonBrowse.setText("Browse");\r
673 jButtonBrowse.setPreferredSize(new java.awt.Dimension(80,20));\r
674 jButtonBrowse.addActionListener(new AbstractAction() {\r
675 \r
676 public void actionPerformed(ActionEvent arg0) {\r
677 //\r
678 // Select files from current pkg\r
679 //\r
680 String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));\r
681 JFileChooser chooser = new JFileChooser(dirPrefix);\r
682 File theFile = null;\r
683 String headerDest = null;\r
684 \r
685 chooser.setMultiSelectionEnabled(false);\r
686 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
687 int retval = chooser.showOpenDialog(frame);\r
688 if (retval == JFileChooser.APPROVE_OPTION) {\r
689\r
690 theFile = chooser.getSelectedFile();\r
691 String file = theFile.getPath();\r
692 if (!file.startsWith(dirPrefix)) {\r
693 JOptionPane.showMessageDialog(frame, "You can only select files in current package!");\r
694 return;\r
695 }\r
696 \r
697 \r
698 }\r
699 else {\r
700 return;\r
701 }\r
702 \r
703 headerDest = theFile.getPath();\r
704 int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());\r
705 \r
706 jTextField.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));\r
707 \r
708 }\r
709\r
710 });\r
711 }\r
712 return jButtonBrowse;\r
713 }\r
714 \r
715 public void componentResized(ComponentEvent arg0) {\r
716 int intPreferredWidth = 500;\r
717 \r
718 resizeComponentWidth(this.jTextFieldAdd, this.getWidth(), intPreferredWidth);\r
719 resizeComponentWidth(this.jTextFieldHelp, this.getWidth(), intPreferredWidth);\r
720 resizeComponentWidth(this.jScrollPane, this.getWidth(), intPreferredWidth);\r
721 relocateComponentX(this.jButtonBrowse, this.getWidth(), this.getPreferredSize().width,25);\r
722 relocateComponentX(this.jButtonClearAll, this.getWidth(), this.getPreferredSize().width,25);\r
723 relocateComponentX(this.jButtonRemove, this.getWidth(), this.getPreferredSize().width,25);\r
724 relocateComponentX(this.jButtonAdd, this.getWidth(), this.getPreferredSize().width,50);\r
725 \r
726 }\r
727 /**\r
728 * This method initializes jTextFieldHelp \r
729 * \r
730 * @return javax.swing.JTextField \r
731 */\r
732 private JTextField getJTextFieldHelp() {\r
733 if (jTextFieldHelp == null) {\r
734 jTextFieldHelp = new JTextField();\r
735 jTextFieldHelp.setBounds(new java.awt.Rectangle(122,33,343,20));\r
736 jTextFieldHelp.setPreferredSize(new java.awt.Dimension(260,20));\r
737 }\r
738 return jTextFieldHelp;\r
739 }\r
740\r
741 /**\r
742 * This method initializes jTextField1 \r
743 * \r
744 * @return javax.swing.JTextField \r
745 */\r
746 private JTextField getJTextField1() {\r
747 if (jTextField1 == null) {\r
748 jTextField1 = new JTextField();\r
749 jTextField1.setBounds(new java.awt.Rectangle(16,135,344,20));\r
750 jTextField1.setEnabled(true);\r
751 }\r
752 return jTextField1;\r
753 }\r
754\r
755 /**\r
756 * This method initializes jTextField2 \r
757 * \r
758 * @return javax.swing.JTextField \r
759 */\r
760 private JTextField getJTextField2() {\r
761 if (jTextField2 == null) {\r
762 jTextField2 = new JTextField();\r
763 jTextField2.setBounds(new java.awt.Rectangle(16,184,344,20));\r
764 jTextField2.setEnabled(true);\r
765 }\r
766 return jTextField2;\r
767 }\r
768\r
769 /**\r
770 * This method initializes jCheckBox \r
771 * \r
772 * @return javax.swing.JCheckBox \r
773 */\r
774 private JCheckBox getJCheckBox() {\r
775 if (jCheckBox == null) {\r
776 jCheckBox = new JCheckBox();\r
777 jCheckBox.setBounds(new java.awt.Rectangle(123,213,57,21));\r
778 jCheckBox.setText("IA32");\r
779 jCheckBox.setPreferredSize(new java.awt.Dimension(21,20));\r
780 }\r
781 return jCheckBox;\r
782 }\r
783\r
784 /**\r
785 * This method initializes jCheckBox1 \r
786 * \r
787 * @return javax.swing.JCheckBox \r
788 */\r
789 private JCheckBox getJCheckBox1() {\r
790 if (jCheckBox1 == null) {\r
791 jCheckBox1 = new JCheckBox();\r
792 jCheckBox1.setBounds(new java.awt.Rectangle(197,213,49,20));\r
793 jCheckBox1.setText("X64");\r
794 jCheckBox1.setPreferredSize(new java.awt.Dimension(21,20));\r
795 }\r
796 return jCheckBox1;\r
797 }\r
798\r
799 /**\r
800 * This method initializes jCheckBox2 \r
801 * \r
802 * @return javax.swing.JCheckBox \r
803 */\r
804 private JCheckBox getJCheckBox2() {\r
805 if (jCheckBox2 == null) {\r
806 jCheckBox2 = new JCheckBox();\r
807 jCheckBox2.setText("IPF");\r
808 jCheckBox2.setSize(new java.awt.Dimension(50,20));\r
809 jCheckBox2.setLocation(new java.awt.Point(258,213));\r
810 jCheckBox2.setPreferredSize(new java.awt.Dimension(21,20));\r
811 }\r
812 return jCheckBox2;\r
813 }\r
814\r
815 /**\r
816 * This method initializes jCheckBox3 \r
817 * \r
818 * @return javax.swing.JCheckBox \r
819 */\r
820 private JCheckBox getJCheckBox3() {\r
821 if (jCheckBox3 == null) {\r
822 jCheckBox3 = new JCheckBox();\r
823 jCheckBox3.setBounds(new java.awt.Rectangle(319,213,59,20));\r
824 jCheckBox3.setText("EBC");\r
825 jCheckBox3.setPreferredSize(new java.awt.Dimension(21,20));\r
826 }\r
827 return jCheckBox3;\r
828 }\r
829\r
830 private JScrollPane getJScrollPaneArch() {\r
831 if (jScrollPaneArch == null) {\r
832 jScrollPaneArch = new JScrollPane();\r
833 jScrollPaneArch.setBounds(new java.awt.Rectangle(130,252,230,45));\r
834 jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));\r
835 jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());\r
836 }\r
837 return jScrollPaneArch;\r
838 }\r
839 \r
840 private ICheckBoxList getICheckBoxListSupportedArchitectures() {\r
841 if (iCheckBoxListArch == null) {\r
842 iCheckBoxListArch = new ICheckBoxList();\r
843 Vector<String> v = new Vector<String>();\r
844 v.add("BASE");\r
845 v.add("SEC");\r
846 v.add("PEI_CORE");\r
847 v.add("PEIM");\r
848 v.add("DXE_CORE");\r
849 v.add("DXE_DRIVER");\r
850 v.add("DXE_RUNTIME_DRIVER");\r
851 v.add("DXE_SAL_DRIVER");\r
852 v.add("DXE_SMM_DRIVER");\r
853 v.add("UEFI_DRIVER");\r
854 v.add("UEFI_APPLICATION");\r
855 v.add("USER_DEFINED");\r
856 iCheckBoxListArch.setAllItems(v);\r
857 }\r
858 return iCheckBoxListArch;\r
859 }\r
860 \r
861 private String booleanToString(boolean b1, boolean b2, boolean b3, boolean b4){\r
862 String s = " ";\r
863 if (b1){\r
864 s += "IA32 ";\r
865 }\r
866 if (b2){\r
867 s += "X64 ";\r
868 }\r
869 if (b3){\r
870 s += "IPF ";\r
871 }\r
872 if (b4){\r
873 s += "EBC ";\r
874 }\r
875 return s.trim();\r
876 }\r
877 \r
878 private String vectorToString(Vector<String> v) {\r
879 String s = " ";\r
880 for (int i = 0; i < v.size(); ++i) {\r
881 s += v.get(i);\r
882 s += " ";\r
883 }\r
884 return s.trim();\r
885 }\r
886 public static void main(String[] args){\r
887 new SpdLibClassDecls().setVisible(true);\r
888 }\r
889}\r
890\r
891\r