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
][7];
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("MaxDatumSize");
523 model
.addColumn("DataType");
524 model
.addColumn("DefaultValue");
526 jTable
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
527 jTable
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
528 public void valueChanged(ListSelectionEvent e
) {
530 if (e
.getValueIsAdjusting()){
533 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
534 if (lsm
.isSelectionEmpty()) {
538 // int selectedRow = lsm.getMinSelectionIndex();
545 jTable
.getModel().addTableModelListener(new TableModelListener() {
546 public void tableChanged(TableModelEvent arg0
) {
547 // TODO Auto-generated method stub
548 int row
= arg0
.getFirstRow();
549 TableModel m
= (TableModel
)arg0
.getSource();
550 if (arg0
.getType() == TableModelEvent
.INSERT
) {
552 // Set combo box values for item type according to pcd values added.
556 if (arg0
.getType() == TableModelEvent
.UPDATE
){
557 //ToDo Data Validition check.
567 * This method initializes jPanel2
569 * @return javax.swing.JPanel
571 private JPanel
getJPanel2() {
572 if (jPanel2
== null) {
573 jLabel5
= new JLabel();
574 jLabel5
.setText("PCD Description");
575 jPanel2
= new JPanel();
576 jPanel2
.add(jLabel5
, null);
577 jPanel2
.add(getJScrollPane1(), null);
583 * This method initializes jScrollPane1
585 * @return javax.swing.JScrollPane
587 private JScrollPane
getJScrollPane1() {
588 if (jScrollPane1
== null) {
589 jScrollPane1
= new JScrollPane();
590 jScrollPane1
.setPreferredSize(new java
.awt
.Dimension(500,100));
591 jScrollPane1
.setViewportView(getJTextArea());
597 * This method initializes jTextArea
599 * @return javax.swing.JTextArea
601 private JTextArea
getJTextArea() {
602 if (jTextArea
== null) {
603 jTextArea
= new JTextArea();
604 jTextArea
.setEditable(false);
610 * This method initializes jPanel3
612 * @return javax.swing.JPanel
614 private JPanel
getJPanel3() {
615 if (jPanel3
== null) {
616 FlowLayout flowLayout
= new FlowLayout();
617 flowLayout
.setAlignment(java
.awt
.FlowLayout
.RIGHT
);
618 jPanel3
= new JPanel();
619 jPanel3
.setLayout(flowLayout
);
620 jPanel3
.add(getJButton2(), null);
621 jPanel3
.add(getJButton3(), null);
627 * This method initializes jSplitPane
629 * @return javax.swing.JSplitPane
631 private JSplitPane
getJSplitPane() {
632 if (jSplitPane
== null) {
633 jSplitPane
= new JSplitPane();
634 jSplitPane
.setDividerLocation(200);
635 jSplitPane
.setLeftComponent(getJPanel4());
636 jSplitPane
.setRightComponent(getJPanel5());
637 jSplitPane
.setPreferredSize(new java
.awt
.Dimension(202,200));
643 * This method initializes jPanel4
645 * @return javax.swing.JPanel
647 private JPanel
getJPanel4() {
648 if (jPanel4
== null) {
649 jLabel1
= new JLabel();
650 jLabel1
.setText("Library Classes Consumed");
651 jPanel4
= new JPanel();
652 jPanel4
.add(jLabel1
, null);
653 jPanel4
.add(getJScrollPane3(), null);
659 * This method initializes jPanel5
661 * @return javax.swing.JPanel
663 private JPanel
getJPanel5() {
664 if (jPanel5
== null) {
665 jLabel2
= new JLabel();
666 jLabel2
.setText("Instances Available");
667 jPanel5
= new JPanel();
668 jPanel5
.add(jLabel2
, null);
669 jPanel5
.add(getJScrollPane4(), null);
675 * This method initializes jScrollPane2
677 * @return javax.swing.JScrollPane
679 private JScrollPane
getJScrollPane2() {
680 if (jScrollPane2
== null) {
681 jScrollPane2
= new JScrollPane();
682 jScrollPane2
.setPreferredSize(new java
.awt
.Dimension(453,150));
683 jScrollPane2
.setViewportView(getJTable1());
689 * This method initializes jTable1
691 * @return javax.swing.JTable
693 private JTable
getJTable1() {
694 if (jTable1
== null) {
695 model1
= new LibraryTableModel();
696 model1
.addColumn("Name");
697 model1
.addColumn("ModuleGUID");
698 model1
.addColumn("ModuleVersion");
699 model1
.addColumn("PackageGUID");
700 model1
.addColumn("PackageVersion");
701 jTable1
= new JTable(model1
);
702 jTable1
.setRowHeight(20);
703 jTable1
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
704 jTable1
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
705 jTable1
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
706 public void valueChanged(ListSelectionEvent e
) {
707 int selectedRow1
= -1;
708 if (e
.getValueIsAdjusting()){
711 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
712 if (lsm
.isSelectionEmpty()) {
716 selectedRow1
= lsm
.getMinSelectionIndex();
729 * This method initializes jScrollPane3
731 * @return javax.swing.JScrollPane
733 private JScrollPane
getJScrollPane3() {
734 if (jScrollPane3
== null) {
735 jScrollPane3
= new JScrollPane();
736 jScrollPane3
.setPreferredSize(new java
.awt
.Dimension(200,170));
737 jScrollPane3
.setViewportView(getJTable2());
743 * This method initializes jTable2
745 * @return javax.swing.JTable
747 private JTable
getJTable2() {
748 if (jTable2
== null) {
749 model2
= new LibraryTableModel();
750 model2
.addColumn("LibraryClass");
751 jTable2
= new JTable(model2
);
752 jTable2
.setRowHeight(20);
753 jTable2
.setShowGrid(false);
754 jTable2
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
755 jTable2
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
756 public void valueChanged(ListSelectionEvent e
) {
757 if (e
.getValueIsAdjusting()){
760 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
761 if (lsm
.isSelectionEmpty()) {
765 int selectedRow2
= lsm
.getMinSelectionIndex();
766 if (selectedRow2
< 0) {
770 // display potential lib instances according to class selection
772 model3
.setRowCount(0);
773 String cls
= model2
.getValueAt(selectedRow2
, 0).toString();
774 ArrayList
<String
> al
= classInstanceMap
.get(cls
);
775 ListIterator
<String
> li
= al
.listIterator();
776 while(li
.hasNext()) {
777 String instance
= li
.next();
778 String
[] s
= {"", "", "", "", ""};
779 if (getModuleId(instance
) != null) {
780 s
[0] = getModuleId(instance
).getName();
783 String
[] instancePart
= instance
.split(" ");
784 for (int i
= 0; i
< instancePart
.length
; ++i
){
785 s
[i
+1] = instancePart
[i
];
798 * This method initializes jScrollPane4
800 * @return javax.swing.JScrollPane
802 private JScrollPane
getJScrollPane4() {
803 if (jScrollPane4
== null) {
804 jScrollPane4
= new JScrollPane();
805 jScrollPane4
.setPreferredSize(new java
.awt
.Dimension(450,170));
806 jScrollPane4
.setViewportView(getJTable3());
812 * This method initializes jTable3
814 * @return javax.swing.JTable
816 private JTable
getJTable3() {
817 if (jTable3
== null) {
818 model3
= new LibraryTableModel();
819 model3
.addColumn("Name");
820 model3
.addColumn("ModuleGUID");
821 model3
.addColumn("ModuleVersion");
822 model3
.addColumn("PackageGUID");
823 model3
.addColumn("PackageVersion");
824 jTable3
= new JTable(model3
);
825 jTable3
.setRowHeight(20);
826 jTable3
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
827 jTable3
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
828 jTable3
.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
829 public void valueChanged(ListSelectionEvent e
) {
830 int selectedRow3
= -1;
831 if (e
.getValueIsAdjusting()){
834 ListSelectionModel lsm
= (ListSelectionModel
)e
.getSource();
835 if (lsm
.isSelectionEmpty()) {
839 selectedRow3
= lsm
.getMinSelectionIndex();
850 * This method initializes jPanel6
852 * @return javax.swing.JPanel
854 private JPanel
getJPanel6() {
855 if (jPanel6
== null) {
856 jPanel6
= new JPanel();
862 * This method initializes jPanel7
864 * @return javax.swing.JPanel
866 private JPanel
getJPanel7() {
867 if (jPanel7
== null) {
868 jLabel4
= new JLabel();
869 jLabel4
.setText("Instance Description");
870 jLabel3
= new JLabel();
871 jLabel3
.setText("Selected Instances");
872 jPanel7
= new JPanel();
873 jPanel7
.add(jLabel4
, null);
874 jPanel7
.add(getJScrollPane5(), null);
875 jPanel7
.add(getJButton(), null);
876 jPanel7
.add(getJButton1(), null);
877 jPanel7
.add(jLabel3
, null);
878 jPanel7
.add(getJScrollPane2(), null);
884 * This method initializes jScrollPane5
886 * @return javax.swing.JScrollPane
888 private JScrollPane
getJScrollPane5() {
889 if (jScrollPane5
== null) {
890 jScrollPane5
= new JScrollPane();
891 jScrollPane5
.setPreferredSize(new java
.awt
.Dimension(300,50));
892 jScrollPane5
.setViewportView(getJTextArea1());
898 * This method initializes jTextArea1
900 * @return javax.swing.JTextArea
902 private JTextArea
getJTextArea1() {
903 if (jTextArea1
== null) {
904 jTextArea1
= new JTextArea();
905 jTextArea1
.setEditable(false);
911 * This method initializes jButton
913 * @return javax.swing.JButton
915 private JButton
getJButton() {
916 if (jButton
== null) {
917 jButton
= new JButton();
918 jButton
.setPreferredSize(new java
.awt
.Dimension(80,20));
919 jButton
.setText("Add");
920 jButton
.addActionListener(new java
.awt
.event
.ActionListener() {
921 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
922 int row
= jTable3
.getSelectedRow();
926 Object
[] s
= {model3
.getValueAt(row
, 0), model3
.getValueAt(row
, 1),
927 model3
.getValueAt(row
, 2), model3
.getValueAt(row
, 3),
928 model3
.getValueAt(row
, 4)};
930 String instanceValue
= model3
.getValueAt(row
, 1) + " " +
931 model3
.getValueAt(row
, 2) + " " +
932 model3
.getValueAt(row
, 3) + " " +
933 model3
.getValueAt(row
, 4);
935 // Add pcd information of selected instance to current moduleSA
938 ffc
.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue
), ffc
.getModuleSA(moduleKey
));
940 catch (Exception exception
) {
941 JOptionPane
.showMessageDialog(frame
, "PCD Insertion Fail. " + exception
.getMessage());
943 resolveLibraryInstances(instanceValue
);
951 * This method initializes jButton1
953 * @return javax.swing.JButton
955 private JButton
getJButton1() {
956 if (jButton1
== null) {
957 jButton1
= new JButton();
958 jButton1
.setPreferredSize(new java
.awt
.Dimension(80,20));
959 jButton1
.setText("Delete");
960 jButton1
.addActionListener(new java
.awt
.event
.ActionListener() {
961 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
962 int row
= jTable1
.getSelectedRow();
966 removeInstance(model1
.getValueAt(row
, 1) + " " +
967 model1
.getValueAt(row
, 2) + " " +
968 model1
.getValueAt(row
, 3) + " " +
969 model1
.getValueAt(row
, 4));
970 model1
.removeRow(row
);
979 * This method initializes jButton2
981 * @return javax.swing.JButton
983 private JButton
getJButton2() {
984 if (jButton2
== null) {
985 jButton2
= new JButton();
986 jButton2
.setPreferredSize(new java
.awt
.Dimension(80,20));
987 jButton2
.setText("Ok");
988 jButton2
.addActionListener(this);
994 * This method initializes jButton3
996 * @return javax.swing.JButton
998 private JButton
getJButton3() {
999 if (jButton3
== null) {
1000 jButton3
= new JButton();
1001 jButton3
.setPreferredSize(new java
.awt
.Dimension(80,20));
1002 jButton3
.setText("Cancel");
1003 jButton3
.setVisible(false);
1007 public void actionPerformed(ActionEvent arg0
) {
1009 if (arg0
.getSource() == jButton2
) {
1010 ffc
.removeLibraryInstances(moduleKey
);
1011 for (int i
= 0; i
< model1
.getRowCount(); ++i
) {
1012 String mg
= model1
.getValueAt(i
, 1)+"";
1013 String mv
= model1
.getValueAt(i
, 2)+"";
1014 String pg
= model1
.getValueAt(i
, 3)+"";
1015 String pv
= model1
.getValueAt(i
, 4)+"";
1016 ffc
.genLibraryInstance(mg
, mv
, pg
, pv
, moduleKey
);
1018 this.setVisible(false);
1022 * This method initializes jPanel8
1024 * @return javax.swing.JPanel
1026 private JPanel
getJPanel8() {
1027 if (jPanel8
== null) {
1028 jLabel8
= new JLabel();
1029 jLabel8
.setText("FFS Format Key");
1030 jLabel7
= new JLabel();
1031 jLabel7
.setText("FFS File GUID");
1032 jLabel6
= new JLabel();
1033 jLabel6
.setText("FV Binding");
1034 jPanel8
= new JPanel();
1035 jPanel8
.add(jLabel6
, null);
1036 jPanel8
.add(getJTextField(), null);
1037 jPanel8
.add(jLabel7
, null);
1038 jPanel8
.add(getJTextField1(), null);
1039 jPanel8
.add(jLabel8
, null);
1040 jPanel8
.add(getJTextField2(), null);
1041 jPanel8
.add(getJScrollPane6(), null);
1042 jPanel8
.add(getJButton4(), null);
1043 jPanel8
.add(getJButton5(), null);
1044 jPanel8
.addComponentListener(new java
.awt
.event
.ComponentAdapter() {
1045 public void componentShown(java
.awt
.event
.ComponentEvent e
) {
1053 * This method initializes jTextField
1055 * @return javax.swing.JTextField
1057 private JTextField
getJTextField() {
1058 if (jTextField
== null) {
1059 jTextField
= new JTextField();
1060 jTextField
.setPreferredSize(new java
.awt
.Dimension(100,20));
1061 jTextField
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
1062 public void focusLost(java
.awt
.event
.FocusEvent e
) {
1063 ffc
.setFvBinding(moduleKey
, jTextField
.getText());
1070 * This method initializes jTextField1
1072 * @return javax.swing.JTextField
1074 private JTextField
getJTextField1() {
1075 if (jTextField1
== null) {
1076 jTextField1
= new JTextField();
1077 jTextField1
.setPreferredSize(new java
.awt
.Dimension(100,20));
1078 jTextField1
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
1079 public void focusLost(java
.awt
.event
.FocusEvent e
) {
1080 ffc
.setFfsFileNameGuid(moduleKey
, jTextField1
.getText());
1087 * This method initializes jTextField2
1089 * @return javax.swing.JTextField
1091 private JTextField
getJTextField2() {
1092 if (jTextField2
== null) {
1093 jTextField2
= new JTextField();
1094 jTextField2
.setPreferredSize(new java
.awt
.Dimension(100,20));
1095 jTextField2
.addFocusListener(new java
.awt
.event
.FocusAdapter() {
1096 public void focusLost(java
.awt
.event
.FocusEvent e
) {
1097 ffc
.setFfsFormatKey(moduleKey
, jTextField2
.getText());
1104 * This method initializes jScrollPane6
1106 * @return javax.swing.JScrollPane
1108 private JScrollPane
getJScrollPane6() {
1109 if (jScrollPane6
== null) {
1110 jScrollPane6
= new JScrollPane();
1111 jScrollPane6
.setPreferredSize(new java
.awt
.Dimension(600,200));
1112 jScrollPane6
.setViewportView(getJTable4());
1114 return jScrollPane6
;
1117 * This method initializes jTable4
1119 * @return javax.swing.JTable
1121 private JTable
getJTable4() {
1122 if (jTable4
== null) {
1123 optionsTableModel
= new DefaultTableModel();
1124 optionsTableModel
.addColumn("BuildTargets");
1125 optionsTableModel
.addColumn("ToolChainFamily");
1126 optionsTableModel
.addColumn("TagName");
1127 optionsTableModel
.addColumn("ToolCode");
1128 optionsTableModel
.addColumn("SupportedArchs");
1129 optionsTableModel
.addColumn("Contents");
1130 jTable4
= new JTable(optionsTableModel
);
1131 jTable4
.setRowHeight(20);
1132 Vector
<String
> vArch
= new Vector
<String
>();
1139 jTable4
.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch
));
1140 jTable4
.setSelectionMode(ListSelectionModel
.SINGLE_SELECTION
);
1141 jTable4
.setAutoResizeMode(javax
.swing
.JTable
.AUTO_RESIZE_OFF
);
1142 jTable4
.getModel().addTableModelListener(new TableModelListener() {
1143 public void tableChanged(TableModelEvent arg0
) {
1144 // TODO Auto-generated method stub
1145 int row
= arg0
.getFirstRow();
1146 TableModel m
= (TableModel
)arg0
.getSource();
1148 if (arg0
.getType() == TableModelEvent
.UPDATE
){
1149 //ToDo Data Validition check.
1150 String targets
= m
.getValueAt(row
, 0) + "";
1151 Vector
<Object
> targetName
= null;
1152 if (targets
.length() > 0) {
1153 targetName
= new Vector
<Object
>();
1154 String
[] sArray
= targets
.split(" ");
1155 for (int i
= 0; i
< sArray
.length
; ++i
) {
1156 targetName
.add(sArray
[i
]);
1160 String toolChain
= m
.getValueAt(row
, 1) + "";
1161 String tagName
= m
.getValueAt(row
, 2) + "";
1162 String toolCode
= m
.getValueAt(row
, 3) + "";
1163 String archs
= m
.getValueAt(row
, 4) + "";
1164 Vector
<Object
> supArch
= null;
1165 if (archs
.length() > 0) {
1166 supArch
= new Vector
<Object
>();
1167 String
[] sArray1
= archs
.split(" ");
1168 for (int i
= 0; i
< sArray1
.length
; ++i
) {
1169 supArch
.add(sArray1
[i
]);
1173 String contents
= m
.getValueAt(row
, 5) + "";
1175 ffc
.updateModuleSAOptionsOpt(moduleKey
, row
, targetName
, toolChain
, tagName
, toolCode
, supArch
, contents
);
1183 * This method initializes jButton4
1185 * @return javax.swing.JButton
1187 private JButton
getJButton4() {
1188 if (jButton4
== null) {
1189 jButton4
= new JButton();
1190 jButton4
.setPreferredSize(new java
.awt
.Dimension(80,20));
1191 jButton4
.setText("New");
1192 jButton4
.addActionListener(new java
.awt
.event
.ActionListener() {
1193 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
1194 String
[] row
= {"", "", "", "", "IA32", ""};
1195 optionsTableModel
.addRow(row
);
1196 Vector
<Object
> v
= new Vector
<Object
>();
1197 Vector
<Object
> v1
= new Vector
<Object
>();
1199 ffc
.genModuleSAOptionsOpt(moduleKey
, v
, "", "", "", v1
, "");
1206 * This method initializes jButton5
1208 * @return javax.swing.JButton
1210 private JButton
getJButton5() {
1211 if (jButton5
== null) {
1212 jButton5
= new JButton();
1213 jButton5
.setPreferredSize(new java
.awt
.Dimension(80,20));
1214 jButton5
.setText("Delete");
1215 jButton5
.addActionListener(new java
.awt
.event
.ActionListener() {
1216 public void actionPerformed(java
.awt
.event
.ActionEvent e
) {
1217 if (jTable4
.getSelectedRow() < 0) {
1221 ffc
.removeModuleSAOptionsOpt(moduleKey
, jTable4
.getSelectedRow());
1222 optionsTableModel
.removeRow(jTable4
.getSelectedRow());
1230 Start the window at the center of screen
1233 protected void centerWindow(int intWidth
, int intHeight
) {
1234 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
1235 this.setLocation((d
.width
- intWidth
) / 2, (d
.height
- intHeight
) / 2);
1239 Start the window at the center of screen
1242 protected void centerWindow() {
1243 centerWindow(this.getSize().width
, this.getSize().height
);
1247 } // @jve:decl-index=0:visual-constraint="10,10"
1249 class PartialEditableTableModel
extends DefaultTableModel
{
1253 private static final long serialVersionUID
= 1L;
1255 public boolean isCellEditable(int row
, int col
) {
1266 class LibraryTableModel
extends DefaultTableModel
{
1270 private static final long serialVersionUID
= 1L;
1272 public boolean isCellEditable(int row
, int col
) {