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