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