]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
Fix EDKT143.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdModuleSA.java
1 package org.tianocore.frameworkwizard.platform.ui;
2
3 import java.awt.BorderLayout;
4 import java.awt.Dimension;
5 import java.awt.Toolkit;
6
7 import javax.swing.JFrame;
8 import javax.swing.JOptionPane;
9 import javax.swing.JPanel;
10 import javax.swing.JDialog;
11 import javax.swing.JTabbedPane;
12 import javax.swing.JLabel;
13 import javax.swing.JScrollPane;
14 import javax.swing.JTable;
15 import javax.swing.JTextArea;
16 import javax.swing.JSplitPane;
17 import javax.swing.JButton;
18 import javax.swing.ListSelectionModel;
19 import javax.swing.event.ListSelectionEvent;
20 import javax.swing.event.ListSelectionListener;
21 import javax.swing.event.TableModelEvent;
22 import javax.swing.event.TableModelListener;
23 import javax.swing.table.DefaultTableModel;
24 import javax.swing.table.TableModel;
25
26 import org.apache.xmlbeans.XmlObject;
27 import org.tianocore.frameworkwizard.common.DataValidation;
28 import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
29 import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
30 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
31 import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
32 import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
33
34 import java.awt.FlowLayout;
35 import java.awt.event.ActionEvent;
36 import java.awt.event.ActionListener;
37 import java.util.ArrayList;
38 import java.util.HashMap;
39 import java.util.Iterator;
40 import java.util.ListIterator;
41 import java.util.Map;
42 import java.util.Set;
43 import java.util.Vector;
44
45 import javax.swing.JTextField;
46 import java.awt.GridLayout;
47 import javax.swing.JComboBox;
48
49 public class FpdModuleSA extends JDialog implements ActionListener {
50
51 /**
52 *
53 */
54 private static final long serialVersionUID = 1L;
55 static JFrame frame;
56 private JPanel jContentPane = null;
57 private JTabbedPane jTabbedPane = null;
58 private JPanel jPanel = null;
59 private JPanel jPanel1 = null;
60 private JLabel jLabel = null;
61 private JScrollPane jScrollPane = null;
62 private JTable jTable = null;
63 private JPanel jPanel2 = null;
64 private JScrollPane jScrollPane1 = null;
65 private JTextArea jTextArea = null;
66 private JPanel jPanel3 = null;
67 private JSplitPane jSplitPane = null;
68 private JPanel jPanel4 = null;
69 private JPanel jPanel5 = null;
70 private JLabel jLabel1 = null;
71 private JLabel jLabel2 = null;
72 private JScrollPane jScrollPane2 = null;
73 private JTable jTable1 = null;
74 private JScrollPane jScrollPane3 = null;
75 private JTable jTable2 = null;
76 private JScrollPane jScrollPane4 = null;
77 private JTable jTable3 = null;
78 private JPanel jPanel6 = null;
79 private JPanel jPanel7 = null;
80 private JScrollPane jScrollPane5 = null;
81 private JTextArea jTextArea1 = null;
82 private JLabel jLabel3 = null;
83 private JLabel jLabel4 = null;
84 private JButton jButton = null;
85 private JButton jButton1 = null;
86 private JLabel jLabel5 = null;
87 private JButton jButton2 = null;
88 private JButton jButton3 = null;
89 private PartialEditableTableModel model = null;
90 private LibraryTableModel model1 = null;
91 private LibraryTableModel model2 = null;
92 private LibraryTableModel model3 = null;
93 private DefaultTableModel optionsTableModel = null;
94 private FpdFileContents ffc = null;
95 private String moduleKey = null;
96 private HashMap<String, ArrayList<String>> classInstanceMap = null;
97 private ArrayList<String> classProduced = null;
98 private HashMap<String, ArrayList<String>> classConsumed = null;
99 private JPanel jPanel8 = null;
100 private JLabel jLabel6 = null;
101 private JTextField jTextFieldFvBinding = null;
102 private JLabel jLabel7 = null;
103 private JTextField jTextFieldFileGuid = null;
104 private JLabel jLabel8 = null;
105 private JTextField jTextFieldFfsKey = null;
106 private JScrollPane jScrollPane6 = null;
107 private JTable jTable4 = null;
108 private JButton jButton4 = null;
109 private JButton jButton5 = null;
110 private JPanel jPanel9 = null;
111 private JPanel jPanel10 = null;
112 private JPanel jPanel11 = null;
113 private JPanel jPanel12 = null;
114 private JLabel jLabel9 = null;
115 private JComboBox jComboBox = null;
116 private JLabel jLabel10 = null;
117 private JTextField jTextField3 = null;
118 private JLabel jLabel11 = null;
119 private JTextField jTextField4 = null;
120 private JButton jButton6 = null;
121 private JComboBox jComboBox1 = null;
122 private OpeningPlatformType docConsole = null;
123 private JLabel jLabel12 = null;
124 /**
125 * This is the default constructor
126 */
127 public FpdModuleSA() {
128 super();
129 initialize();
130 }
131 public FpdModuleSA(FpdFileContents ffc) {
132 this();
133 this.ffc = ffc;
134 }
135
136 public void setKey(String k, int i, OpeningPlatformType dc){
137 this.moduleKey = k;
138 this.docConsole = dc;
139 jTabbedPane.setSelectedIndex(0);
140 initPcdBuildDefinition(i);
141 }
142
143 /**
144 init will be called each time FpdModuleSA object is to be shown.
145 @param key Module information.
146 **/
147 public void initPcdBuildDefinition(int i) {
148 //
149 // display pcd for key.
150 //
151 model.setRowCount(0);
152 int pcdCount = ffc.getPcdDataCount(i);
153 if (pcdCount != 0) {
154 String[][] saa = new String[pcdCount][7];
155 ffc.getPcdData(i, saa);
156 for (int j = 0; j < saa.length; ++j) {
157 model.addRow(saa[j]);
158 }
159 }
160 }
161
162 public void initLibraries(String key) {
163 //
164 // display library classes that need to be resolved. also potential instances for them.
165 //
166 resolveLibraryInstances(moduleKey);
167 //
168 // display lib instances already selected for key
169 //
170 model1.setRowCount(0);
171 int instanceCount = ffc.getLibraryInstancesCount(key);
172 if (instanceCount != 0) {
173 String[][] saa = new String[instanceCount][5];
174 ffc.getLibraryInstances(key, saa);
175 for (int i = 0; i < saa.length; ++i) {
176 ModuleIdentification mi = getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
177 if (mi != null) {
178 saa[i][0] = mi.getName();
179 saa[i][2] = mi.getVersion();
180 saa[i][4] = mi.getPackage().getVersion();
181 //
182 // re-evaluate lib instance usage when adding a already-selected lib instance.
183 //
184 resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
185 model1.addRow(saa[i]);
186 }
187
188
189 }
190 }
191 }
192
193 public void initModuleSAOptions(String key) {
194 //
195 // display module SA options
196 //
197 String fvBinding = ffc.getFvBinding(key);
198 if (fvBinding != null) {
199 jTextFieldFvBinding.setText(fvBinding);
200 }
201 String fileGuid = ffc.getFfsFileNameGuid(key);
202 if (fileGuid != null) {
203 jTextFieldFileGuid.setText(fileGuid);
204 }
205 String ffsKey = ffc.getFfsFormatKey(key);
206 if (ffsKey != null) {
207 jTextFieldFfsKey.setText(ffsKey);
208 }
209
210 optionsTableModel.setRowCount(0);
211 String[][] saa = new String[ffc.getModuleSAOptionsCount(key)][6];
212 ffc.getModuleSAOptions(key, saa);
213 for (int i = 0; i < saa.length; ++i) {
214 optionsTableModel.addRow(saa[i]);
215 }
216 }
217
218 private void resolveLibraryInstances(String key) {
219 ModuleIdentification mi = getModuleId(key);
220 PackageIdentification[] depPkgList = null;
221 try{
222 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
223 SurfaceAreaQuery.setDoc(m);
224 //
225 // Get dependency pkg list into which we will search lib instances.
226 //
227 depPkgList = SurfaceAreaQuery.getDependencePkg(null);
228 //
229 // Get the lib class consumed, produced by this module itself.
230 //
231 String[] classConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
232
233 if (this.classConsumed == null) {
234 this.classConsumed = new HashMap<String, ArrayList<String>>();
235 }
236
237 for(int i = 0; i < classConsumed.length; ++i){
238 ArrayList<String> consumedBy = this.classConsumed.get(classConsumed[i]);
239 if (consumedBy == null) {
240 consumedBy = new ArrayList<String>();
241 }
242 consumedBy.add(key);
243 this.classConsumed.put(classConsumed[i], consumedBy);
244 }
245
246 String[] classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
247 if (this.classProduced == null) {
248 this.classProduced = new ArrayList<String>();
249 }
250 for(int i = 0; i < classProduced.length; ++i){
251 if (!this.classProduced.contains(classProduced[i])){
252 this.classProduced.add(classProduced[i]);
253 }
254 }
255 //
256 // Get classes unresolved
257 //
258 // Iterator<String> lip = this.classProduced.listIterator();
259 // while(lip.hasNext()){
260 // String clsProduced = lip.next();
261 // this.classConsumed.remove(clsProduced);
262 //
263 // }
264 //
265 // find potential instances in all dependency pkgs for classes still in classConsumed.
266 //
267 if (classInstanceMap == null){
268 classInstanceMap = new HashMap<String, ArrayList<String>>();
269 }
270 Iterator<String> lic = this.classConsumed.keySet().iterator();
271 while(lic.hasNext()){
272 String cls = lic.next();
273 if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {
274 continue;
275 }
276 ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
277 if (instances.size() == 0){
278 JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " +
279 cls + ", Platform Build will Fail.");
280 }
281 classInstanceMap.put(cls, instances);
282
283 }
284
285 showClassToResolved();
286 }
287 catch(Exception e) {
288 e.printStackTrace();
289 }
290 }
291
292 private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{
293 ArrayList<String> al = new ArrayList<String>();
294
295 for (int i = 0; i < depPkgList.length; ++i) {
296 Set<ModuleIdentification> smi = GlobalData.getModules(depPkgList[i]);
297 Iterator ismi = smi.iterator();
298 while(ismi.hasNext()) {
299 ModuleIdentification mi = (ModuleIdentification)ismi.next();
300
301 String[] clsProduced = getClassProduced(mi);
302
303 boolean isPotential = false;
304 for (int j = 0; j < clsProduced.length; ++j) {
305 if (clsProduced[j] == null) {
306 continue;
307 }
308 if (clsProduced[j].equals(cls)){
309 isPotential = true;
310 }
311 if (classProduced.contains(clsProduced[j])) {
312 isPotential = false;
313 break;
314 }
315 }
316 if (isPotential) {
317 al.add(mi.getGuid() + " " + mi.getVersion() + " " +
318 depPkgList[i].getGuid() + " " + depPkgList[i].getVersion());
319 }
320 }
321 }
322
323 return al;
324 }
325
326 private void removeInstance(String key) {
327 ModuleIdentification mi = getModuleId(key);
328 //
329 // remove pcd information of instance from current ModuleSA
330 //
331 ffc.removePcdData(moduleKey, mi);
332 //
333 // remove class produced by this instance and add back these produced class to be bound.
334 //
335 String[] clsProduced = getClassProduced(mi);
336 for (int i = 0; i < clsProduced.length; ++i) {
337
338 classProduced.remove(clsProduced[i]);
339 }
340 //
341 // remove class consumed by this instance. we do not need to bound it now.
342 //
343 String[] clsConsumed = getClassConsumed(mi);
344 for (int i = 0; i < clsConsumed.length; ++i) {
345 ArrayList<String> al = classConsumed.get(clsConsumed[i]);
346
347 if (al == null ) {
348 classConsumed.remove(clsConsumed[i]);
349 continue;
350 }
351 al.remove(key);
352 if (al.size() == 0) {
353 classConsumed.remove(clsConsumed[i]);
354 }
355
356 }
357
358 showClassToResolved();
359
360 }
361
362 private ModuleIdentification getModuleId(String key){
363 //
364 // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion, Arch into string array.
365 //
366 String[] keyPart = key.split(" ");
367 Set<PackageIdentification> spi = GlobalData.getPackageList();
368 Iterator ispi = spi.iterator();
369
370 while(ispi.hasNext()) {
371 PackageIdentification pi = (PackageIdentification)ispi.next();
372 if ( !pi.getGuid().equals(keyPart[2])){
373
374 continue;
375 }
376 if (keyPart[3] != null && keyPart[3].length() > 0 && !keyPart[3].equals("null")){
377 if(!pi.getVersion().equals(keyPart[3])){
378 continue;
379 }
380 }
381 Set<ModuleIdentification> smi = GlobalData.getModules(pi);
382 Iterator ismi = smi.iterator();
383 while(ismi.hasNext()) {
384 ModuleIdentification mi = (ModuleIdentification)ismi.next();
385 if (mi.getGuid().equals(keyPart[0])){
386 if (keyPart[1] != null && keyPart[1].length() > 0 && !keyPart[1].equals("null")){
387 if(!mi.getVersion().equals(keyPart[1])){
388 continue;
389 }
390 }
391
392 return mi;
393 }
394 }
395 }
396 return null;
397 }
398
399 private String[] getClassProduced(ModuleIdentification mi){
400
401 try{
402 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
403 SurfaceAreaQuery.setDoc(m);
404 String[] clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
405 return clsProduced;
406
407 }catch (Exception e) {
408 e.printStackTrace();
409 }
410 return new String[0];
411
412 }
413
414 private String[] getClassConsumed(ModuleIdentification mi){
415
416 String[] clsConsumed = null;
417 try{
418 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
419 SurfaceAreaQuery.setDoc(m);
420 clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
421
422 }catch (Exception e) {
423 e.printStackTrace();
424 }
425 return clsConsumed;
426 }
427
428 private void showClassToResolved(){
429 model2.setRowCount(0);
430 if (classConsumed.size() == 0) {
431 return;
432 }
433 Iterator<String> li = classConsumed.keySet().iterator();
434 while(li.hasNext()){
435
436 String[] s = {li.next()};
437 if (classConsumed.get(s[0]) == null) {
438 continue;
439 }
440 if (classConsumed.get(s[0]).size() == 0) {
441 continue;
442 }
443 if (!classProduced.contains(s[0])){
444 model2.addRow(s);
445 }
446 }
447 model3.setRowCount(0);
448 }
449 /**
450 * This method initializes this
451 *
452 * @return void
453 */
454 private void initialize() {
455 this.setSize(664, 515);
456 this.centerWindow();
457 this.setModal(true);
458 this.setTitle("Module Settings");
459 this.setContentPane(getJContentPane());
460 }
461
462 /**
463 * This method initializes jContentPane
464 *
465 * @return javax.swing.JPanel
466 */
467 private JPanel getJContentPane() {
468 if (jContentPane == null) {
469 jContentPane = new JPanel();
470 jContentPane.setLayout(new BorderLayout());
471 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
472 jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH);
473 }
474 return jContentPane;
475 }
476
477 /**
478 * This method initializes jTabbedPane
479 *
480 * @return javax.swing.JTabbedPane
481 */
482 private JTabbedPane getJTabbedPane() {
483 if (jTabbedPane == null) {
484 jTabbedPane = new JTabbedPane();
485 jTabbedPane.addTab("PCD Build Definition", null, getJPanel(), null);
486 jTabbedPane.addTab("Module SA Options", null, getJPanel8(), null);
487 jTabbedPane.addTab("Libraries", null, getJPanel1(), null);
488 }
489 return jTabbedPane;
490 }
491
492 /**
493 * This method initializes jPanel
494 *
495 * @return javax.swing.JPanel
496 */
497 private JPanel getJPanel() {
498 if (jPanel == null) {
499 jLabel = new JLabel();
500 jLabel.setText("PcdData");
501 jPanel = new JPanel();
502 jPanel.setLayout(new BorderLayout());
503 jPanel.add(jLabel, java.awt.BorderLayout.NORTH);
504 jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
505 jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
506 jPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
507 public void componentShown(java.awt.event.ComponentEvent e) {
508 // initPcdBuildDefinition(moduleKey);
509 }
510 });
511
512 }
513 return jPanel;
514 }
515
516 /**
517 * This method initializes jPanel1
518 *
519 * @return javax.swing.JPanel
520 */
521 private JPanel getJPanel1() {
522 if (jPanel1 == null) {
523 jPanel1 = new JPanel();
524 jPanel1.setLayout(new BorderLayout());
525 jPanel1.add(getJSplitPane(), java.awt.BorderLayout.NORTH);
526 jPanel1.add(getJPanel6(), java.awt.BorderLayout.SOUTH);
527 jPanel1.add(getJPanel7(), java.awt.BorderLayout.CENTER);
528 jPanel1.addComponentListener(new java.awt.event.ComponentAdapter() {
529 public void componentShown(java.awt.event.ComponentEvent e) {
530 initLibraries(moduleKey);
531 }
532 });
533 }
534 return jPanel1;
535 }
536
537 /**
538 * This method initializes jScrollPane
539 *
540 * @return javax.swing.JScrollPane
541 */
542 private JScrollPane getJScrollPane() {
543 if (jScrollPane == null) {
544 jScrollPane = new JScrollPane();
545 jScrollPane.setViewportView(getJTable());
546 }
547 return jScrollPane;
548 }
549
550 /**
551 * This method initializes jTable
552 *
553 * @return javax.swing.JTable
554 */
555 private JTable getJTable() {
556 if (jTable == null) {
557 model = new PartialEditableTableModel();
558 jTable = new JTable(model);
559 jTable.setRowHeight(20);
560 jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
561 model.addColumn("CName");
562 model.addColumn("TokenSpaceGUID");
563 model.addColumn("ItemType");
564 model.addColumn("Token");
565 model.addColumn("MaxDatumSize");
566 model.addColumn("DataType");
567 model.addColumn("DefaultValue");
568
569 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
570 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
571 public void valueChanged(ListSelectionEvent e) {
572
573 if (e.getValueIsAdjusting()){
574 return;
575 }
576 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
577 if (lsm.isSelectionEmpty()) {
578 return;
579 }
580 else{
581 int selectedRow = lsm.getMinSelectionIndex();
582 String cName = jTable.getValueAt(selectedRow, 0)+"";
583 String[] pcdInfo = {"", ""};
584 getPcdInfo(cName, pcdInfo);
585 jTextArea.setText(pcdInfo[0]);
586 initComboBox(pcdInfo[1]);
587 jComboBox.setSelectedItem(pcdInfo[1]);
588 jTextField3.setEnabled(true);
589 jTextField3.setVisible(true);
590 jTextField3.setText(jTable.getValueAt(selectedRow, 4)+"");
591 jTextField4.setEnabled(true);
592 jTextField4.setText(jTable.getValueAt(selectedRow, 6)+"");
593 if (jTable.getValueAt(selectedRow, 5).equals("VOID*")) {
594 if (pcdInfo[1].equals("FEATURE_FLAG")) {
595 jTextField3.setVisible(false);
596 }
597 else if (pcdInfo[1].equals("FIXED_AT_BUILD")) {
598 try{
599 jTextField3.setEnabled(false);
600 jTextField3.setText(ffc.setMaxSizeForPointer(jTable.getValueAt(selectedRow, 6)+"")+"");
601 }
602 catch(Exception except){
603 JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage());
604 }
605 }
606 else{
607 jTextField3.setText(jTable.getValueAt(selectedRow, 4)+"");
608 }
609 }
610 else {
611 jTextField3.setEnabled(false);
612 }
613
614 if (!jTable.getValueAt(selectedRow, 2).equals("DYNAMIC") && !jTable.getValueAt(selectedRow, 2).equals("DYNAMIC_EX")) {
615 jTextField4.setText(jTable.getValueAt(selectedRow, 6)+"");
616 if (jTable.getValueAt(selectedRow, 2).equals("FEATURE_FLAG")){
617 jTextField4.setVisible(false);
618 jComboBox1.setVisible(true);
619 jComboBox1.setSelectedItem(jTable.getValueAt(selectedRow, 6)+"");
620 }
621 else{
622 jTextField4.setVisible(true);
623 jTextField4.setEnabled(true);
624 jComboBox1.setVisible(false);
625 }
626 }
627 else{
628 jTextField4.setEnabled(false);
629 }
630 }
631
632
633 }
634 });
635
636 jTable.getModel().addTableModelListener(new TableModelListener() {
637 public void tableChanged(TableModelEvent arg0) {
638 // TODO Auto-generated method stub
639 // int row = arg0.getFirstRow();
640 // TableModel m = (TableModel)arg0.getSource();
641
642 if (arg0.getType() == TableModelEvent.UPDATE){
643 //update xml doc here.
644
645 }
646 }
647 });
648 }
649 return jTable;
650 }
651
652 private void initComboBox(String originalType) {
653 jComboBox.removeAllItems();
654 jComboBox.addItem(originalType);
655 if (originalType.equals("PATCHABLE_IN_MODULE")) {
656 jComboBox.addItem("FIXED_AT_BUILD");
657 }
658 if (originalType.equals("DYNAMIC")) {
659 jComboBox.addItem("FIXED_AT_BUILD");
660 jComboBox.addItem("PATCHABLE_IN_MODULE");
661 }
662 }
663
664 private void getPcdInfo(String cName, String[] sa) {
665 String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];
666 ffc.getLibraryInstances(moduleKey, saa);
667
668 try{
669 if (ffc.getPcdBuildDataInfo(getModuleId(moduleKey), cName, sa)) {
670 return;
671 }
672 for (int j = 0; j < saa.length; ++j) {
673 if (ffc.getPcdBuildDataInfo(getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
674 cName, sa)) {
675 return;
676 }
677 }
678 }
679 catch(Exception e) {
680 JOptionPane.showMessageDialog(this, "Get PCD details fail: " + e.getMessage());
681 }
682 }
683
684 /**
685 * This method initializes jPanel2
686 *
687 * @return javax.swing.JPanel
688 */
689 private JPanel getJPanel2() {
690 if (jPanel2 == null) {
691 jLabel5 = new JLabel();
692 jLabel5.setText("PCD Description");
693 jPanel2 = new JPanel();
694 jPanel2.setPreferredSize(new java.awt.Dimension(607,200));
695 jPanel2.add(jLabel5, null);
696 jPanel2.add(getJScrollPane1(), null);
697 jPanel2.add(getJPanel9(), null);
698 }
699 return jPanel2;
700 }
701
702 /**
703 * This method initializes jScrollPane1
704 *
705 * @return javax.swing.JScrollPane
706 */
707 private JScrollPane getJScrollPane1() {
708 if (jScrollPane1 == null) {
709 jScrollPane1 = new JScrollPane();
710 jScrollPane1.setPreferredSize(new java.awt.Dimension(500,100));
711 jScrollPane1.setViewportView(getJTextArea());
712 }
713 return jScrollPane1;
714 }
715
716 /**
717 * This method initializes jTextArea
718 *
719 * @return javax.swing.JTextArea
720 */
721 private JTextArea getJTextArea() {
722 if (jTextArea == null) {
723 jTextArea = new JTextArea();
724 jTextArea.setEditable(false);
725 }
726 return jTextArea;
727 }
728
729 /**
730 * This method initializes jPanel3
731 *
732 * @return javax.swing.JPanel
733 */
734 private JPanel getJPanel3() {
735 if (jPanel3 == null) {
736 FlowLayout flowLayout = new FlowLayout();
737 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
738 jPanel3 = new JPanel();
739 jPanel3.setLayout(flowLayout);
740 jPanel3.add(getJButton2(), null);
741 jPanel3.add(getJButton3(), null);
742 }
743 return jPanel3;
744 }
745
746 /**
747 * This method initializes jSplitPane
748 *
749 * @return javax.swing.JSplitPane
750 */
751 private JSplitPane getJSplitPane() {
752 if (jSplitPane == null) {
753 jSplitPane = new JSplitPane();
754 jSplitPane.setDividerLocation(200);
755 jSplitPane.setLeftComponent(getJPanel4());
756 jSplitPane.setRightComponent(getJPanel5());
757 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
758 }
759 return jSplitPane;
760 }
761
762 /**
763 * This method initializes jPanel4
764 *
765 * @return javax.swing.JPanel
766 */
767 private JPanel getJPanel4() {
768 if (jPanel4 == null) {
769 jLabel1 = new JLabel();
770 jLabel1.setText("Library Classes Uninstantiated");
771 jPanel4 = new JPanel();
772 jPanel4.add(jLabel1, null);
773 jPanel4.add(getJScrollPane3(), null);
774 }
775 return jPanel4;
776 }
777
778 /**
779 * This method initializes jPanel5
780 *
781 * @return javax.swing.JPanel
782 */
783 private JPanel getJPanel5() {
784 if (jPanel5 == null) {
785 jLabel2 = new JLabel();
786 jLabel2.setText("Instances Available");
787 jPanel5 = new JPanel();
788 jPanel5.add(jLabel2, null);
789 jPanel5.add(getJScrollPane4(), null);
790 }
791 return jPanel5;
792 }
793
794 /**
795 * This method initializes jScrollPane2
796 *
797 * @return javax.swing.JScrollPane
798 */
799 private JScrollPane getJScrollPane2() {
800 if (jScrollPane2 == null) {
801 jScrollPane2 = new JScrollPane();
802 jScrollPane2.setPreferredSize(new java.awt.Dimension(453,150));
803 jScrollPane2.setViewportView(getJTable1());
804 }
805 return jScrollPane2;
806 }
807
808 /**
809 * This method initializes jTable1
810 *
811 * @return javax.swing.JTable
812 */
813 private JTable getJTable1() {
814 if (jTable1 == null) {
815 model1 = new LibraryTableModel();
816 model1.addColumn("Name");
817 model1.addColumn("ModuleGUID");
818 model1.addColumn("ModuleVersion");
819 model1.addColumn("PackageGUID");
820 model1.addColumn("PackageVersion");
821 jTable1 = new JTable(model1);
822 jTable1.setRowHeight(20);
823 jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
824 jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
825
826 }
827 return jTable1;
828 }
829
830 /**
831 * This method initializes jScrollPane3
832 *
833 * @return javax.swing.JScrollPane
834 */
835 private JScrollPane getJScrollPane3() {
836 if (jScrollPane3 == null) {
837 jScrollPane3 = new JScrollPane();
838 jScrollPane3.setPreferredSize(new java.awt.Dimension(200,170));
839 jScrollPane3.setViewportView(getJTable2());
840 }
841 return jScrollPane3;
842 }
843
844 /**
845 * This method initializes jTable2
846 *
847 * @return javax.swing.JTable
848 */
849 private JTable getJTable2() {
850 if (jTable2 == null) {
851 model2 = new LibraryTableModel();
852 model2.addColumn("LibraryClass");
853 jTable2 = new JTable(model2);
854 jTable2.setRowHeight(20);
855 jTable2.setShowGrid(false);
856 jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
857 jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
858 public void valueChanged(ListSelectionEvent e) {
859 if (e.getValueIsAdjusting()){
860 return;
861 }
862 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
863 if (lsm.isSelectionEmpty()) {
864 return;
865 }
866 else{
867 int selectedRow2 = lsm.getMinSelectionIndex();
868 if (selectedRow2 < 0) {
869 return;
870 }
871 //
872 // display potential lib instances according to class selection
873 //
874 model3.setRowCount(0);
875 String cls = model2.getValueAt(selectedRow2, 0).toString();
876 ArrayList<String> al = classInstanceMap.get(cls);
877 ListIterator<String> li = al.listIterator();
878 while(li.hasNext()) {
879 String instance = li.next();
880 String[] s = {"", "", "", "", ""};
881 if (getModuleId(instance) != null) {
882 s[0] = getModuleId(instance).getName();
883 }
884
885 String[] instancePart = instance.split(" ");
886 for (int i = 0; i < instancePart.length; ++i){
887 s[i+1] = instancePart[i];
888 }
889 model3.addRow(s);
890 }
891
892 }
893 }
894 });
895 }
896 return jTable2;
897 }
898
899 /**
900 * This method initializes jScrollPane4
901 *
902 * @return javax.swing.JScrollPane
903 */
904 private JScrollPane getJScrollPane4() {
905 if (jScrollPane4 == null) {
906 jScrollPane4 = new JScrollPane();
907 jScrollPane4.setPreferredSize(new java.awt.Dimension(430,170));
908 jScrollPane4.setViewportView(getJTable3());
909 }
910 return jScrollPane4;
911 }
912
913 /**
914 * This method initializes jTable3
915 *
916 * @return javax.swing.JTable
917 */
918 private JTable getJTable3() {
919 if (jTable3 == null) {
920 model3 = new LibraryTableModel();
921 model3.addColumn("Name");
922 model3.addColumn("ModuleGUID");
923 model3.addColumn("ModuleVersion");
924 model3.addColumn("PackageGUID");
925 model3.addColumn("PackageVersion");
926 jTable3 = new JTable(model3);
927 jTable3.setRowHeight(20);
928 jTable3.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
929 jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
930
931 }
932 return jTable3;
933 }
934
935 /**
936 * This method initializes jPanel6
937 *
938 * @return javax.swing.JPanel
939 */
940 private JPanel getJPanel6() {
941 if (jPanel6 == null) {
942 jPanel6 = new JPanel();
943 }
944 return jPanel6;
945 }
946
947 /**
948 * This method initializes jPanel7
949 *
950 * @return javax.swing.JPanel
951 */
952 private JPanel getJPanel7() {
953 if (jPanel7 == null) {
954 jLabel4 = new JLabel();
955 jLabel4.setText("Instance Description");
956 jLabel3 = new JLabel();
957 jLabel3.setText("Selected Instances");
958 jPanel7 = new JPanel();
959 jPanel7.add(jLabel4, null);
960 jPanel7.add(getJScrollPane5(), null);
961 jPanel7.add(getJButton(), null);
962 jPanel7.add(getJButton1(), null);
963 jPanel7.add(jLabel3, null);
964 jPanel7.add(getJScrollPane2(), null);
965 }
966 return jPanel7;
967 }
968
969 /**
970 * This method initializes jScrollPane5
971 *
972 * @return javax.swing.JScrollPane
973 */
974 private JScrollPane getJScrollPane5() {
975 if (jScrollPane5 == null) {
976 jScrollPane5 = new JScrollPane();
977 jScrollPane5.setPreferredSize(new java.awt.Dimension(300,50));
978 jScrollPane5.setViewportView(getJTextArea1());
979 }
980 return jScrollPane5;
981 }
982
983 /**
984 * This method initializes jTextArea1
985 *
986 * @return javax.swing.JTextArea
987 */
988 private JTextArea getJTextArea1() {
989 if (jTextArea1 == null) {
990 jTextArea1 = new JTextArea();
991 jTextArea1.setEditable(false);
992 }
993 return jTextArea1;
994 }
995
996 /**
997 * This method initializes jButton
998 *
999 * @return javax.swing.JButton
1000 */
1001 private JButton getJButton() {
1002 if (jButton == null) {
1003 jButton = new JButton();
1004 jButton.setPreferredSize(new java.awt.Dimension(80,20));
1005 jButton.setText("Add");
1006 jButton.addActionListener(new java.awt.event.ActionListener() {
1007 public void actionPerformed(java.awt.event.ActionEvent e) {
1008 int row = jTable3.getSelectedRow();
1009 if (row < 0) {
1010 return;
1011 }
1012 docConsole.setSaved(false);
1013 Object[] s = {model3.getValueAt(row, 0), model3.getValueAt(row, 1),
1014 model3.getValueAt(row, 2), model3.getValueAt(row, 3),
1015 model3.getValueAt(row, 4)};
1016 model1.addRow(s);
1017 String instanceValue = model3.getValueAt(row, 1) + " " +
1018 model3.getValueAt(row, 2) + " " +
1019 model3.getValueAt(row, 3) + " " +
1020 model3.getValueAt(row, 4);
1021 ModuleIdentification libMi = getModuleId(instanceValue);
1022 ffc.genLibraryInstance(libMi, moduleKey);
1023 //
1024 // Add pcd information of selected instance to current moduleSA
1025 //
1026 try{
1027 ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));
1028 }
1029 catch (Exception exception) {
1030 JOptionPane.showMessageDialog(frame, "PCD Insertion Fail. " + exception.getMessage());
1031 }
1032 resolveLibraryInstances(instanceValue);
1033 }
1034 });
1035 }
1036 return jButton;
1037 }
1038
1039 /**
1040 * This method initializes jButton1
1041 *
1042 * @return javax.swing.JButton
1043 */
1044 private JButton getJButton1() {
1045 if (jButton1 == null) {
1046 jButton1 = new JButton();
1047 jButton1.setPreferredSize(new java.awt.Dimension(80,20));
1048 jButton1.setText("Delete");
1049 jButton1.addActionListener(new java.awt.event.ActionListener() {
1050 public void actionPerformed(java.awt.event.ActionEvent e) {
1051 int row = jTable1.getSelectedRow();
1052 if (row < 0) {
1053 return;
1054 }
1055 docConsole.setSaved(false);
1056 removeInstance(model1.getValueAt(row, 1) + " " +
1057 model1.getValueAt(row, 2) + " " +
1058 model1.getValueAt(row, 3) + " " +
1059 model1.getValueAt(row, 4));
1060 ffc.removeLibraryInstance(moduleKey, row);
1061 model1.removeRow(row);
1062
1063 }
1064 });
1065 }
1066 return jButton1;
1067 }
1068
1069 /**
1070 * This method initializes jButton2
1071 *
1072 * @return javax.swing.JButton
1073 */
1074 private JButton getJButton2() {
1075 if (jButton2 == null) {
1076 jButton2 = new JButton();
1077 jButton2.setPreferredSize(new java.awt.Dimension(80,20));
1078 jButton2.setText("Ok");
1079 jButton2.addActionListener(this);
1080 }
1081 return jButton2;
1082 }
1083
1084 /**
1085 * This method initializes jButton3
1086 *
1087 * @return javax.swing.JButton
1088 */
1089 private JButton getJButton3() {
1090 if (jButton3 == null) {
1091 jButton3 = new JButton();
1092 jButton3.setPreferredSize(new java.awt.Dimension(80,20));
1093 jButton3.setText("Cancel");
1094 jButton3.setVisible(false);
1095 }
1096 return jButton3;
1097 }
1098 public void actionPerformed(ActionEvent arg0) {
1099
1100 if (arg0.getSource() == jButton2) {
1101 if (jTable4.isEditing()) {
1102 jTable4.getCellEditor().stopCellEditing();
1103 }
1104 this.setVisible(false);
1105 }
1106 }
1107 /**
1108 * This method initializes jPanel8
1109 *
1110 * @return javax.swing.JPanel
1111 */
1112 private JPanel getJPanel8() {
1113 if (jPanel8 == null) {
1114 jLabel12 = new JLabel();
1115 jLabel12.setText("");
1116 jLabel12.setPreferredSize(new java.awt.Dimension(250,16));
1117 FlowLayout flowLayout4 = new FlowLayout();
1118 flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
1119 jLabel8 = new JLabel();
1120 jLabel8.setText("FFS Format Key");
1121 jLabel8.setPreferredSize(new java.awt.Dimension(90,16));
1122 jLabel7 = new JLabel();
1123 jLabel7.setText("FFS File GUID");
1124 jLabel7.setPreferredSize(new java.awt.Dimension(90,16));
1125 jLabel6 = new JLabel();
1126 jLabel6.setText("FV Binding");
1127 jLabel6.setPreferredSize(new java.awt.Dimension(90,16));
1128 jPanel8 = new JPanel();
1129 jPanel8.setLayout(flowLayout4);
1130 jPanel8.add(jLabel6, null);
1131 jPanel8.add(getJTextFieldFvBinding(), null);
1132 jPanel8.add(jLabel7, null);
1133 jPanel8.add(getJTextFieldFileGuid(), null);
1134 jPanel8.add(jLabel8, null);
1135 jPanel8.add(getJTextFieldFfsKey(), null);
1136 jPanel8.add(getJScrollPane6(), null);
1137 jPanel8.add(jLabel12, null);
1138 jPanel8.add(getJButton4(), null);
1139 jPanel8.add(getJButton5(), null);
1140 jPanel8.addComponentListener(new java.awt.event.ComponentAdapter() {
1141 public void componentShown(java.awt.event.ComponentEvent e) {
1142 initModuleSAOptions(moduleKey);
1143 }
1144 });
1145 }
1146 return jPanel8;
1147 }
1148 /**
1149 * This method initializes jTextField
1150 *
1151 * @return javax.swing.JTextField
1152 */
1153 private JTextField getJTextFieldFvBinding() {
1154 if (jTextFieldFvBinding == null) {
1155 jTextFieldFvBinding = new JTextField();
1156 jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(150,20));
1157 jTextFieldFvBinding.addFocusListener(new java.awt.event.FocusAdapter() {
1158 public void focusLost(java.awt.event.FocusEvent e) {
1159 String originalFvBinding = ffc.getFvBinding(moduleKey);
1160 String newFvBinding = jTextFieldFvBinding.getText();
1161 if (newFvBinding.equals(originalFvBinding)) {
1162 return;
1163 }
1164 if (newFvBinding.length() == 0 && originalFvBinding == null) {
1165 return;
1166 }
1167 docConsole.setSaved(false);
1168 ffc.setFvBinding(moduleKey, newFvBinding);
1169 }
1170 });
1171
1172 }
1173 return jTextFieldFvBinding;
1174 }
1175 /**
1176 * This method initializes jTextField1
1177 *
1178 * @return javax.swing.JTextField
1179 */
1180 private JTextField getJTextFieldFileGuid() {
1181 if (jTextFieldFileGuid == null) {
1182 jTextFieldFileGuid = new JTextField();
1183 jTextFieldFileGuid.setPreferredSize(new java.awt.Dimension(300,20));
1184 jTextFieldFileGuid.addFocusListener(new java.awt.event.FocusAdapter() {
1185 public void focusLost(java.awt.event.FocusEvent e) {
1186 String originalFileGuid = ffc.getFfsFileNameGuid(moduleKey);
1187 String newFileGuid = jTextFieldFileGuid.getText();
1188 if (newFileGuid.equals(originalFileGuid)) {
1189 return;
1190 }
1191 if (newFileGuid.length() == 0 && originalFileGuid == null) {
1192 return;
1193 }
1194 if (newFileGuid.length() > 0) {
1195 if (!DataValidation.isGuid(newFileGuid)) {
1196 JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type.");
1197 return;
1198 }
1199 }
1200
1201 docConsole.setSaved(false);
1202 if (newFileGuid.length() == 0) {
1203 newFileGuid = null;
1204 }
1205 ffc.setFfsFileNameGuid(moduleKey, newFileGuid);
1206 }
1207 });
1208
1209 }
1210 return jTextFieldFileGuid;
1211 }
1212 /**
1213 * This method initializes jTextFieldFfsKey
1214 *
1215 * @return javax.swing.JTextField
1216 */
1217 private JTextField getJTextFieldFfsKey() {
1218 if (jTextFieldFfsKey == null) {
1219 jTextFieldFfsKey = new JTextField();
1220 jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(150,20));
1221 jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {
1222 public void focusLost(java.awt.event.FocusEvent e) {
1223 String originalFfsKey = ffc.getFfsFormatKey(moduleKey);
1224 String newFfsKey = jTextFieldFfsKey.getText();
1225 if (newFfsKey.equals(originalFfsKey)) {
1226 return;
1227 }
1228 if (newFfsKey.length() == 0 && originalFfsKey == null) {
1229 return;
1230 }
1231 docConsole.setSaved(false);
1232 ffc.setFfsFormatKey(moduleKey, newFfsKey);
1233 }
1234 });
1235
1236 }
1237 return jTextFieldFfsKey;
1238 }
1239 /**
1240 * This method initializes jScrollPane6
1241 *
1242 * @return javax.swing.JScrollPane
1243 */
1244 private JScrollPane getJScrollPane6() {
1245 if (jScrollPane6 == null) {
1246 jScrollPane6 = new JScrollPane();
1247 jScrollPane6.setPreferredSize(new java.awt.Dimension(600,200));
1248 jScrollPane6.setViewportView(getJTable4());
1249 }
1250 return jScrollPane6;
1251 }
1252 /**
1253 * This method initializes jTable4
1254 *
1255 * @return javax.swing.JTable
1256 */
1257 private JTable getJTable4() {
1258 if (jTable4 == null) {
1259 optionsTableModel = new DefaultTableModel();
1260 optionsTableModel.addColumn("BuildTargets");
1261 optionsTableModel.addColumn("ToolChainFamily");
1262 optionsTableModel.addColumn("TagName");
1263 optionsTableModel.addColumn("ToolCode");
1264 optionsTableModel.addColumn("SupportedArchs");
1265 optionsTableModel.addColumn("Contents");
1266 jTable4 = new JTable(optionsTableModel);
1267 jTable4.setRowHeight(20);
1268 Vector<String> vArch = new Vector<String>();
1269 vArch.add("IA32");
1270 vArch.add("X64");
1271 vArch.add("IPF");
1272 vArch.add("EBC");
1273 vArch.add("ARM");
1274 vArch.add("PPC");
1275 jTable4.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch));
1276 jTable4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1277 jTable4.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
1278 jTable4.getModel().addTableModelListener(new TableModelListener() {
1279 public void tableChanged(TableModelEvent arg0) {
1280 // TODO Auto-generated method stub
1281 int row = arg0.getFirstRow();
1282 TableModel m = (TableModel)arg0.getSource();
1283
1284 if (arg0.getType() == TableModelEvent.UPDATE){
1285 //ToDo Data Validition check.
1286 String targets = m.getValueAt(row, 0) + "";
1287 Vector<Object> targetName = null;
1288 if (targets.length() > 0) {
1289 targetName = new Vector<Object>();
1290 String[] sArray = targets.split(" ");
1291 for (int i = 0; i < sArray.length; ++i) {
1292 targetName.add(sArray[i]);
1293 }
1294 }
1295
1296 String toolChain = m.getValueAt(row, 1) + "";
1297 String tagName = m.getValueAt(row, 2) + "";
1298 String toolCode = m.getValueAt(row, 3) + "";
1299 String archs = m.getValueAt(row, 4) + "";
1300 Vector<Object> supArch = null;
1301 if (archs.length() > 0) {
1302 supArch = new Vector<Object>();
1303 String[] sArray1 = archs.split(" ");
1304 for (int i = 0; i < sArray1.length; ++i) {
1305 supArch.add(sArray1[i]);
1306 }
1307 }
1308
1309 String contents = m.getValueAt(row, 5) + "";
1310 docConsole.setSaved(false);
1311 ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);
1312 }
1313 }
1314 });
1315 }
1316 return jTable4;
1317 }
1318 /**
1319 * This method initializes jButton4
1320 *
1321 * @return javax.swing.JButton
1322 */
1323 private JButton getJButton4() {
1324 if (jButton4 == null) {
1325 jButton4 = new JButton();
1326 jButton4.setPreferredSize(new java.awt.Dimension(80,20));
1327 jButton4.setText("New");
1328 jButton4.addActionListener(new java.awt.event.ActionListener() {
1329 public void actionPerformed(java.awt.event.ActionEvent e) {
1330 String[] row = {"", "", "", "", "", ""};
1331 optionsTableModel.addRow(row);
1332 Vector<Object> v = new Vector<Object>();
1333 Vector<Object> v1 = null;
1334 docConsole.setSaved(false);
1335 ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");
1336 }
1337 });
1338 }
1339 return jButton4;
1340 }
1341 /**
1342 * This method initializes jButton5
1343 *
1344 * @return javax.swing.JButton
1345 */
1346 private JButton getJButton5() {
1347 if (jButton5 == null) {
1348 jButton5 = new JButton();
1349 jButton5.setPreferredSize(new java.awt.Dimension(80,20));
1350 jButton5.setText("Delete");
1351 jButton5.addActionListener(new java.awt.event.ActionListener() {
1352 public void actionPerformed(java.awt.event.ActionEvent e) {
1353 if (jTable4.getSelectedRow() < 0) {
1354 return;
1355 }
1356 docConsole.setSaved(false);
1357 ffc.removeModuleSAOptionsOpt(moduleKey, jTable4.getSelectedRow());
1358 optionsTableModel.removeRow(jTable4.getSelectedRow());
1359 }
1360 });
1361 }
1362 return jButton5;
1363 }
1364
1365 /**
1366 Start the window at the center of screen
1367
1368 **/
1369 protected void centerWindow(int intWidth, int intHeight) {
1370 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
1371 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
1372 }
1373
1374 /**
1375 Start the window at the center of screen
1376
1377 **/
1378 protected void centerWindow() {
1379 centerWindow(this.getSize().width, this.getSize().height);
1380 }
1381 /**
1382 * This method initializes jPanel9
1383 *
1384 * @return javax.swing.JPanel
1385 */
1386 private JPanel getJPanel9() {
1387 if (jPanel9 == null) {
1388 GridLayout gridLayout = new GridLayout();
1389 gridLayout.setRows(3);
1390 gridLayout.setColumns(2);
1391 jPanel9 = new JPanel();
1392 jPanel9.setLayout(gridLayout);
1393 jPanel9.setPreferredSize(new java.awt.Dimension(600,90));
1394 jPanel9.add(getJPanel12(), null);
1395 jPanel9.add(getJPanel10(), null);
1396 jPanel9.add(getJPanel11(), null);
1397 }
1398 return jPanel9;
1399 }
1400 /**
1401 * This method initializes jPanel10
1402 *
1403 * @return javax.swing.JPanel
1404 */
1405 private JPanel getJPanel10() {
1406 if (jPanel10 == null) {
1407 FlowLayout flowLayout2 = new FlowLayout();
1408 flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
1409 jLabel10 = new JLabel();
1410 jLabel10.setText("Max Datum Size");
1411 jPanel10 = new JPanel();
1412 jPanel10.setLayout(flowLayout2);
1413 jPanel10.add(jLabel10, null);
1414 jPanel10.add(getJTextField3(), null);
1415 }
1416 return jPanel10;
1417 }
1418 /**
1419 * This method initializes jPanel11
1420 *
1421 * @return javax.swing.JPanel
1422 */
1423 private JPanel getJPanel11() {
1424 if (jPanel11 == null) {
1425 FlowLayout flowLayout3 = new FlowLayout();
1426 flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
1427 jLabel11 = new JLabel();
1428 jLabel11.setText("Default Value");
1429 jLabel11.setPreferredSize(new java.awt.Dimension(91,16));
1430 jPanel11 = new JPanel();
1431 jPanel11.setLayout(flowLayout3);
1432 jPanel11.add(jLabel11, null);
1433 jPanel11.add(getJTextField4(), null);
1434 jPanel11.add(getJComboBox1(), null);
1435 }
1436 return jPanel11;
1437 }
1438 /**
1439 * This method initializes jPanel12
1440 *
1441 * @return javax.swing.JPanel
1442 */
1443 private JPanel getJPanel12() {
1444 if (jPanel12 == null) {
1445 FlowLayout flowLayout1 = new FlowLayout();
1446 flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
1447 jLabel9 = new JLabel();
1448 jLabel9.setText("Item Type");
1449 jLabel9.setPreferredSize(new java.awt.Dimension(91,16));
1450 jPanel12 = new JPanel();
1451 jPanel12.setLayout(flowLayout1);
1452 jPanel12.add(jLabel9, null);
1453 jPanel12.add(getJComboBox(), null);
1454 jPanel12.add(getJButton6(), null);
1455 }
1456 return jPanel12;
1457 }
1458 /**
1459 * This method initializes jComboBox
1460 *
1461 * @return javax.swing.JComboBox
1462 */
1463 private JComboBox getJComboBox() {
1464 if (jComboBox == null) {
1465 jComboBox = new JComboBox();
1466 jComboBox.setPreferredSize(new java.awt.Dimension(200,20));
1467 jComboBox.addItemListener(new java.awt.event.ItemListener() {
1468 public void itemStateChanged(java.awt.event.ItemEvent e) {
1469 int row = jTable.getSelectedRow();
1470 if (row < 0 || jTable.getValueAt(row, 2).equals(jComboBox.getSelectedItem())) {
1471 return;
1472 }
1473 if (jComboBox.getItemCount() == 3) {
1474 if (!jComboBox.getSelectedItem().equals("DYNAMIC")) {
1475 pcdDynamicToNonDynamic(jTable.getValueAt(row, 0)+"", jTable.getValueAt(row, 1)+"");
1476 }
1477 else{
1478 pcdNonDynamicToDynamic(jTable.getValueAt(row, 0)+"", jTable.getValueAt(row, 1)+"");
1479 }
1480 }
1481 }
1482 });
1483 }
1484 return jComboBox;
1485 }
1486
1487 private void pcdDynamicToNonDynamic(String cName, String tsGuid) {
1488 String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];
1489 ffc.getDynamicPcdBuildData(saa);
1490 String maxSize = "";
1491 String value = "";
1492 for (int i = 0; i < saa.length; ++i) {
1493 if (saa[i][0].equals(cName) && saa[i][2].equals(tsGuid)) {
1494 maxSize = saa[i][3];
1495 value = ffc.getDynamicPcdBuildDataValue(i);
1496 break;
1497 }
1498 }
1499
1500 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1501 for (int i = 0; i < al.size(); ++i) {
1502 String[] s = al.get(i).split(" ");
1503 String mKey = s[0] + s[1] + s[2] + s[3];
1504 ffc.updatePcdData(mKey, cName, tsGuid, jComboBox.getSelectedItem()+"", maxSize, value);
1505 s[4] = jComboBox.getSelectedItem()+"";
1506 al.set(i, s[0]+" "+s[1]+" "+s[2]+" "+s[3]+" "+s[4]);
1507 }
1508
1509 ffc.removeDynamicPcdBuildData(cName, tsGuid);
1510 }
1511
1512 private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
1513 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1514 for (int i = 0; i < al.size(); ++i) {
1515 String[] s = al.get(i).split(" ");
1516 String mKey = s[0] + " " + s[1]+ " " + s[2] + " " + s[3];
1517 ffc.updatePcdData(mKey, cName, tsGuid, jComboBox.getSelectedItem()+"", jTextField3.getText(), jTextField4.isVisible() ? jTextField4.getText() : jComboBox1.getSelectedItem()+"");
1518 s[4] = jComboBox.getSelectedItem()+"";
1519 al.set(i, s[0]+" "+s[1]+" "+s[2]+" "+s[3]+" "+s[4]);
1520 }
1521 try{
1522 ffc.addDynamicPcdBuildData(cName, jTable.getValueAt(jTable.getSelectedRow(), 3), tsGuid, "DYNAMIC", jTable.getValueAt(jTable.getSelectedRow(), 5)+"", jTextField4.isVisible() ? jTextField4.getText() : jComboBox1.getSelectedItem()+"");
1523 }
1524 catch(Exception e){
1525 JOptionPane.showMessageDialog(frame, "PCD value format: " + e.getMessage());
1526 }
1527 }
1528 /**
1529 * This method initializes jTextField3
1530 *
1531 * @return javax.swing.JTextField
1532 */
1533 private JTextField getJTextField3() {
1534 if (jTextField3 == null) {
1535 jTextField3 = new JTextField();
1536 jTextField3.setPreferredSize(new java.awt.Dimension(200,20));
1537 }
1538 return jTextField3;
1539 }
1540 /**
1541 * This method initializes jTextField4
1542 *
1543 * @return javax.swing.JTextField
1544 */
1545 private JTextField getJTextField4() {
1546 if (jTextField4 == null) {
1547 jTextField4 = new JTextField();
1548 jTextField4.setPreferredSize(new java.awt.Dimension(200,20));
1549 }
1550 return jTextField4;
1551 }
1552 /**
1553 * This method initializes jButton6
1554 *
1555 * @return javax.swing.JButton
1556 */
1557 private JButton getJButton6() {
1558 if (jButton6 == null) {
1559 jButton6 = new JButton();
1560 jButton6.setPreferredSize(new java.awt.Dimension(150,20));
1561 jButton6.setText("Update PCD Data");
1562 jButton6.addActionListener(new java.awt.event.ActionListener() {
1563 public void actionPerformed(java.awt.event.ActionEvent e) {
1564 int row = jTable.getSelectedRow();
1565 if (row < 0) {
1566 return;
1567 }
1568 docConsole.setSaved(false);
1569 model.setValueAt(jComboBox.getSelectedItem(), row, 2);
1570 model.setValueAt(jTextField3.getText(), row, 4);
1571 model.setValueAt(jTextField4.isVisible()? jTextField4.getText():jComboBox1.getSelectedItem(), row, 6);
1572 ffc.updatePcdData(moduleKey, model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");
1573 }
1574 });
1575 }
1576 return jButton6;
1577 }
1578 /**
1579 * This method initializes jComboBox1
1580 *
1581 * @return javax.swing.JComboBox
1582 */
1583 private JComboBox getJComboBox1() {
1584 if (jComboBox1 == null) {
1585 jComboBox1 = new JComboBox();
1586 jComboBox1.setPreferredSize(new java.awt.Dimension(100,20));
1587 jComboBox1.setVisible(false);
1588 jComboBox1.addItem("true");
1589 jComboBox1.addItem("false");
1590 }
1591 return jComboBox1;
1592 }
1593
1594
1595 } // @jve:decl-index=0:visual-constraint="10,10"
1596
1597 class PartialEditableTableModel extends DefaultTableModel {
1598 /**
1599 *
1600 */
1601 private static final long serialVersionUID = 1L;
1602
1603 public boolean isCellEditable(int row, int col) {
1604 switch (col){
1605 case 2:
1606 return false;
1607 default:
1608 return false;
1609 }
1610
1611 }
1612 }
1613
1614 class LibraryTableModel extends DefaultTableModel {
1615 /**
1616 *
1617 */
1618 private static final long serialVersionUID = 1L;
1619
1620 public boolean isCellEditable(int row, int col) {
1621 return false;
1622 }
1623 }