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