Remove empty FfsFileNameGuid element under ModuleSaBuildOptions if user input empty...
[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(key, 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 ffc.genLibraryInstance(model3.getValueAt(row, 1)+"", model3.getValueAt(row, 2)+"", model3.getValueAt(row, 3)+"", model3.getValueAt(row, 4)+"", moduleKey);
1022 //
1023 // Add pcd information of selected instance to current moduleSA
1024 //
1025 try{
1026 ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), null, ffc.getModuleSA(moduleKey));
1027 }
1028 catch (Exception exception) {
1029 JOptionPane.showMessageDialog(frame, "PCD Insertion Fail. " + exception.getMessage());
1030 }
1031 resolveLibraryInstances(instanceValue);
1032 }
1033 });
1034 }
1035 return jButton;
1036 }
1037
1038 /**
1039 * This method initializes jButton1
1040 *
1041 * @return javax.swing.JButton
1042 */
1043 private JButton getJButton1() {
1044 if (jButton1 == null) {
1045 jButton1 = new JButton();
1046 jButton1.setPreferredSize(new java.awt.Dimension(80,20));
1047 jButton1.setText("Delete");
1048 jButton1.addActionListener(new java.awt.event.ActionListener() {
1049 public void actionPerformed(java.awt.event.ActionEvent e) {
1050 int row = jTable1.getSelectedRow();
1051 if (row < 0) {
1052 return;
1053 }
1054 docConsole.setSaved(false);
1055 removeInstance(model1.getValueAt(row, 1) + " " +
1056 model1.getValueAt(row, 2) + " " +
1057 model1.getValueAt(row, 3) + " " +
1058 model1.getValueAt(row, 4));
1059 ffc.removeLibraryInstance(moduleKey, row);
1060 model1.removeRow(row);
1061
1062 }
1063 });
1064 }
1065 return jButton1;
1066 }
1067
1068 /**
1069 * This method initializes jButton2
1070 *
1071 * @return javax.swing.JButton
1072 */
1073 private JButton getJButton2() {
1074 if (jButton2 == null) {
1075 jButton2 = new JButton();
1076 jButton2.setPreferredSize(new java.awt.Dimension(80,20));
1077 jButton2.setText("Ok");
1078 jButton2.addActionListener(this);
1079 }
1080 return jButton2;
1081 }
1082
1083 /**
1084 * This method initializes jButton3
1085 *
1086 * @return javax.swing.JButton
1087 */
1088 private JButton getJButton3() {
1089 if (jButton3 == null) {
1090 jButton3 = new JButton();
1091 jButton3.setPreferredSize(new java.awt.Dimension(80,20));
1092 jButton3.setText("Cancel");
1093 jButton3.setVisible(false);
1094 }
1095 return jButton3;
1096 }
1097 public void actionPerformed(ActionEvent arg0) {
1098
1099 if (arg0.getSource() == jButton2) {
1100 if (jTable4.isEditing()) {
1101 jTable4.getCellEditor().stopCellEditing();
1102 }
1103 this.setVisible(false);
1104 }
1105 }
1106 /**
1107 * This method initializes jPanel8
1108 *
1109 * @return javax.swing.JPanel
1110 */
1111 private JPanel getJPanel8() {
1112 if (jPanel8 == null) {
1113 jLabel12 = new JLabel();
1114 jLabel12.setText("");
1115 jLabel12.setPreferredSize(new java.awt.Dimension(250,16));
1116 FlowLayout flowLayout4 = new FlowLayout();
1117 flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
1118 jLabel8 = new JLabel();
1119 jLabel8.setText("FFS Format Key");
1120 jLabel8.setPreferredSize(new java.awt.Dimension(90,16));
1121 jLabel7 = new JLabel();
1122 jLabel7.setText("FFS File GUID");
1123 jLabel7.setPreferredSize(new java.awt.Dimension(90,16));
1124 jLabel6 = new JLabel();
1125 jLabel6.setText("FV Binding");
1126 jLabel6.setPreferredSize(new java.awt.Dimension(90,16));
1127 jPanel8 = new JPanel();
1128 jPanel8.setLayout(flowLayout4);
1129 jPanel8.add(jLabel6, null);
1130 jPanel8.add(getJTextFieldFvBinding(), null);
1131 jPanel8.add(jLabel7, null);
1132 jPanel8.add(getJTextFieldFileGuid(), null);
1133 jPanel8.add(jLabel8, null);
1134 jPanel8.add(getJTextFieldFfsKey(), null);
1135 jPanel8.add(getJScrollPane6(), null);
1136 jPanel8.add(jLabel12, null);
1137 jPanel8.add(getJButton4(), null);
1138 jPanel8.add(getJButton5(), null);
1139 jPanel8.addComponentListener(new java.awt.event.ComponentAdapter() {
1140 public void componentShown(java.awt.event.ComponentEvent e) {
1141 initModuleSAOptions(moduleKey);
1142 }
1143 });
1144 }
1145 return jPanel8;
1146 }
1147 /**
1148 * This method initializes jTextField
1149 *
1150 * @return javax.swing.JTextField
1151 */
1152 private JTextField getJTextFieldFvBinding() {
1153 if (jTextFieldFvBinding == null) {
1154 jTextFieldFvBinding = new JTextField();
1155 jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(150,20));
1156 jTextFieldFvBinding.addFocusListener(new java.awt.event.FocusAdapter() {
1157 public void focusLost(java.awt.event.FocusEvent e) {
1158 String originalFvBinding = ffc.getFvBinding(moduleKey);
1159 String newFvBinding = jTextFieldFvBinding.getText();
1160 if (newFvBinding.equals(originalFvBinding)) {
1161 return;
1162 }
1163 if (newFvBinding.length() == 0 && originalFvBinding == null) {
1164 return;
1165 }
1166 docConsole.setSaved(false);
1167 ffc.setFvBinding(moduleKey, newFvBinding);
1168 }
1169 });
1170
1171 }
1172 return jTextFieldFvBinding;
1173 }
1174 /**
1175 * This method initializes jTextField1
1176 *
1177 * @return javax.swing.JTextField
1178 */
1179 private JTextField getJTextFieldFileGuid() {
1180 if (jTextFieldFileGuid == null) {
1181 jTextFieldFileGuid = new JTextField();
1182 jTextFieldFileGuid.setPreferredSize(new java.awt.Dimension(300,20));
1183 jTextFieldFileGuid.addFocusListener(new java.awt.event.FocusAdapter() {
1184 public void focusLost(java.awt.event.FocusEvent e) {
1185 String originalFileGuid = ffc.getFfsFileNameGuid(moduleKey);
1186 String newFileGuid = jTextFieldFileGuid.getText();
1187 if (newFileGuid.equals(originalFileGuid)) {
1188 return;
1189 }
1190 if (newFileGuid.length() == 0 && originalFileGuid == null) {
1191 return;
1192 }
1193 if (newFileGuid.length() > 0) {
1194 if (!DataValidation.isGuid(newFileGuid)) {
1195 JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type.");
1196 return;
1197 }
1198 }
1199
1200 docConsole.setSaved(false);
1201 if (newFileGuid.length() == 0) {
1202 newFileGuid = null;
1203 }
1204 ffc.setFfsFileNameGuid(moduleKey, newFileGuid);
1205 }
1206 });
1207
1208 }
1209 return jTextFieldFileGuid;
1210 }
1211 /**
1212 * This method initializes jTextFieldFfsKey
1213 *
1214 * @return javax.swing.JTextField
1215 */
1216 private JTextField getJTextFieldFfsKey() {
1217 if (jTextFieldFfsKey == null) {
1218 jTextFieldFfsKey = new JTextField();
1219 jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(150,20));
1220 jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {
1221 public void focusLost(java.awt.event.FocusEvent e) {
1222 String originalFfsKey = ffc.getFfsFormatKey(moduleKey);
1223 String newFfsKey = jTextFieldFfsKey.getText();
1224 if (newFfsKey.equals(originalFfsKey)) {
1225 return;
1226 }
1227 if (newFfsKey.length() == 0 && originalFfsKey == null) {
1228 return;
1229 }
1230 docConsole.setSaved(false);
1231 ffc.setFfsFormatKey(moduleKey, newFfsKey);
1232 }
1233 });
1234
1235 }
1236 return jTextFieldFfsKey;
1237 }
1238 /**
1239 * This method initializes jScrollPane6
1240 *
1241 * @return javax.swing.JScrollPane
1242 */
1243 private JScrollPane getJScrollPane6() {
1244 if (jScrollPane6 == null) {
1245 jScrollPane6 = new JScrollPane();
1246 jScrollPane6.setPreferredSize(new java.awt.Dimension(600,200));
1247 jScrollPane6.setViewportView(getJTable4());
1248 }
1249 return jScrollPane6;
1250 }
1251 /**
1252 * This method initializes jTable4
1253 *
1254 * @return javax.swing.JTable
1255 */
1256 private JTable getJTable4() {
1257 if (jTable4 == null) {
1258 optionsTableModel = new DefaultTableModel();
1259 optionsTableModel.addColumn("BuildTargets");
1260 optionsTableModel.addColumn("ToolChainFamily");
1261 optionsTableModel.addColumn("TagName");
1262 optionsTableModel.addColumn("ToolCode");
1263 optionsTableModel.addColumn("SupportedArchs");
1264 optionsTableModel.addColumn("Contents");
1265 jTable4 = new JTable(optionsTableModel);
1266 jTable4.setRowHeight(20);
1267 Vector<String> vArch = new Vector<String>();
1268 vArch.add("IA32");
1269 vArch.add("X64");
1270 vArch.add("IPF");
1271 vArch.add("EBC");
1272 vArch.add("ARM");
1273 vArch.add("PPC");
1274 jTable4.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch));
1275 jTable4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1276 jTable4.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
1277 jTable4.getModel().addTableModelListener(new TableModelListener() {
1278 public void tableChanged(TableModelEvent arg0) {
1279 // TODO Auto-generated method stub
1280 int row = arg0.getFirstRow();
1281 TableModel m = (TableModel)arg0.getSource();
1282
1283 if (arg0.getType() == TableModelEvent.UPDATE){
1284 //ToDo Data Validition check.
1285 String targets = m.getValueAt(row, 0) + "";
1286 Vector<Object> targetName = null;
1287 if (targets.length() > 0) {
1288 targetName = new Vector<Object>();
1289 String[] sArray = targets.split(" ");
1290 for (int i = 0; i < sArray.length; ++i) {
1291 targetName.add(sArray[i]);
1292 }
1293 }
1294
1295 String toolChain = m.getValueAt(row, 1) + "";
1296 String tagName = m.getValueAt(row, 2) + "";
1297 String toolCode = m.getValueAt(row, 3) + "";
1298 String archs = m.getValueAt(row, 4) + "";
1299 Vector<Object> supArch = null;
1300 if (archs.length() > 0) {
1301 supArch = new Vector<Object>();
1302 String[] sArray1 = archs.split(" ");
1303 for (int i = 0; i < sArray1.length; ++i) {
1304 supArch.add(sArray1[i]);
1305 }
1306 }
1307
1308 String contents = m.getValueAt(row, 5) + "";
1309 docConsole.setSaved(false);
1310 ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);
1311 }
1312 }
1313 });
1314 }
1315 return jTable4;
1316 }
1317 /**
1318 * This method initializes jButton4
1319 *
1320 * @return javax.swing.JButton
1321 */
1322 private JButton getJButton4() {
1323 if (jButton4 == null) {
1324 jButton4 = new JButton();
1325 jButton4.setPreferredSize(new java.awt.Dimension(80,20));
1326 jButton4.setText("New");
1327 jButton4.addActionListener(new java.awt.event.ActionListener() {
1328 public void actionPerformed(java.awt.event.ActionEvent e) {
1329 String[] row = {"", "", "", "", "", ""};
1330 optionsTableModel.addRow(row);
1331 Vector<Object> v = new Vector<Object>();
1332 Vector<Object> v1 = null;
1333 docConsole.setSaved(false);
1334 ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");
1335 }
1336 });
1337 }
1338 return jButton4;
1339 }
1340 /**
1341 * This method initializes jButton5
1342 *
1343 * @return javax.swing.JButton
1344 */
1345 private JButton getJButton5() {
1346 if (jButton5 == null) {
1347 jButton5 = new JButton();
1348 jButton5.setPreferredSize(new java.awt.Dimension(80,20));
1349 jButton5.setText("Delete");
1350 jButton5.addActionListener(new java.awt.event.ActionListener() {
1351 public void actionPerformed(java.awt.event.ActionEvent e) {
1352 if (jTable4.getSelectedRow() < 0) {
1353 return;
1354 }
1355 docConsole.setSaved(false);
1356 ffc.removeModuleSAOptionsOpt(moduleKey, jTable4.getSelectedRow());
1357 optionsTableModel.removeRow(jTable4.getSelectedRow());
1358 }
1359 });
1360 }
1361 return jButton5;
1362 }
1363
1364 /**
1365 Start the window at the center of screen
1366
1367 **/
1368 protected void centerWindow(int intWidth, int intHeight) {
1369 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
1370 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
1371 }
1372
1373 /**
1374 Start the window at the center of screen
1375
1376 **/
1377 protected void centerWindow() {
1378 centerWindow(this.getSize().width, this.getSize().height);
1379 }
1380 /**
1381 * This method initializes jPanel9
1382 *
1383 * @return javax.swing.JPanel
1384 */
1385 private JPanel getJPanel9() {
1386 if (jPanel9 == null) {
1387 GridLayout gridLayout = new GridLayout();
1388 gridLayout.setRows(3);
1389 gridLayout.setColumns(2);
1390 jPanel9 = new JPanel();
1391 jPanel9.setLayout(gridLayout);
1392 jPanel9.setPreferredSize(new java.awt.Dimension(600,90));
1393 jPanel9.add(getJPanel12(), null);
1394 jPanel9.add(getJPanel10(), null);
1395 jPanel9.add(getJPanel11(), null);
1396 }
1397 return jPanel9;
1398 }
1399 /**
1400 * This method initializes jPanel10
1401 *
1402 * @return javax.swing.JPanel
1403 */
1404 private JPanel getJPanel10() {
1405 if (jPanel10 == null) {
1406 FlowLayout flowLayout2 = new FlowLayout();
1407 flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
1408 jLabel10 = new JLabel();
1409 jLabel10.setText("Max Datum Size");
1410 jPanel10 = new JPanel();
1411 jPanel10.setLayout(flowLayout2);
1412 jPanel10.add(jLabel10, null);
1413 jPanel10.add(getJTextField3(), null);
1414 }
1415 return jPanel10;
1416 }
1417 /**
1418 * This method initializes jPanel11
1419 *
1420 * @return javax.swing.JPanel
1421 */
1422 private JPanel getJPanel11() {
1423 if (jPanel11 == null) {
1424 FlowLayout flowLayout3 = new FlowLayout();
1425 flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
1426 jLabel11 = new JLabel();
1427 jLabel11.setText("Default Value");
1428 jLabel11.setPreferredSize(new java.awt.Dimension(91,16));
1429 jPanel11 = new JPanel();
1430 jPanel11.setLayout(flowLayout3);
1431 jPanel11.add(jLabel11, null);
1432 jPanel11.add(getJTextField4(), null);
1433 jPanel11.add(getJComboBox1(), null);
1434 }
1435 return jPanel11;
1436 }
1437 /**
1438 * This method initializes jPanel12
1439 *
1440 * @return javax.swing.JPanel
1441 */
1442 private JPanel getJPanel12() {
1443 if (jPanel12 == null) {
1444 FlowLayout flowLayout1 = new FlowLayout();
1445 flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
1446 jLabel9 = new JLabel();
1447 jLabel9.setText("Item Type");
1448 jLabel9.setPreferredSize(new java.awt.Dimension(91,16));
1449 jPanel12 = new JPanel();
1450 jPanel12.setLayout(flowLayout1);
1451 jPanel12.add(jLabel9, null);
1452 jPanel12.add(getJComboBox(), null);
1453 jPanel12.add(getJButton6(), null);
1454 }
1455 return jPanel12;
1456 }
1457 /**
1458 * This method initializes jComboBox
1459 *
1460 * @return javax.swing.JComboBox
1461 */
1462 private JComboBox getJComboBox() {
1463 if (jComboBox == null) {
1464 jComboBox = new JComboBox();
1465 jComboBox.setPreferredSize(new java.awt.Dimension(200,20));
1466 jComboBox.addItemListener(new java.awt.event.ItemListener() {
1467 public void itemStateChanged(java.awt.event.ItemEvent e) {
1468 int row = jTable.getSelectedRow();
1469 if (row < 0 || jTable.getValueAt(row, 2).equals(jComboBox.getSelectedItem())) {
1470 return;
1471 }
1472 if (jComboBox.getItemCount() == 3) {
1473 if (!jComboBox.getSelectedItem().equals("DYNAMIC")) {
1474 pcdDynamicToNonDynamic(jTable.getValueAt(row, 0)+"", jTable.getValueAt(row, 1)+"");
1475 }
1476 else{
1477 pcdNonDynamicToDynamic(jTable.getValueAt(row, 0)+"", jTable.getValueAt(row, 1)+"");
1478 }
1479 }
1480 }
1481 });
1482 }
1483 return jComboBox;
1484 }
1485
1486 private void pcdDynamicToNonDynamic(String cName, String tsGuid) {
1487 String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];
1488 ffc.getDynamicPcdBuildData(saa);
1489 String maxSize = "";
1490 String value = "";
1491 for (int i = 0; i < saa.length; ++i) {
1492 if (saa[i][0].equals(cName) && saa[i][2].equals(tsGuid)) {
1493 maxSize = saa[i][3];
1494 value = ffc.getDynamicPcdBuildDataValue(i);
1495 break;
1496 }
1497 }
1498
1499 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1500 for (int i = 0; i < al.size(); ++i) {
1501 String[] s = al.get(i).split(" ");
1502 String mKey = s[0] + s[1] + s[2] + s[3];
1503 ffc.updatePcdData(mKey, cName, tsGuid, jComboBox.getSelectedItem()+"", maxSize, value);
1504 s[4] = jComboBox.getSelectedItem()+"";
1505 al.set(i, s[0]+" "+s[1]+" "+s[2]+" "+s[3]+" "+s[4]);
1506 }
1507
1508 ffc.removeDynamicPcdBuildData(cName, tsGuid);
1509 }
1510
1511 private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
1512 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1513 for (int i = 0; i < al.size(); ++i) {
1514 String[] s = al.get(i).split(" ");
1515 String mKey = s[0] + " " + s[1]+ " " + s[2] + " " + s[3];
1516 ffc.updatePcdData(mKey, cName, tsGuid, jComboBox.getSelectedItem()+"", jTextField3.getText(), jTextField4.isVisible() ? jTextField4.getText() : jComboBox1.getSelectedItem()+"");
1517 s[4] = jComboBox.getSelectedItem()+"";
1518 al.set(i, s[0]+" "+s[1]+" "+s[2]+" "+s[3]+" "+s[4]);
1519 }
1520 try{
1521 ffc.addDynamicPcdBuildData(cName, jTable.getValueAt(jTable.getSelectedRow(), 3), tsGuid, "DYNAMIC", jTable.getValueAt(jTable.getSelectedRow(), 5)+"", jTextField4.isVisible() ? jTextField4.getText() : jComboBox1.getSelectedItem()+"");
1522 }
1523 catch(Exception e){
1524 JOptionPane.showMessageDialog(frame, "PCD value format: " + e.getMessage());
1525 }
1526 }
1527 /**
1528 * This method initializes jTextField3
1529 *
1530 * @return javax.swing.JTextField
1531 */
1532 private JTextField getJTextField3() {
1533 if (jTextField3 == null) {
1534 jTextField3 = new JTextField();
1535 jTextField3.setPreferredSize(new java.awt.Dimension(200,20));
1536 }
1537 return jTextField3;
1538 }
1539 /**
1540 * This method initializes jTextField4
1541 *
1542 * @return javax.swing.JTextField
1543 */
1544 private JTextField getJTextField4() {
1545 if (jTextField4 == null) {
1546 jTextField4 = new JTextField();
1547 jTextField4.setPreferredSize(new java.awt.Dimension(200,20));
1548 }
1549 return jTextField4;
1550 }
1551 /**
1552 * This method initializes jButton6
1553 *
1554 * @return javax.swing.JButton
1555 */
1556 private JButton getJButton6() {
1557 if (jButton6 == null) {
1558 jButton6 = new JButton();
1559 jButton6.setPreferredSize(new java.awt.Dimension(150,20));
1560 jButton6.setText("Update PCD Data");
1561 jButton6.addActionListener(new java.awt.event.ActionListener() {
1562 public void actionPerformed(java.awt.event.ActionEvent e) {
1563 int row = jTable.getSelectedRow();
1564 if (row < 0) {
1565 return;
1566 }
1567 docConsole.setSaved(false);
1568 model.setValueAt(jComboBox.getSelectedItem(), row, 2);
1569 model.setValueAt(jTextField3.getText(), row, 4);
1570 model.setValueAt(jTextField4.isVisible()? jTextField4.getText():jComboBox1.getSelectedItem(), row, 6);
1571 ffc.updatePcdData(moduleKey, model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");
1572 }
1573 });
1574 }
1575 return jButton6;
1576 }
1577 /**
1578 * This method initializes jComboBox1
1579 *
1580 * @return javax.swing.JComboBox
1581 */
1582 private JComboBox getJComboBox1() {
1583 if (jComboBox1 == null) {
1584 jComboBox1 = new JComboBox();
1585 jComboBox1.setPreferredSize(new java.awt.Dimension(100,20));
1586 jComboBox1.setVisible(false);
1587 jComboBox1.addItem("true");
1588 jComboBox1.addItem("false");
1589 }
1590 return jComboBox1;
1591 }
1592
1593
1594 } // @jve:decl-index=0:visual-constraint="10,10"
1595
1596 class PartialEditableTableModel extends DefaultTableModel {
1597 /**
1598 *
1599 */
1600 private static final long serialVersionUID = 1L;
1601
1602 public boolean isCellEditable(int row, int col) {
1603 switch (col){
1604 case 2:
1605 return false;
1606 default:
1607 return false;
1608 }
1609
1610 }
1611 }
1612
1613 class LibraryTableModel extends DefaultTableModel {
1614 /**
1615 *
1616 */
1617 private static final long serialVersionUID = 1L;
1618
1619 public boolean isCellEditable(int row, int col) {
1620 return false;
1621 }
1622 }