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