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