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