]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
58c181dcd38fe4a2d710d719e4d142382061146c
[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
5 import javax.swing.JFrame;
6 import javax.swing.JOptionPane;
7 import javax.swing.JPanel;
8 import javax.swing.JDialog;
9 import javax.swing.JTabbedPane;
10 import javax.swing.JLabel;
11 import javax.swing.JScrollPane;
12 import javax.swing.JTable;
13 import javax.swing.JTextArea;
14 import javax.swing.JSplitPane;
15 import javax.swing.JButton;
16 import javax.swing.ListSelectionModel;
17 import javax.swing.event.ListSelectionEvent;
18 import javax.swing.event.ListSelectionListener;
19 import javax.swing.event.TableModelEvent;
20 import javax.swing.event.TableModelListener;
21 import javax.swing.table.DefaultTableModel;
22 import javax.swing.table.TableModel;
23
24 import org.apache.xmlbeans.XmlObject;
25 import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;
26 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
27 import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;
28 import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;
29
30 import java.awt.FlowLayout;
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.util.ArrayList;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.ListIterator;
37 import java.util.Map;
38 import java.util.Set;
39 import java.util.Vector;
40
41 import javax.swing.JTextField;
42
43 public class FpdModuleSA extends JDialog implements ActionListener {
44
45 /**
46 *
47 */
48 private static final long serialVersionUID = 1L;
49 static JFrame frame;
50 private JPanel jContentPane = null;
51 private JTabbedPane jTabbedPane = null;
52 private JPanel jPanel = null;
53 private JPanel jPanel1 = null;
54 private JLabel jLabel = null;
55 private JScrollPane jScrollPane = null;
56 private JTable jTable = null;
57 private JPanel jPanel2 = null;
58 private JScrollPane jScrollPane1 = null;
59 private JTextArea jTextArea = null;
60 private JPanel jPanel3 = null;
61 private JSplitPane jSplitPane = null;
62 private JPanel jPanel4 = null;
63 private JPanel jPanel5 = null;
64 private JLabel jLabel1 = null;
65 private JLabel jLabel2 = null;
66 private JScrollPane jScrollPane2 = null;
67 private JTable jTable1 = null;
68 private JScrollPane jScrollPane3 = null;
69 private JTable jTable2 = null;
70 private JScrollPane jScrollPane4 = null;
71 private JTable jTable3 = null;
72 private JPanel jPanel6 = null;
73 private JPanel jPanel7 = null;
74 private JScrollPane jScrollPane5 = null;
75 private JTextArea jTextArea1 = null;
76 private JLabel jLabel3 = null;
77 private JLabel jLabel4 = null;
78 private JButton jButton = null;
79 private JButton jButton1 = null;
80 private JLabel jLabel5 = null;
81 private JButton jButton2 = null;
82 private JButton jButton3 = null;
83 private PartialEditableTableModel model = null;
84 private LibraryTableModel model1 = null;
85 private LibraryTableModel model2 = null;
86 private LibraryTableModel model3 = null;
87 private DefaultTableModel optionsTableModel = null;
88 private FpdFileContents ffc = null;
89 private String moduleKey = null;
90 private HashMap<String, ArrayList<String>> classInstanceMap = null;
91 private ArrayList<String> classProduced = null;
92 private HashMap<String, ArrayList<String>> classConsumed = null;
93 private JPanel jPanel8 = null;
94 private JLabel jLabel6 = null;
95 private JTextField jTextField = null;
96 private JLabel jLabel7 = null;
97 private JTextField jTextField1 = null;
98 private JLabel jLabel8 = null;
99 private JTextField jTextField2 = null;
100 private JScrollPane jScrollPane6 = null;
101 private JTable jTable4 = null;
102 private JButton jButton4 = null;
103 private JButton jButton5 = null;
104 /**
105 * This is the default constructor
106 */
107 public FpdModuleSA() {
108 super();
109 initialize();
110 }
111 public FpdModuleSA(FpdFileContents ffc) {
112 this();
113 this.ffc = ffc;
114 }
115
116 public void setKey(String k){
117 this.moduleKey = k;
118 }
119
120 /**
121 init will be called each time FpdModuleSA object is to be shown.
122 @param key Module information.
123 **/
124 public void init(String key) {
125 //
126 // display pcd for key.
127 //
128 model.setRowCount(0);
129 int pcdCount = ffc.getPcdDataCount(key);
130 if (pcdCount != 0) {
131 String[][] saa = new String[pcdCount][6];
132 ffc.getPcdData(key, saa);
133 for (int i = 0; i < saa.length; ++i) {
134 model.addRow(saa[i]);
135 }
136 }
137
138 //
139 // display lib instances already selected for key
140 //
141 model1.setRowCount(0);
142 int instanceCount = ffc.getLibraryInstancesCount(key);
143 if (instanceCount != 0) {
144 String[][] saa = new String[instanceCount][5];
145 ffc.getLibraryInstances(key, saa);
146 for (int i = 0; i < saa.length; ++i) {
147 if (getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]) != null) {
148 saa[i][0] = getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]).getName();
149 }
150
151 model1.addRow(saa[i]);
152 }
153 }
154 //
155 // display library classes that need to be resolved. also potential instances for them.
156 //
157 resolveLibraryInstances(key);
158 //
159 // display module SA options
160 //
161 String fvBinding = ffc.getFvBinding(key);
162 if (fvBinding != null) {
163 jTextField.setText(fvBinding);
164 }
165 String fileGuid = ffc.getFfsFileNameGuid(key);
166 if (fileGuid != null) {
167 jTextField1.setText(fileGuid);
168 }
169 String ffsKey = ffc.getFfsFormatKey(key);
170 if (ffsKey != null) {
171 jTextField2.setText(ffsKey);
172 }
173 }
174
175 private void resolveLibraryInstances(String key) {
176 ModuleIdentification mi = getModuleId(key);
177 PackageIdentification[] depPkgList = null;
178 try{
179 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
180 SurfaceAreaQuery.setDoc(m);
181 //
182 // Get dependency pkg list into which we will search lib instances.
183 //
184 depPkgList = SurfaceAreaQuery.getDependencePkg(null);
185 //
186 // Get the lib class consumed, produced by this module itself.
187 //
188 String[] classConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
189
190 if (this.classConsumed == null) {
191 this.classConsumed = new HashMap<String, ArrayList<String>>();
192 }
193
194 for(int i = 0; i < classConsumed.length; ++i){
195 ArrayList<String> consumedBy = this.classConsumed.get(classConsumed[i]);
196 if (consumedBy == null) {
197 consumedBy = new ArrayList<String>();
198 }
199 consumedBy.add(key);
200 this.classConsumed.put(classConsumed[i], consumedBy);
201 }
202
203 String[] classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
204 if (this.classProduced == null) {
205 this.classProduced = new ArrayList<String>();
206 }
207 for(int i = 0; i < classProduced.length; ++i){
208 if (!this.classProduced.contains(classProduced[i])){
209 this.classProduced.add(classProduced[i]);
210 }
211 }
212 //
213 // Get classes unresolved
214 //
215 // Iterator<String> lip = this.classProduced.listIterator();
216 // while(lip.hasNext()){
217 // String clsProduced = lip.next();
218 // this.classConsumed.remove(clsProduced);
219 //
220 // }
221 //
222 // find potential instances in all dependency pkgs for classes still in classConsumed.
223 //
224 if (classInstanceMap == null){
225 classInstanceMap = new HashMap<String, ArrayList<String>>();
226 }
227 Iterator<String> lic = this.classConsumed.keySet().iterator();
228 while(lic.hasNext()){
229 String cls = lic.next();
230 if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {
231 continue;
232 }
233 ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
234 if (instances.size() == 0){
235 JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " +
236 cls + ", Platform Build will Fail.");
237 }
238 classInstanceMap.put(cls, instances);
239
240 }
241
242 showClassToResolved();
243 }
244 catch(Exception e) {
245 e.printStackTrace();
246 }
247 }
248
249 private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{
250 ArrayList<String> al = new ArrayList<String>();
251
252 for (int i = 0; i < depPkgList.length; ++i) {
253 Set<ModuleIdentification> smi = GlobalData.getModules(depPkgList[i]);
254 Iterator ismi = smi.iterator();
255 while(ismi.hasNext()) {
256 ModuleIdentification mi = (ModuleIdentification)ismi.next();
257
258 String[] clsProduced = getClassProduced(mi);
259
260 boolean isPotential = false;
261 for (int j = 0; j < clsProduced.length; ++j) {
262 if (clsProduced[j] == null) {
263 continue;
264 }
265 if (clsProduced[j].equals(cls)){
266 isPotential = true;
267 }
268 if (classProduced.contains(clsProduced[j])) {
269 isPotential = false;
270 break;
271 }
272 }
273 if (isPotential) {
274 al.add(mi.getGuid() + " " + mi.getVersion() + " " +
275 depPkgList[i].getGuid() + " " + depPkgList[i].getVersion());
276 }
277 }
278 }
279
280 return al;
281 }
282
283 private void removeInstance(String key) {
284 ModuleIdentification mi = getModuleId(key);
285 //
286 // remove pcd information of instance from current ModuleSA
287 //
288 ffc.removePcdDataFromLibraryInstance(moduleKey, key);
289 //
290 // remove class produced by this instance and add back these produced class to be bound.
291 //
292 String[] clsProduced = getClassProduced(mi);
293 for (int i = 0; i < clsProduced.length; ++i) {
294
295 classProduced.remove(clsProduced[i]);
296 }
297 //
298 // remove class consumed by this instance. we do not need to bound it now.
299 //
300 String[] clsConsumed = getClassConsumed(mi);
301 for (int i = 0; i < clsConsumed.length; ++i) {
302 ArrayList<String> al = classConsumed.get(clsConsumed[i]);
303
304 if (al == null ) {
305 classConsumed.remove(clsConsumed[i]);
306 continue;
307 }
308 al.remove(key);
309 if (al.size() == 0) {
310 classConsumed.remove(clsConsumed[i]);
311 }
312
313 }
314
315 showClassToResolved();
316
317 }
318
319 private ModuleIdentification getModuleId(String key){
320 //
321 // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion into string array.
322 //
323 String[] keyPart = key.split(" ");
324 Set<PackageIdentification> spi = GlobalData.getPackageList();
325 Iterator ispi = spi.iterator();
326
327 while(ispi.hasNext()) {
328 PackageIdentification pi = (PackageIdentification)ispi.next();
329 if ( !pi.getGuid().equals(keyPart[2]) || !pi.getVersion().equals(keyPart[3])){
330 continue;
331 }
332 Set<ModuleIdentification> smi = GlobalData.getModules(pi);
333 Iterator ismi = smi.iterator();
334 while(ismi.hasNext()) {
335 ModuleIdentification mi = (ModuleIdentification)ismi.next();
336 if (mi.getGuid().equals(keyPart[0]) && mi.getVersion().equals(keyPart[1])){
337 return mi;
338 }
339 }
340 }
341 return null;
342 }
343
344 private String[] getClassProduced(ModuleIdentification mi){
345
346 try{
347 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
348 SurfaceAreaQuery.setDoc(m);
349 String[] clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
350 return clsProduced;
351
352 }catch (Exception e) {
353 e.printStackTrace();
354 }
355 return new String[0];
356
357 }
358
359 private String[] getClassConsumed(ModuleIdentification mi){
360
361 String[] clsConsumed = null;
362 try{
363 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);
364 SurfaceAreaQuery.setDoc(m);
365 clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");
366
367 }catch (Exception e) {
368 e.printStackTrace();
369 }
370 return clsConsumed;
371 }
372
373 private void showClassToResolved(){
374 model2.setRowCount(0);
375 if (classConsumed.size() == 0) {
376 return;
377 }
378 Iterator<String> li = classConsumed.keySet().iterator();
379 while(li.hasNext()){
380
381 String[] s = {li.next()};
382 if (classConsumed.get(s[0]) == null) {
383 continue;
384 }
385 if (classConsumed.get(s[0]).size() == 0) {
386 continue;
387 }
388 if (!classProduced.contains(s[0])){
389 model2.addRow(s);
390 }
391 }
392 model3.setRowCount(0);
393 }
394 /**
395 * This method initializes this
396 *
397 * @return void
398 */
399 private void initialize() {
400 this.setSize(664, 515);
401 this.setModal(true);
402 this.setTitle("Module Settings");
403 this.setContentPane(getJContentPane());
404 }
405
406 /**
407 * This method initializes jContentPane
408 *
409 * @return javax.swing.JPanel
410 */
411 private JPanel getJContentPane() {
412 if (jContentPane == null) {
413 jContentPane = new JPanel();
414 jContentPane.setLayout(new BorderLayout());
415 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
416 jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH);
417 }
418 return jContentPane;
419 }
420
421 /**
422 * This method initializes jTabbedPane
423 *
424 * @return javax.swing.JTabbedPane
425 */
426 private JTabbedPane getJTabbedPane() {
427 if (jTabbedPane == null) {
428 jTabbedPane = new JTabbedPane();
429 jTabbedPane.addTab("PCD Build Definition", null, getJPanel(), null);
430 jTabbedPane.addTab("Module SA Options", null, getJPanel8(), null);
431 jTabbedPane.addTab("Libraries", null, getJPanel1(), null);
432 }
433 return jTabbedPane;
434 }
435
436 /**
437 * This method initializes jPanel
438 *
439 * @return javax.swing.JPanel
440 */
441 private JPanel getJPanel() {
442 if (jPanel == null) {
443 jLabel = new JLabel();
444 jLabel.setText("PcdData");
445 jPanel = new JPanel();
446 jPanel.setLayout(new BorderLayout());
447 jPanel.add(jLabel, java.awt.BorderLayout.NORTH);
448 jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
449 jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);
450 jPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
451 public void componentShown(java.awt.event.ComponentEvent e) {
452 init(moduleKey);
453 }
454 });
455
456 }
457 return jPanel;
458 }
459
460 /**
461 * This method initializes jPanel1
462 *
463 * @return javax.swing.JPanel
464 */
465 private JPanel getJPanel1() {
466 if (jPanel1 == null) {
467 jPanel1 = new JPanel();
468 jPanel1.setLayout(new BorderLayout());
469 jPanel1.add(getJSplitPane(), java.awt.BorderLayout.NORTH);
470 jPanel1.add(getJPanel6(), java.awt.BorderLayout.SOUTH);
471 jPanel1.add(getJPanel7(), java.awt.BorderLayout.CENTER);
472 jPanel1.addComponentListener(new java.awt.event.ComponentAdapter() {
473 public void componentShown(java.awt.event.ComponentEvent e) {
474 }
475 });
476 }
477 return jPanel1;
478 }
479
480 /**
481 * This method initializes jScrollPane
482 *
483 * @return javax.swing.JScrollPane
484 */
485 private JScrollPane getJScrollPane() {
486 if (jScrollPane == null) {
487 jScrollPane = new JScrollPane();
488 jScrollPane.setViewportView(getJTable());
489 }
490 return jScrollPane;
491 }
492
493 /**
494 * This method initializes jTable
495 *
496 * @return javax.swing.JTable
497 */
498 private JTable getJTable() {
499 if (jTable == null) {
500 model = new PartialEditableTableModel();
501 jTable = new JTable(model);
502 model.addColumn("CName");
503 model.addColumn("TokenSpaceGUID");
504 model.addColumn("ItemType");
505 model.addColumn("Token");
506 model.addColumn("DataType");
507 model.addColumn("DefaultValue");
508
509 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
510 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
511 public void valueChanged(ListSelectionEvent e) {
512
513 if (e.getValueIsAdjusting()){
514 return;
515 }
516 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
517 if (lsm.isSelectionEmpty()) {
518 return;
519 }
520 else{
521 // int selectedRow = lsm.getMinSelectionIndex();
522
523
524 }
525 }
526 });
527
528 jTable.getModel().addTableModelListener(new TableModelListener() {
529 public void tableChanged(TableModelEvent arg0) {
530 // TODO Auto-generated method stub
531 int row = arg0.getFirstRow();
532 TableModel m = (TableModel)arg0.getSource();
533 if (arg0.getType() == TableModelEvent.INSERT) {
534 //
535 // Set combo box values for item type according to pcd values added.
536 //
537
538 }
539 if (arg0.getType() == TableModelEvent.UPDATE){
540 //ToDo Data Validition check.
541
542 }
543 }
544 });
545 }
546 return jTable;
547 }
548
549 /**
550 * This method initializes jPanel2
551 *
552 * @return javax.swing.JPanel
553 */
554 private JPanel getJPanel2() {
555 if (jPanel2 == null) {
556 jLabel5 = new JLabel();
557 jLabel5.setText("PCD Description");
558 jPanel2 = new JPanel();
559 jPanel2.add(jLabel5, null);
560 jPanel2.add(getJScrollPane1(), null);
561 }
562 return jPanel2;
563 }
564
565 /**
566 * This method initializes jScrollPane1
567 *
568 * @return javax.swing.JScrollPane
569 */
570 private JScrollPane getJScrollPane1() {
571 if (jScrollPane1 == null) {
572 jScrollPane1 = new JScrollPane();
573 jScrollPane1.setPreferredSize(new java.awt.Dimension(500,100));
574 jScrollPane1.setViewportView(getJTextArea());
575 }
576 return jScrollPane1;
577 }
578
579 /**
580 * This method initializes jTextArea
581 *
582 * @return javax.swing.JTextArea
583 */
584 private JTextArea getJTextArea() {
585 if (jTextArea == null) {
586 jTextArea = new JTextArea();
587 jTextArea.setEditable(false);
588 }
589 return jTextArea;
590 }
591
592 /**
593 * This method initializes jPanel3
594 *
595 * @return javax.swing.JPanel
596 */
597 private JPanel getJPanel3() {
598 if (jPanel3 == null) {
599 FlowLayout flowLayout = new FlowLayout();
600 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
601 jPanel3 = new JPanel();
602 jPanel3.setLayout(flowLayout);
603 jPanel3.add(getJButton2(), null);
604 jPanel3.add(getJButton3(), null);
605 }
606 return jPanel3;
607 }
608
609 /**
610 * This method initializes jSplitPane
611 *
612 * @return javax.swing.JSplitPane
613 */
614 private JSplitPane getJSplitPane() {
615 if (jSplitPane == null) {
616 jSplitPane = new JSplitPane();
617 jSplitPane.setDividerLocation(200);
618 jSplitPane.setLeftComponent(getJPanel4());
619 jSplitPane.setRightComponent(getJPanel5());
620 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
621 }
622 return jSplitPane;
623 }
624
625 /**
626 * This method initializes jPanel4
627 *
628 * @return javax.swing.JPanel
629 */
630 private JPanel getJPanel4() {
631 if (jPanel4 == null) {
632 jLabel1 = new JLabel();
633 jLabel1.setText("Library Classes Consumed");
634 jPanel4 = new JPanel();
635 jPanel4.add(jLabel1, null);
636 jPanel4.add(getJScrollPane3(), null);
637 }
638 return jPanel4;
639 }
640
641 /**
642 * This method initializes jPanel5
643 *
644 * @return javax.swing.JPanel
645 */
646 private JPanel getJPanel5() {
647 if (jPanel5 == null) {
648 jLabel2 = new JLabel();
649 jLabel2.setText("Instances Available");
650 jPanel5 = new JPanel();
651 jPanel5.add(jLabel2, null);
652 jPanel5.add(getJScrollPane4(), null);
653 }
654 return jPanel5;
655 }
656
657 /**
658 * This method initializes jScrollPane2
659 *
660 * @return javax.swing.JScrollPane
661 */
662 private JScrollPane getJScrollPane2() {
663 if (jScrollPane2 == null) {
664 jScrollPane2 = new JScrollPane();
665 jScrollPane2.setPreferredSize(new java.awt.Dimension(453,150));
666 jScrollPane2.setViewportView(getJTable1());
667 }
668 return jScrollPane2;
669 }
670
671 /**
672 * This method initializes jTable1
673 *
674 * @return javax.swing.JTable
675 */
676 private JTable getJTable1() {
677 if (jTable1 == null) {
678 model1 = new LibraryTableModel();
679 model1.addColumn("Name");
680 model1.addColumn("ModuleGUID");
681 model1.addColumn("ModuleVersion");
682 model1.addColumn("PackageGUID");
683 model1.addColumn("PackageVersion");
684 jTable1 = new JTable(model1);
685
686 jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
687 jTable1.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
688 public void valueChanged(ListSelectionEvent e) {
689 int selectedRow1 = -1;
690 if (e.getValueIsAdjusting()){
691 return;
692 }
693 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
694 if (lsm.isSelectionEmpty()) {
695 return;
696 }
697 else{
698 selectedRow1 = lsm.getMinSelectionIndex();
699
700
701 }
702 }
703 });
704
705
706 }
707 return jTable1;
708 }
709
710 /**
711 * This method initializes jScrollPane3
712 *
713 * @return javax.swing.JScrollPane
714 */
715 private JScrollPane getJScrollPane3() {
716 if (jScrollPane3 == null) {
717 jScrollPane3 = new JScrollPane();
718 jScrollPane3.setPreferredSize(new java.awt.Dimension(200,170));
719 jScrollPane3.setViewportView(getJTable2());
720 }
721 return jScrollPane3;
722 }
723
724 /**
725 * This method initializes jTable2
726 *
727 * @return javax.swing.JTable
728 */
729 private JTable getJTable2() {
730 if (jTable2 == null) {
731 model2 = new LibraryTableModel();
732 model2.addColumn("LibraryClass");
733 jTable2 = new JTable(model2);
734
735 jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
736 jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
737 public void valueChanged(ListSelectionEvent e) {
738 if (e.getValueIsAdjusting()){
739 return;
740 }
741 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
742 if (lsm.isSelectionEmpty()) {
743 return;
744 }
745 else{
746 int selectedRow2 = lsm.getMinSelectionIndex();
747 if (selectedRow2 < 0) {
748 return;
749 }
750 //
751 // display potential lib instances according to class selection
752 //
753 model3.setRowCount(0);
754 String cls = model2.getValueAt(selectedRow2, 0).toString();
755 ArrayList<String> al = classInstanceMap.get(cls);
756 ListIterator<String> li = al.listIterator();
757 while(li.hasNext()) {
758 String instance = li.next();
759 String[] s = {"", "", "", "", ""};
760 if (getModuleId(instance) != null) {
761 s[0] = getModuleId(instance).getName();
762 }
763
764 String[] instancePart = instance.split(" ");
765 for (int i = 0; i < instancePart.length; ++i){
766 s[i+1] = instancePart[i];
767 }
768 model3.addRow(s);
769 }
770
771 }
772 }
773 });
774 }
775 return jTable2;
776 }
777
778 /**
779 * This method initializes jScrollPane4
780 *
781 * @return javax.swing.JScrollPane
782 */
783 private JScrollPane getJScrollPane4() {
784 if (jScrollPane4 == null) {
785 jScrollPane4 = new JScrollPane();
786 jScrollPane4.setPreferredSize(new java.awt.Dimension(450,170));
787 jScrollPane4.setViewportView(getJTable3());
788 }
789 return jScrollPane4;
790 }
791
792 /**
793 * This method initializes jTable3
794 *
795 * @return javax.swing.JTable
796 */
797 private JTable getJTable3() {
798 if (jTable3 == null) {
799 model3 = new LibraryTableModel();
800 model3.addColumn("Name");
801 model3.addColumn("ModuleGUID");
802 model3.addColumn("ModuleVersion");
803 model3.addColumn("PackageGUID");
804 model3.addColumn("PackageVersion");
805 jTable3 = new JTable(model3);
806
807 jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
808 jTable3.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
809 public void valueChanged(ListSelectionEvent e) {
810 int selectedRow3 = -1;
811 if (e.getValueIsAdjusting()){
812 return;
813 }
814 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
815 if (lsm.isSelectionEmpty()) {
816 return;
817 }
818 else{
819 selectedRow3 = lsm.getMinSelectionIndex();
820
821
822 }
823 }
824 });
825 }
826 return jTable3;
827 }
828
829 /**
830 * This method initializes jPanel6
831 *
832 * @return javax.swing.JPanel
833 */
834 private JPanel getJPanel6() {
835 if (jPanel6 == null) {
836 jPanel6 = new JPanel();
837 }
838 return jPanel6;
839 }
840
841 /**
842 * This method initializes jPanel7
843 *
844 * @return javax.swing.JPanel
845 */
846 private JPanel getJPanel7() {
847 if (jPanel7 == null) {
848 jLabel4 = new JLabel();
849 jLabel4.setText("Instance Description");
850 jLabel3 = new JLabel();
851 jLabel3.setText("Selected Instances");
852 jPanel7 = new JPanel();
853 jPanel7.add(jLabel4, null);
854 jPanel7.add(getJScrollPane5(), null);
855 jPanel7.add(getJButton(), null);
856 jPanel7.add(getJButton1(), null);
857 jPanel7.add(jLabel3, null);
858 jPanel7.add(getJScrollPane2(), null);
859 }
860 return jPanel7;
861 }
862
863 /**
864 * This method initializes jScrollPane5
865 *
866 * @return javax.swing.JScrollPane
867 */
868 private JScrollPane getJScrollPane5() {
869 if (jScrollPane5 == null) {
870 jScrollPane5 = new JScrollPane();
871 jScrollPane5.setPreferredSize(new java.awt.Dimension(300,50));
872 jScrollPane5.setViewportView(getJTextArea1());
873 }
874 return jScrollPane5;
875 }
876
877 /**
878 * This method initializes jTextArea1
879 *
880 * @return javax.swing.JTextArea
881 */
882 private JTextArea getJTextArea1() {
883 if (jTextArea1 == null) {
884 jTextArea1 = new JTextArea();
885 jTextArea1.setEditable(false);
886 }
887 return jTextArea1;
888 }
889
890 /**
891 * This method initializes jButton
892 *
893 * @return javax.swing.JButton
894 */
895 private JButton getJButton() {
896 if (jButton == null) {
897 jButton = new JButton();
898 jButton.setPreferredSize(new java.awt.Dimension(80,20));
899 jButton.setText("Add");
900 jButton.addActionListener(new java.awt.event.ActionListener() {
901 public void actionPerformed(java.awt.event.ActionEvent e) {
902 int row = jTable3.getSelectedRow();
903 if (row < 0) {
904 return;
905 }
906 Object[] s = {model3.getValueAt(row, 0), model3.getValueAt(row, 1),
907 model3.getValueAt(row, 2), model3.getValueAt(row, 3),
908 model3.getValueAt(row, 4)};
909 model1.addRow(s);
910 String instanceValue = model3.getValueAt(row, 1) + " " +
911 model3.getValueAt(row, 2) + " " +
912 model3.getValueAt(row, 3) + " " +
913 model3.getValueAt(row, 4);
914 //
915 // Add pcd information of selected instance to current moduleSA
916 //
917 ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), ffc.getModuleSA(moduleKey));
918
919 resolveLibraryInstances(instanceValue);
920 }
921 });
922 }
923 return jButton;
924 }
925
926 /**
927 * This method initializes jButton1
928 *
929 * @return javax.swing.JButton
930 */
931 private JButton getJButton1() {
932 if (jButton1 == null) {
933 jButton1 = new JButton();
934 jButton1.setPreferredSize(new java.awt.Dimension(80,20));
935 jButton1.setText("Delete");
936 jButton1.addActionListener(new java.awt.event.ActionListener() {
937 public void actionPerformed(java.awt.event.ActionEvent e) {
938 int row = jTable1.getSelectedRow();
939 if (row < 0) {
940 return;
941 }
942 removeInstance(model1.getValueAt(row, 1) + " " +
943 model1.getValueAt(row, 2) + " " +
944 model1.getValueAt(row, 3) + " " +
945 model1.getValueAt(row, 4));
946 model1.removeRow(row);
947
948 }
949 });
950 }
951 return jButton1;
952 }
953
954 /**
955 * This method initializes jButton2
956 *
957 * @return javax.swing.JButton
958 */
959 private JButton getJButton2() {
960 if (jButton2 == null) {
961 jButton2 = new JButton();
962 jButton2.setPreferredSize(new java.awt.Dimension(80,20));
963 jButton2.setText("Ok");
964 jButton2.addActionListener(this);
965 }
966 return jButton2;
967 }
968
969 /**
970 * This method initializes jButton3
971 *
972 * @return javax.swing.JButton
973 */
974 private JButton getJButton3() {
975 if (jButton3 == null) {
976 jButton3 = new JButton();
977 jButton3.setPreferredSize(new java.awt.Dimension(80,20));
978 jButton3.setText("Cancel");
979 jButton3.setVisible(false);
980 }
981 return jButton3;
982 }
983 public void actionPerformed(ActionEvent arg0) {
984
985 if (arg0.getSource() == jButton2) {
986 ffc.removeLibraryInstances(moduleKey);
987 for (int i = 0; i < model1.getRowCount(); ++i) {
988 String mg = model1.getValueAt(i, 1)+"";
989 String mv = model1.getValueAt(i, 2)+"";
990 String pg = model1.getValueAt(i, 3)+"";
991 String pv = model1.getValueAt(i, 4)+"";
992 ffc.genLibraryInstance(mg, mv, pg, pv, moduleKey);
993 }
994 this.setVisible(false);
995 }
996 }
997 /**
998 * This method initializes jPanel8
999 *
1000 * @return javax.swing.JPanel
1001 */
1002 private JPanel getJPanel8() {
1003 if (jPanel8 == null) {
1004 jLabel8 = new JLabel();
1005 jLabel8.setText("FFS Format Key");
1006 jLabel7 = new JLabel();
1007 jLabel7.setText("FFS File GUID");
1008 jLabel6 = new JLabel();
1009 jLabel6.setText("FV Binding");
1010 jPanel8 = new JPanel();
1011 jPanel8.add(jLabel6, null);
1012 jPanel8.add(getJTextField(), null);
1013 jPanel8.add(jLabel7, null);
1014 jPanel8.add(getJTextField1(), null);
1015 jPanel8.add(jLabel8, null);
1016 jPanel8.add(getJTextField2(), null);
1017 jPanel8.add(getJScrollPane6(), null);
1018 jPanel8.add(getJButton4(), null);
1019 jPanel8.add(getJButton5(), null);
1020 }
1021 return jPanel8;
1022 }
1023 /**
1024 * This method initializes jTextField
1025 *
1026 * @return javax.swing.JTextField
1027 */
1028 private JTextField getJTextField() {
1029 if (jTextField == null) {
1030 jTextField = new JTextField();
1031 jTextField.setPreferredSize(new java.awt.Dimension(100,20));
1032 jTextField.addFocusListener(new java.awt.event.FocusAdapter() {
1033 public void focusLost(java.awt.event.FocusEvent e) {
1034 ffc.setFvBinding(moduleKey, jTextField.getText());
1035 }
1036 });
1037 }
1038 return jTextField;
1039 }
1040 /**
1041 * This method initializes jTextField1
1042 *
1043 * @return javax.swing.JTextField
1044 */
1045 private JTextField getJTextField1() {
1046 if (jTextField1 == null) {
1047 jTextField1 = new JTextField();
1048 jTextField1.setPreferredSize(new java.awt.Dimension(100,20));
1049 jTextField1.addFocusListener(new java.awt.event.FocusAdapter() {
1050 public void focusLost(java.awt.event.FocusEvent e) {
1051 ffc.setFfsFileNameGuid(moduleKey, jTextField1.getText());
1052 }
1053 });
1054 }
1055 return jTextField1;
1056 }
1057 /**
1058 * This method initializes jTextField2
1059 *
1060 * @return javax.swing.JTextField
1061 */
1062 private JTextField getJTextField2() {
1063 if (jTextField2 == null) {
1064 jTextField2 = new JTextField();
1065 jTextField2.setPreferredSize(new java.awt.Dimension(100,20));
1066 jTextField2.addFocusListener(new java.awt.event.FocusAdapter() {
1067 public void focusLost(java.awt.event.FocusEvent e) {
1068 ffc.setFfsFormatKey(moduleKey, jTextField2.getText());
1069 }
1070 });
1071 }
1072 return jTextField2;
1073 }
1074 /**
1075 * This method initializes jScrollPane6
1076 *
1077 * @return javax.swing.JScrollPane
1078 */
1079 private JScrollPane getJScrollPane6() {
1080 if (jScrollPane6 == null) {
1081 jScrollPane6 = new JScrollPane();
1082 jScrollPane6.setPreferredSize(new java.awt.Dimension(600,200));
1083 jScrollPane6.setViewportView(getJTable4());
1084 }
1085 return jScrollPane6;
1086 }
1087 /**
1088 * This method initializes jTable4
1089 *
1090 * @return javax.swing.JTable
1091 */
1092 private JTable getJTable4() {
1093 if (jTable4 == null) {
1094 optionsTableModel = new DefaultTableModel();
1095 optionsTableModel.addColumn("BuildTargets");
1096 optionsTableModel.addColumn("ToolChainFamily");
1097 optionsTableModel.addColumn("TagName");
1098 optionsTableModel.addColumn("ToolCode");
1099 optionsTableModel.addColumn("SupportedArchs");
1100 optionsTableModel.addColumn("Contents");
1101 jTable4 = new JTable(optionsTableModel);
1102 jTable4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1103 jTable4.getModel().addTableModelListener(new TableModelListener() {
1104 public void tableChanged(TableModelEvent arg0) {
1105 // TODO Auto-generated method stub
1106 int row = arg0.getFirstRow();
1107 TableModel m = (TableModel)arg0.getSource();
1108
1109 if (arg0.getType() == TableModelEvent.UPDATE){
1110 //ToDo Data Validition check.
1111 String targets = m.getValueAt(row, 0) + "";
1112 Vector<Object> targetName = new Vector<Object>();
1113 String[] sArray = targets.split(" ");
1114 for (int i = 0; i < sArray.length; ++i) {
1115 targetName.add(sArray[i]);
1116 }
1117 String toolChain = m.getValueAt(row, 1) + "";
1118 String tagName = m.getValueAt(row, 2) + "";
1119 String toolCode = m.getValueAt(row, 3) + "";
1120 String archs = m.getValueAt(row, 4) + "";
1121 Vector<Object> supArch = new Vector<Object>();
1122 String[] sArray1 = archs.split(" ");
1123 for (int i = 0; i < sArray1.length; ++i) {
1124 supArch.add(sArray1[i]);
1125 }
1126 if (supArch.size() == 0) {
1127 supArch.add("IA32");
1128 }
1129 String contents = m.getValueAt(row, 5) + "";
1130
1131 ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);
1132 }
1133 }
1134 });
1135 }
1136 return jTable4;
1137 }
1138 /**
1139 * This method initializes jButton4
1140 *
1141 * @return javax.swing.JButton
1142 */
1143 private JButton getJButton4() {
1144 if (jButton4 == null) {
1145 jButton4 = new JButton();
1146 jButton4.setPreferredSize(new java.awt.Dimension(80,20));
1147 jButton4.setText("New");
1148 jButton4.addActionListener(new java.awt.event.ActionListener() {
1149 public void actionPerformed(java.awt.event.ActionEvent e) {
1150 String[] row = {"", "", "", "", "IA32", ""};
1151 optionsTableModel.addRow(row);
1152 Vector<Object> v = new Vector<Object>();
1153 Vector<Object> v1 = new Vector<Object>();
1154 v1.add("IA32");
1155 ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");
1156 }
1157 });
1158 }
1159 return jButton4;
1160 }
1161 /**
1162 * This method initializes jButton5
1163 *
1164 * @return javax.swing.JButton
1165 */
1166 private JButton getJButton5() {
1167 if (jButton5 == null) {
1168 jButton5 = new JButton();
1169 jButton5.setPreferredSize(new java.awt.Dimension(80,20));
1170 jButton5.setText("Delete");
1171 jButton5.addActionListener(new java.awt.event.ActionListener() {
1172 public void actionPerformed(java.awt.event.ActionEvent e) {
1173 if (jTable4.getSelectedRow() < 0) {
1174 return;
1175 }
1176
1177 ffc.removeModuleSAOptionsOpt(moduleKey, jTable4.getSelectedRow());
1178 optionsTableModel.removeRow(jTable4.getSelectedRow());
1179 }
1180 });
1181 }
1182 return jButton5;
1183 }
1184
1185 } // @jve:decl-index=0:visual-constraint="10,10"
1186
1187 class PartialEditableTableModel extends DefaultTableModel {
1188 /**
1189 *
1190 */
1191 private static final long serialVersionUID = 1L;
1192
1193 public boolean isCellEditable(int row, int col) {
1194 switch (col){
1195 case 2:
1196 return true;
1197 default:
1198 return false;
1199 }
1200
1201 }
1202 }
1203
1204 class LibraryTableModel extends DefaultTableModel {
1205 /**
1206 *
1207 */
1208 private static final long serialVersionUID = 1L;
1209
1210 public boolean isCellEditable(int row, int col) {
1211 return false;
1212 }
1213 }