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