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