1 package org
.tianocore
.frameworkwizard
.platform
.ui
;
3 import java
.awt
.BorderLayout
;
4 import java
.awt
.Dimension
;
5 import java
.awt
.Toolkit
;
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
;
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
;
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
;
41 import java
.util
.Vector
;
43 import javax
.swing
.JTextField
;
45 public class FpdModuleSA
extends JDialog
implements ActionListener
{
50 private static final long serialVersionUID
= 1L;
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;
107 * This is the default constructor
109 public FpdModuleSA() {
113 public FpdModuleSA(FpdFileContents ffc
) {
118 public void setKey(String k
){
123 init will be called each time FpdModuleSA object is to be shown.
124 @param key Module information.
126 public void init(String key
) {
128 // display pcd for key.
130 model
.setRowCount(0);
131 int pcdCount
= ffc
.getPcdDataCount(key
);
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
]);
140 // display library classes that need to be resolved. also potential instances for them.
142 resolveLibraryInstances(key
);
144 // display lib instances already selected for key
146 model1
.setRowCount(0);
147 int instanceCount
= ffc
.getLibraryInstancesCount(key
);
148 if (instanceCount
!= 0) {
149 String
[][] saa
= new String
[instanceCount
][5];
150 ffc
.getLibraryInstances(key
, saa
);
151 for (int i
= 0; i
< saa
.length
; ++i
) {
152 ModuleIdentification mi
= getModuleId(saa
[i
][1] + " " + saa
[i
][2] + " " + saa
[i
][3] + " " + saa
[i
][4]);
154 saa
[i
][0] = mi
.getName();
155 saa
[i
][2] = mi
.getVersion();
156 saa
[i
][4] = mi
.getPackage().getVersion();
158 // re-evaluate lib instance usage when adding a already-selected lib instance.
160 resolveLibraryInstances(saa
[i
][1] + " " + saa
[i
][2] + " " + saa
[i
][3] + " " + saa
[i
][4]);
161 model1
.addRow(saa
[i
]);
169 // display module SA options
171 String fvBinding
= ffc
.getFvBinding(key
);
172 if (fvBinding
!= null) {
173 jTextField
.setText(fvBinding
);
175 String fileGuid
= ffc
.getFfsFileNameGuid(key
);
176 if (fileGuid
!= null) {
177 jTextField1
.setText(fileGuid
);
179 String ffsKey
= ffc
.getFfsFormatKey(key
);
180 if (ffsKey
!= null) {
181 jTextField2
.setText(ffsKey
);
185 private void resolveLibraryInstances(String key
) {
186 ModuleIdentification mi
= getModuleId(key
);
187 PackageIdentification
[] depPkgList
= null;
189 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
190 SurfaceAreaQuery
.setDoc(m
);
192 // Get dependency pkg list into which we will search lib instances.
194 depPkgList
= SurfaceAreaQuery
.getDependencePkg(null);
196 // Get the lib class consumed, produced by this module itself.
198 String
[] classConsumed
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_CONSUMED");
200 if (this.classConsumed
== null) {
201 this.classConsumed
= new HashMap
<String
, ArrayList
<String
>>();
204 for(int i
= 0; i
< classConsumed
.length
; ++i
){
205 ArrayList
<String
> consumedBy
= this.classConsumed
.get(classConsumed
[i
]);
206 if (consumedBy
== null) {
207 consumedBy
= new ArrayList
<String
>();
210 this.classConsumed
.put(classConsumed
[i
], consumedBy
);
213 String
[] classProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
214 if (this.classProduced
== null) {
215 this.classProduced
= new ArrayList
<String
>();
217 for(int i
= 0; i
< classProduced
.length
; ++i
){
218 if (!this.classProduced
.contains(classProduced
[i
])){
219 this.classProduced
.add(classProduced
[i
]);
223 // Get classes unresolved
225 // Iterator<String> lip = this.classProduced.listIterator();
226 // while(lip.hasNext()){
227 // String clsProduced = lip.next();
228 // this.classConsumed.remove(clsProduced);
232 // find potential instances in all dependency pkgs for classes still in classConsumed.
234 if (classInstanceMap
== null){
235 classInstanceMap
= new HashMap
<String
, ArrayList
<String
>>();
237 Iterator
<String
> lic
= this.classConsumed
.keySet().iterator();
238 while(lic
.hasNext()){
239 String cls
= lic
.next();
240 if (this.classProduced
.contains(cls
) || classInstanceMap
.containsKey(cls
)) {
243 ArrayList
<String
> instances
= getInstancesForClass(cls
, depPkgList
);
244 if (instances
.size() == 0){
245 JOptionPane
.showMessageDialog(frame
, "No Applicable Instance for Library Class " +
246 cls
+ ", Platform Build will Fail.");
248 classInstanceMap
.put(cls
, instances
);
252 showClassToResolved();
259 private ArrayList
<String
> getInstancesForClass(String cls
, PackageIdentification
[] depPkgList
) throws Exception
{
260 ArrayList
<String
> al
= new ArrayList
<String
>();
262 for (int i
= 0; i
< depPkgList
.length
; ++i
) {
263 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(depPkgList
[i
]);
264 Iterator ismi
= smi
.iterator();
265 while(ismi
.hasNext()) {
266 ModuleIdentification mi
= (ModuleIdentification
)ismi
.next();
268 String
[] clsProduced
= getClassProduced(mi
);
270 boolean isPotential
= false;
271 for (int j
= 0; j
< clsProduced
.length
; ++j
) {
272 if (clsProduced
[j
] == null) {
275 if (clsProduced
[j
].equals(cls
)){
278 if (classProduced
.contains(clsProduced
[j
])) {
284 al
.add(mi
.getGuid() + " " + mi
.getVersion() + " " +
285 depPkgList
[i
].getGuid() + " " + depPkgList
[i
].getVersion());
293 private void removeInstance(String key
) {
294 ModuleIdentification mi
= getModuleId(key
);
296 // remove pcd information of instance from current ModuleSA
298 ffc
.removePcdDataFromLibraryInstance(moduleKey
, key
);
300 // remove class produced by this instance and add back these produced class to be bound.
302 String
[] clsProduced
= getClassProduced(mi
);
303 for (int i
= 0; i
< clsProduced
.length
; ++i
) {
305 classProduced
.remove(clsProduced
[i
]);
308 // remove class consumed by this instance. we do not need to bound it now.
310 String
[] clsConsumed
= getClassConsumed(mi
);
311 for (int i
= 0; i
< clsConsumed
.length
; ++i
) {
312 ArrayList
<String
> al
= classConsumed
.get(clsConsumed
[i
]);
315 classConsumed
.remove(clsConsumed
[i
]);
319 if (al
.size() == 0) {
320 classConsumed
.remove(clsConsumed
[i
]);
325 showClassToResolved();
329 private ModuleIdentification
getModuleId(String key
){
331 // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion into string array.
333 String
[] keyPart
= key
.split(" ");
334 Set
<PackageIdentification
> spi
= GlobalData
.getPackageList();
335 Iterator ispi
= spi
.iterator();
337 while(ispi
.hasNext()) {
338 PackageIdentification pi
= (PackageIdentification
)ispi
.next();
339 if ( !pi
.getGuid().equals(keyPart
[2])){
340 // || !pi.getVersion().equals(keyPart[3])){
343 Set
<ModuleIdentification
> smi
= GlobalData
.getModules(pi
);
344 Iterator ismi
= smi
.iterator();
345 while(ismi
.hasNext()) {
346 ModuleIdentification mi
= (ModuleIdentification
)ismi
.next();
347 if (mi
.getGuid().equals(keyPart
[0])){
348 // && mi.getVersion().equals(keyPart[1])){
356 private String
[] getClassProduced(ModuleIdentification mi
){
359 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
360 SurfaceAreaQuery
.setDoc(m
);
361 String
[] clsProduced
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_PRODUCED");
364 }catch (Exception e
) {
367 return new String
[0];
371 private String
[] getClassConsumed(ModuleIdentification mi
){
373 String
[] clsConsumed
= null;
375 Map
<String
, XmlObject
> m
= GlobalData
.getNativeMsa(mi
);
376 SurfaceAreaQuery
.setDoc(m
);
377 clsConsumed
= SurfaceAreaQuery
.getLibraryClasses("ALWAYS_CONSUMED");
379 }catch (Exception e
) {
385 private void showClassToResolved(){
386 model2
.setRowCount(0);
387 if (classConsumed
.size() == 0) {
390 Iterator
<String
> li
= classConsumed
.keySet().iterator();
393 String
[] s
= {li
.next()};
394 if (classConsumed
.get(s
[0]) == null) {
397 if (classConsumed
.get(s
[0]).size() == 0) {
400 if (!classProduced
.contains(s
[0])){
404 model3
.setRowCount(0);
407 * This method initializes this
411 private void initialize() {
412 this.setSize(664, 515);
415 this.setTitle("Module Settings");
416 this.setContentPane(getJContentPane());
420 * This method initializes jContentPane
422 * @return javax.swing.JPanel
424 private JPanel
getJContentPane() {
425 if (jContentPane
== null) {
426 jContentPane
= new JPanel();
427 jContentPane
.setLayout(new BorderLayout());
428 jContentPane
.add(getJTabbedPane(), java
.awt
.BorderLayout
.CENTER
);
429 jContentPane
.add(getJPanel3(), java
.awt
.BorderLayout
.SOUTH
);
435 * This method initializes jTabbedPane
437 * @return javax.swing.JTabbedPane
439 private JTabbedPane
getJTabbedPane() {
440 if (jTabbedPane
== null) {
441 jTabbedPane
= new JTabbedPane();
442 jTabbedPane
.addTab("PCD Build Definition", null, getJPanel(), null);
443 jTabbedPane
.addTab("Module SA Options", null, getJPanel8(), null);
444 jTabbedPane
.addTab("Libraries", null, getJPanel1(), null);
450 * This method initializes jPanel
452 * @return javax.swing.JPanel
454 private JPanel
getJPanel() {
455 if (jPanel
== null) {
456 jLabel
= new JLabel();
457 jLabel
.setText("PcdData");
458 jPanel
= new JPanel();
459 jPanel
.setLayout(new BorderLayout());
460 jPanel
.add(jLabel
, java
.awt
.BorderLayout
.NORTH
);
461 jPanel
.add(getJScrollPane(), java
.awt
.BorderLayout
.CENTER
);
462 jPanel
.add(getJPanel2(), java
.awt
.BorderLayout
.SOUTH
);
463 jPanel
.addComponentListener(new java
.awt
.event
.ComponentAdapter() {
464 public void componentShown(java
.awt
.event
.ComponentEvent e
) {
474 * This method initializes jPanel1
476 * @return javax.swing.JPanel
478 private JPanel
getJPanel1() {
479 if (jPanel1
== null) {
480 jPanel1
= new JPanel();
481 jPanel1
.setLayout(new BorderLayout());
482 jPanel1
.add(getJSplitPane(), java
.awt
.BorderLayout
.NORTH
);
483 jPanel1
.add(getJPanel6(), java
.awt
.BorderLayout
.SOUTH
);
484 jPanel1
.add(getJPanel7(), java
.awt
.BorderLayout
.CENTER
);
485 jPanel1
.addComponentListener(new java
.awt
.event
.ComponentAdapter() {
486 public void componentShown(java
.awt
.event
.ComponentEvent e
) {
495 * This method initializes jScrollPane
497 * @return javax.swing.JScrollPane
499 private JScrollPane
getJScrollPane() {
500 if (jScrollPane
== null) {
501 jScrollPane
= new JScrollPane();
502 jScrollPane
.setViewportView(getJTable());
508 * This method initializes jTable
510 * @return javax.swing.JTable
512 private JTable
getJTable() {
513 if (jTable
== null) {
514 model
= new PartialEditableTableModel();
515 jTable
= new JTable(model
);
516 jTable
.setRowHeight(20);
517 jTable
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
518 model
.addColumn("CName");
519 model
.addColumn("TokenSpaceGUID");
520 model
.addColumn("ItemType");
521 model
.addColumn("Token");
522 model
.addColumn("DataType");
523 model
.addColumn("DefaultValue");
525 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
526 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
527 public void valueChanged(ListSelectionEvent e
) {
529 if (e
.getValueIsAdjusting()){
532 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
533 if (lsm
.isSelectionEmpty()) {
537 // int selectedRow = lsm.getMinSelectionIndex();
544 jTable
.getModel().addTableModelListener(new TableModelListener() {
545 public void tableChanged(TableModelEvent arg0
) {
546 // TODO Auto-generated method stub
547 int row
= arg0
.getFirstRow();
548 TableModel m
= (TableModel
)arg0
.getSource();
549 if (arg0
.getType() == TableModelEvent
.INSERT
) {
551 // Set combo box values for item type according to pcd values added.
555 if (arg0
.getType() == TableModelEvent
.UPDATE
){
556 //ToDo Data Validition check.
566 * This method initializes jPanel2
568 * @return javax.swing.JPanel
570 private JPanel
getJPanel2() {
571 if (jPanel2
== null) {
572 jLabel5
= new JLabel();
573 jLabel5
.setText("PCD Description");
574 jPanel2
= new JPanel();
575 jPanel2
.add(jLabel5
, null);
576 jPanel2
.add(getJScrollPane1(), null);
582 * This method initializes jScrollPane1
584 * @return javax.swing.JScrollPane
586 private JScrollPane
getJScrollPane1() {
587 if (jScrollPane1
== null) {
588 jScrollPane1
= new JScrollPane();
589 jScrollPane1
.setPreferredSize(new java
.awt
.Dimension(500,100));
590 jScrollPane1
.setViewportView(getJTextArea());
596 * This method initializes jTextArea
598 * @return javax.swing.JTextArea
600 private JTextArea
getJTextArea() {
601 if (jTextArea
== null) {
602 jTextArea
= new JTextArea();
603 jTextArea
.setEditable(false);
609 * This method initializes jPanel3
611 * @return javax.swing.JPanel
613 private JPanel
getJPanel3() {
614 if (jPanel3
== null) {
615 FlowLayout flowLayout
= new FlowLayout();
616 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
617 jPanel3
= new JPanel();
618 jPanel3
.setLayout(flowLayout
);
619 jPanel3
.add(getJButton2(), null);
620 jPanel3
.add(getJButton3(), null);
626 * This method initializes jSplitPane
628 * @return javax.swing.JSplitPane
630 private JSplitPane
getJSplitPane() {
631 if (jSplitPane
== null) {
632 jSplitPane
= new JSplitPane();
633 jSplitPane
.setDividerLocation(200);
634 jSplitPane
.setLeftComponent(getJPanel4());
635 jSplitPane
.setRightComponent(getJPanel5());
636 jSplitPane
.setPreferredSize(new java
.awt
.Dimension(202,200));
642 * This method initializes jPanel4
644 * @return javax.swing.JPanel
646 private JPanel
getJPanel4() {
647 if (jPanel4
== null) {
648 jLabel1
= new JLabel();
649 jLabel1
.setText("Library Classes Consumed");
650 jPanel4
= new JPanel();
651 jPanel4
.add(jLabel1
, null);
652 jPanel4
.add(getJScrollPane3(), null);
658 * This method initializes jPanel5
660 * @return javax.swing.JPanel
662 private JPanel
getJPanel5() {
663 if (jPanel5
== null) {
664 jLabel2
= new JLabel();
665 jLabel2
.setText("Instances Available");
666 jPanel5
= new JPanel();
667 jPanel5
.add(jLabel2
, null);
668 jPanel5
.add(getJScrollPane4(), null);
674 * This method initializes jScrollPane2
676 * @return javax.swing.JScrollPane
678 private JScrollPane
getJScrollPane2() {
679 if (jScrollPane2
== null) {
680 jScrollPane2
= new JScrollPane();
681 jScrollPane2
.setPreferredSize(new java
.awt
.Dimension(453,150));
682 jScrollPane2
.setViewportView(getJTable1());
688 * This method initializes jTable1
690 * @return javax.swing.JTable
692 private JTable
getJTable1() {
693 if (jTable1
== null) {
694 model1
= new LibraryTableModel();
695 model1
.addColumn("Name");
696 model1
.addColumn("ModuleGUID");
697 model1
.addColumn("ModuleVersion");
698 model1
.addColumn("PackageGUID");
699 model1
.addColumn("PackageVersion");
700 jTable1
= new JTable(model1
);
701 jTable1
.setRowHeight(20);
702 jTable1
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
703 jTable1
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
704 jTable1
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
705 public void valueChanged(ListSelectionEvent e
) {
706 int selectedRow1
= -1;
707 if (e
.getValueIsAdjusting()){
710 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
711 if (lsm
.isSelectionEmpty()) {
715 selectedRow1
= lsm
.getMinSelectionIndex();
728 * This method initializes jScrollPane3
730 * @return javax.swing.JScrollPane
732 private JScrollPane
getJScrollPane3() {
733 if (jScrollPane3
== null) {
734 jScrollPane3
= new JScrollPane();
735 jScrollPane3
.setPreferredSize(new java
.awt
.Dimension(200,170));
736 jScrollPane3
.setViewportView(getJTable2());
742 * This method initializes jTable2
744 * @return javax.swing.JTable
746 private JTable
getJTable2() {
747 if (jTable2
== null) {
748 model2
= new LibraryTableModel();
749 model2
.addColumn("LibraryClass");
750 jTable2
= new JTable(model2
);
751 jTable2
.setRowHeight(20);
752 jTable2
.setShowGrid(false);
753 jTable2
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
754 jTable2
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
755 public void valueChanged(ListSelectionEvent e
) {
756 if (e
.getValueIsAdjusting()){
759 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
760 if (lsm
.isSelectionEmpty()) {
764 int selectedRow2
= lsm
.getMinSelectionIndex();
765 if (selectedRow2
< 0) {
769 // display potential lib instances according to class selection
771 model3
.setRowCount(0);
772 String cls
= model2
.getValueAt(selectedRow2
, 0).toString();
773 ArrayList
<String
> al
= classInstanceMap
.get(cls
);
774 ListIterator
<String
> li
= al
.listIterator();
775 while(li
.hasNext()) {
776 String instance
= li
.next();
777 String
[] s
= {"", "", "", "", ""};
778 if (getModuleId(instance
) != null) {
779 s
[0] = getModuleId(instance
).getName();
782 String
[] instancePart
= instance
.split(" ");
783 for (int i
= 0; i
< instancePart
.length
; ++i
){
784 s
[i
+1] = instancePart
[i
];
797 * This method initializes jScrollPane4
799 * @return javax.swing.JScrollPane
801 private JScrollPane
getJScrollPane4() {
802 if (jScrollPane4
== null) {
803 jScrollPane4
= new JScrollPane();
804 jScrollPane4
.setPreferredSize(new java
.awt
.Dimension(450,170));
805 jScrollPane4
.setViewportView(getJTable3());
811 * This method initializes jTable3
813 * @return javax.swing.JTable
815 private JTable
getJTable3() {
816 if (jTable3
== null) {
817 model3
= new LibraryTableModel();
818 model3
.addColumn("Name");
819 model3
.addColumn("ModuleGUID");
820 model3
.addColumn("ModuleVersion");
821 model3
.addColumn("PackageGUID");
822 model3
.addColumn("PackageVersion");
823 jTable3
= new JTable(model3
);
824 jTable3
.setRowHeight(20);
825 jTable3
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
826 jTable3
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
827 jTable3
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
828 public void valueChanged(ListSelectionEvent e
) {
829 int selectedRow3
= -1;
830 if (e
.getValueIsAdjusting()){
833 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
834 if (lsm
.isSelectionEmpty()) {
838 selectedRow3
= lsm
.getMinSelectionIndex();
849 * This method initializes jPanel6
851 * @return javax.swing.JPanel
853 private JPanel
getJPanel6() {
854 if (jPanel6
== null) {
855 jPanel6
= new JPanel();
861 * This method initializes jPanel7
863 * @return javax.swing.JPanel
865 private JPanel
getJPanel7() {
866 if (jPanel7
== null) {
867 jLabel4
= new JLabel();
868 jLabel4
.setText("Instance Description");
869 jLabel3
= new JLabel();
870 jLabel3
.setText("Selected Instances");
871 jPanel7
= new JPanel();
872 jPanel7
.add(jLabel4
, null);
873 jPanel7
.add(getJScrollPane5(), null);
874 jPanel7
.add(getJButton(), null);
875 jPanel7
.add(getJButton1(), null);
876 jPanel7
.add(jLabel3
, null);
877 jPanel7
.add(getJScrollPane2(), null);
883 * This method initializes jScrollPane5
885 * @return javax.swing.JScrollPane
887 private JScrollPane
getJScrollPane5() {
888 if (jScrollPane5
== null) {
889 jScrollPane5
= new JScrollPane();
890 jScrollPane5
.setPreferredSize(new java
.awt
.Dimension(300,50));
891 jScrollPane5
.setViewportView(getJTextArea1());
897 * This method initializes jTextArea1
899 * @return javax.swing.JTextArea
901 private JTextArea
getJTextArea1() {
902 if (jTextArea1
== null) {
903 jTextArea1
= new JTextArea();
904 jTextArea1
.setEditable(false);
910 * This method initializes jButton
912 * @return javax.swing.JButton
914 private JButton
getJButton() {
915 if (jButton
== null) {
916 jButton
= new JButton();
917 jButton
.setPreferredSize(new java
.awt
.Dimension(80,20));
918 jButton
.setText("Add");
919 jButton
.addActionListener(new java
.awt
.event
.ActionListener() {
920 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
921 int row
= jTable3
.getSelectedRow();
925 Object
[] s
= {model3
.getValueAt(row
, 0), model3
.getValueAt(row
, 1),
926 model3
.getValueAt(row
, 2), model3
.getValueAt(row
, 3),
927 model3
.getValueAt(row
, 4)};
929 String instanceValue
= model3
.getValueAt(row
, 1) + " " +
930 model3
.getValueAt(row
, 2) + " " +
931 model3
.getValueAt(row
, 3) + " " +
932 model3
.getValueAt(row
, 4);
934 // Add pcd information of selected instance to current moduleSA
936 ffc
.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue
), ffc
.getModuleSA(moduleKey
));
938 resolveLibraryInstances(instanceValue
);
946 * This method initializes jButton1
948 * @return javax.swing.JButton
950 private JButton
getJButton1() {
951 if (jButton1
== null) {
952 jButton1
= new JButton();
953 jButton1
.setPreferredSize(new java
.awt
.Dimension(80,20));
954 jButton1
.setText("Delete");
955 jButton1
.addActionListener(new java
.awt
.event
.ActionListener() {
956 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
957 int row
= jTable1
.getSelectedRow();
961 removeInstance(model1
.getValueAt(row
, 1) + " " +
962 model1
.getValueAt(row
, 2) + " " +
963 model1
.getValueAt(row
, 3) + " " +
964 model1
.getValueAt(row
, 4));
965 model1
.removeRow(row
);
974 * This method initializes jButton2
976 * @return javax.swing.JButton
978 private JButton
getJButton2() {
979 if (jButton2
== null) {
980 jButton2
= new JButton();
981 jButton2
.setPreferredSize(new java
.awt
.Dimension(80,20));
982 jButton2
.setText("Ok");
983 jButton2
.addActionListener(this);
989 * This method initializes jButton3
991 * @return javax.swing.JButton
993 private JButton
getJButton3() {
994 if (jButton3
== null) {
995 jButton3
= new JButton();
996 jButton3
.setPreferredSize(new java
.awt
.Dimension(80,20));
997 jButton3
.setText("Cancel");
998 jButton3
.setVisible(false);
1002 public void actionPerformed(ActionEvent arg0
) {
1004 if (arg0
.getSource() == jButton2
) {
1005 ffc
.removeLibraryInstances(moduleKey
);
1006 for (int i
= 0; i
< model1
.getRowCount(); ++i
) {
1007 String mg
= model1
.getValueAt(i
, 1)+"";
1008 String mv
= model1
.getValueAt(i
, 2)+"";
1009 String pg
= model1
.getValueAt(i
, 3)+"";
1010 String pv
= model1
.getValueAt(i
, 4)+"";
1011 ffc
.genLibraryInstance(mg
, mv
, pg
, pv
, moduleKey
);
1013 this.setVisible(false);
1017 * This method initializes jPanel8
1019 * @return javax.swing.JPanel
1021 private JPanel
getJPanel8() {
1022 if (jPanel8
== null) {
1023 jLabel8
= new JLabel();
1024 jLabel8
.setText("FFS Format Key");
1025 jLabel7
= new JLabel();
1026 jLabel7
.setText("FFS File GUID");
1027 jLabel6
= new JLabel();
1028 jLabel6
.setText("FV Binding");
1029 jPanel8
= new JPanel();
1030 jPanel8
.add(jLabel6
, null);
1031 jPanel8
.add(getJTextField(), null);
1032 jPanel8
.add(jLabel7
, null);
1033 jPanel8
.add(getJTextField1(), null);
1034 jPanel8
.add(jLabel8
, null);
1035 jPanel8
.add(getJTextField2(), null);
1036 jPanel8
.add(getJScrollPane6(), null);
1037 jPanel8
.add(getJButton4(), null);
1038 jPanel8
.add(getJButton5(), null);
1039 jPanel8
.addComponentListener(new java
.awt
.event
.ComponentAdapter() {
1040 public void componentShown(java
.awt
.event
.ComponentEvent e
) {
1048 * This method initializes jTextField
1050 * @return javax.swing.JTextField
1052 private JTextField
getJTextField() {
1053 if (jTextField
== null) {
1054 jTextField
= new JTextField();
1055 jTextField
.setPreferredSize(new java
.awt
.Dimension(100,20));
1056 jTextField
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
1057 public void focusLost(java
.awt
.event
.FocusEvent e
) {
1058 ffc
.setFvBinding(moduleKey
, jTextField
.getText());
1065 * This method initializes jTextField1
1067 * @return javax.swing.JTextField
1069 private JTextField
getJTextField1() {
1070 if (jTextField1
== null) {
1071 jTextField1
= new JTextField();
1072 jTextField1
.setPreferredSize(new java
.awt
.Dimension(100,20));
1073 jTextField1
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
1074 public void focusLost(java
.awt
.event
.FocusEvent e
) {
1075 ffc
.setFfsFileNameGuid(moduleKey
, jTextField1
.getText());
1082 * This method initializes jTextField2
1084 * @return javax.swing.JTextField
1086 private JTextField
getJTextField2() {
1087 if (jTextField2
== null) {
1088 jTextField2
= new JTextField();
1089 jTextField2
.setPreferredSize(new java
.awt
.Dimension(100,20));
1090 jTextField2
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
1091 public void focusLost(java
.awt
.event
.FocusEvent e
) {
1092 ffc
.setFfsFormatKey(moduleKey
, jTextField2
.getText());
1099 * This method initializes jScrollPane6
1101 * @return javax.swing.JScrollPane
1103 private JScrollPane
getJScrollPane6() {
1104 if (jScrollPane6
== null) {
1105 jScrollPane6
= new JScrollPane();
1106 jScrollPane6
.setPreferredSize(new java
.awt
.Dimension(600,200));
1107 jScrollPane6
.setViewportView(getJTable4());
1109 return jScrollPane6
;
1112 * This method initializes jTable4
1114 * @return javax.swing.JTable
1116 private JTable
getJTable4() {
1117 if (jTable4
== null) {
1118 optionsTableModel
= new DefaultTableModel();
1119 optionsTableModel
.addColumn("BuildTargets");
1120 optionsTableModel
.addColumn("ToolChainFamily");
1121 optionsTableModel
.addColumn("TagName");
1122 optionsTableModel
.addColumn("ToolCode");
1123 optionsTableModel
.addColumn("SupportedArchs");
1124 optionsTableModel
.addColumn("Contents");
1125 jTable4
= new JTable(optionsTableModel
);
1126 jTable4
.setRowHeight(20);
1127 Vector
<String
> vArch
= new Vector
<String
>();
1134 jTable4
.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch
));
1135 jTable4
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
1136 jTable4
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
1137 jTable4
.getModel().addTableModelListener(new TableModelListener() {
1138 public void tableChanged(TableModelEvent arg0
) {
1139 // TODO Auto-generated method stub
1140 int row
= arg0
.getFirstRow();
1141 TableModel m
= (TableModel
)arg0
.getSource();
1143 if (arg0
.getType() == TableModelEvent
.UPDATE
){
1144 //ToDo Data Validition check.
1145 String targets
= m
.getValueAt(row
, 0) + "";
1146 Vector
<Object
> targetName
= null;
1147 if (targets
.length() > 0) {
1148 targetName
= new Vector
<Object
>();
1149 String
[] sArray
= targets
.split(" ");
1150 for (int i
= 0; i
< sArray
.length
; ++i
) {
1151 targetName
.add(sArray
[i
]);
1155 String toolChain
= m
.getValueAt(row
, 1) + "";
1156 String tagName
= m
.getValueAt(row
, 2) + "";
1157 String toolCode
= m
.getValueAt(row
, 3) + "";
1158 String archs
= m
.getValueAt(row
, 4) + "";
1159 Vector
<Object
> supArch
= null;
1160 if (archs
.length() > 0) {
1161 supArch
= new Vector
<Object
>();
1162 String
[] sArray1
= archs
.split(" ");
1163 for (int i
= 0; i
< sArray1
.length
; ++i
) {
1164 supArch
.add(sArray1
[i
]);
1168 String contents
= m
.getValueAt(row
, 5) + "";
1170 ffc
.updateModuleSAOptionsOpt(moduleKey
, row
, targetName
, toolChain
, tagName
, toolCode
, supArch
, contents
);
1178 * This method initializes jButton4
1180 * @return javax.swing.JButton
1182 private JButton
getJButton4() {
1183 if (jButton4
== null) {
1184 jButton4
= new JButton();
1185 jButton4
.setPreferredSize(new java
.awt
.Dimension(80,20));
1186 jButton4
.setText("New");
1187 jButton4
.addActionListener(new java
.awt
.event
.ActionListener() {
1188 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
1189 String
[] row
= {"", "", "", "", "IA32", ""};
1190 optionsTableModel
.addRow(row
);
1191 Vector
<Object
> v
= new Vector
<Object
>();
1192 Vector
<Object
> v1
= new Vector
<Object
>();
1194 ffc
.genModuleSAOptionsOpt(moduleKey
, v
, "", "", "", v1
, "");
1201 * This method initializes jButton5
1203 * @return javax.swing.JButton
1205 private JButton
getJButton5() {
1206 if (jButton5
== null) {
1207 jButton5
= new JButton();
1208 jButton5
.setPreferredSize(new java
.awt
.Dimension(80,20));
1209 jButton5
.setText("Delete");
1210 jButton5
.addActionListener(new java
.awt
.event
.ActionListener() {
1211 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
1212 if (jTable4
.getSelectedRow() < 0) {
1216 ffc
.removeModuleSAOptionsOpt(moduleKey
, jTable4
.getSelectedRow());
1217 optionsTableModel
.removeRow(jTable4
.getSelectedRow());
1225 Start the window at the center of screen
1228 protected void centerWindow(int intWidth
, int intHeight
) {
1229 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
1230 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
1234 Start the window at the center of screen
1237 protected void centerWindow() {
1238 centerWindow(this.getSize().width
, this.getSize().height
);
1242 } // @jve:decl-index=0:visual-constraint="10,10"
1244 class PartialEditableTableModel
extends DefaultTableModel
{
1248 private static final long serialVersionUID
= 1L;
1250 public boolean isCellEditable(int row
, int col
) {
1261 class LibraryTableModel
extends DefaultTableModel
{
1265 private static final long serialVersionUID
= 1L;
1267 public boolean isCellEditable(int row
, int col
) {