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