]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
230b9e8230399fc658ba7d412366a43e317e4483
[mirror_edk2.git] / Tools / Java / 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.JOptionPane;
8 import javax.swing.JPanel;
9 import javax.swing.JDialog;
10 import javax.swing.JTabbedPane;
11 import javax.swing.JLabel;
12 import javax.swing.JScrollPane;
13 import javax.swing.JTable;
14 import javax.swing.JTextArea;
15 import javax.swing.JSplitPane;
16 import javax.swing.JButton;
17 import javax.swing.ListSelectionModel;
18 import javax.swing.event.ListSelectionEvent;
19 import javax.swing.event.ListSelectionListener;
20 import javax.swing.event.TableModelEvent;
21 import javax.swing.event.TableModelListener;
22 import javax.swing.table.DefaultTableModel;
23 import javax.swing.table.TableColumn;
24 import javax.swing.table.TableModel;
25
26 import org.tianocore.frameworkwizard.FrameworkWizardUI;
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.LibraryClassDescriptor;
32 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
33 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
34 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
35 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
36
37 import java.awt.FlowLayout;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.util.ArrayList;
41 import java.util.HashMap;
42 import java.util.Iterator;
43 import java.util.ListIterator;
44 import java.util.Vector;
45
46 import javax.swing.JTextField;
47 import java.awt.GridLayout;
48 import javax.swing.JComboBox;
49
50 public class FpdModuleSA extends JDialog implements ActionListener {
51
52 /**
53 *
54 */
55 private static final long serialVersionUID = 1L;
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 ModuleIdentification moduleId = null;
97 private int moduleSaNum = -1;
98 private HashMap<LibraryClassDescriptor, ArrayList<String>> classInstanceMap = null;
99 //
100 // map of <{libName, supArch, supMod}, list of Module information>
101 //
102 private HashMap<LibraryClassDescriptor, ArrayList<String>> classConsumed = null;
103 private HashMap<LibraryClassDescriptor, ArrayList<String>> classProduced = null;
104
105 private JPanel jPanelModuleSaOpts = null;
106 private JLabel jLabelFvBinding = null;
107 private JTextField jTextFieldFvBinding = null;
108 private JLabel jLabelFfsFileGuid = null;
109 private JTextField jTextFieldFileGuid = null;
110 private JLabel jLabelFfsFormatKey = null;
111 private JTextField jTextFieldFfsKey = null;
112 private JScrollPane jScrollPaneModuleSaOptions = null;
113 private JTable jTableModuleSaOptions = null;
114 private JButton jButtonNew = null;
115 private JButton jButtonDeleteOption = null;
116 private JPanel jPanelPcdFields = null;
117 private JPanel jPanelPcdFieldsSecondRow = null;
118 private JPanel jPanelPcdFieldsThirdRow = null;
119 private JPanel jPanelPcdFieldsFirstRow = null;
120 private JLabel jLabelItemType = null;
121 private JComboBox jComboBoxItemType = null;
122 private JLabel jLabelMaxDatumSize = null;
123 private JTextField jTextFieldMaxDatumSize = null;
124 private JLabel jLabelPcdDefaultValue = null;
125 private JTextField jTextFieldPcdDefault = null;
126 private JButton jButtonUpdatePcd = null;
127 private JComboBox jComboBoxFeatureFlagValue = null;
128 private OpeningPlatformType docConsole = null;
129 private JPanel jPanelCustomToolChain = null;
130 private JPanel jPanelToolchainS = null;
131 private JPanel jPanelLibraryCenterN = null;
132 private JPanel jPanelLibraryCenterC = null; // @jve:decl-index=0:visual-constraint="20,224"
133
134 private final int buildTargetWidth = 150;
135 private final int toolChainFamilyWidth = 150;
136 private final int supportArchWidth = 150;
137 private final int toolCmdCodeWidth = 200;
138 private final int tagNameWidth = 150;
139 private final int argWidth = 400;
140
141 /**
142 * This is the default constructor
143 */
144 public FpdModuleSA() {
145 super(FrameworkWizardUI.getInstance());
146 initialize();
147 }
148 public FpdModuleSA(FpdFileContents ffc) {
149 this();
150 this.ffc = ffc;
151 }
152
153 public void setKey(String k, int i, OpeningPlatformType dc){
154 this.moduleKey = k;
155 moduleSaNum = i;
156 this.docConsole = dc;
157 classInstanceMap = null;
158 classProduced = null;
159 classConsumed = null;
160 jTabbedPane.setSelectedIndex(0);
161 initPcdBuildDefinition(i);
162 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
163 if (mi == null) {
164 return;
165 }
166 int tabIndex = jTabbedPane.indexOfTab("Libraries");
167 if (mi.isLibrary()) {
168 jTabbedPane.setEnabledAt(tabIndex, false);
169 }
170 else {
171 jTabbedPane.setEnabledAt(tabIndex, true);
172 }
173 }
174
175 /**
176 init will be called each time FpdModuleSA object is to be shown.
177 @param key Module information.
178 **/
179 public void initPcdBuildDefinition(int i) {
180 //
181 // display pcd for key.
182 //
183 model.setRowCount(0);
184 jTextAreaPcdHelp.setText("");
185 jComboBoxItemType.setSelectedIndex(-1);
186 jTextFieldMaxDatumSize.setText("");
187 jTextFieldPcdDefault.setText("");
188 int pcdCount = ffc.getPcdDataCount(i);
189 if (pcdCount != 0) {
190 String[][] saa = new String[pcdCount][7];
191 ffc.getPcdData(i, saa);
192 for (int j = 0; j < saa.length; ++j) {
193 model.addRow(saa[j]);
194 }
195 }
196 }
197
198 public void initLibraries(String key) {
199 libClassTableModel.setRowCount(0);
200 libInstanceTableModel.setRowCount(0);
201 selectedInstancesTableModel.setRowCount(0);
202 moduleId = WorkspaceProfile.getModuleId(moduleKey);
203 Vector<String> errorMsg = new Vector<String>();
204 try {
205 //
206 // display library classes that need to be resolved. also potential instances for them.
207 //
208 resolveLibraryInstances(moduleKey, errorMsg);
209 } catch (Exception e) {
210 String exceptionMsg = e.getCause() + " " + e.getMessage();
211 errorMsg.add(exceptionMsg);
212 JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), exceptionMsg);
213 }
214 //
215 // display lib instances already selected for key
216 //
217
218 int instanceCount = ffc.getLibraryInstancesCount(key);
219 if (instanceCount != 0) {
220 String[][] saa = new String[instanceCount][5];
221 ffc.getLibraryInstances(key, saa);
222 for (int i = 0; i < saa.length; ++i) {
223 ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3]
224 + " " + saa[i][4]);
225 if (mi != null) {
226 //
227 // ToDo: verify this instance first.
228 //
229 saa[i][0] = mi.getName();
230 saa[i][2] = mi.getVersion();
231 saa[i][4] = mi.getPackageId().getVersion();
232 //
233 // re-evaluate lib instance usage when adding a already-selected lib instance.
234 //
235 try {
236 resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4], errorMsg);
237 } catch (Exception e) {
238 String exceptionMsg = e.getCause() + " " + e.getMessage();
239 if (!errorMsg.contains(exceptionMsg)) {
240 JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), e.getCause() + " " + e.getMessage());
241 }
242 }
243 selectedInstancesTableModel.addRow(saa[i]);
244 }
245 }
246 }
247
248 if (errorMsg.size() > 0) {
249 String errors = "";
250 for (int i = 0; i < errorMsg.size(); ++i) {
251 errors += " " + errorMsg.get(i) + "\n";
252 }
253 JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), errors);
254 }
255 showClassToResolved();
256 }
257
258 public void initFvInfo (String key) {
259 //
260 // display module SA options
261 //
262 jTextFieldFvBinding.setText("");
263 String fvBinding = ffc.getFvBinding(key);
264 if (fvBinding != null) {
265 jTextFieldFvBinding.setText(fvBinding);
266 }
267 jTextFieldFileGuid.setText("");
268 String fileGuid = ffc.getFfsFileNameGuid(key);
269 if (fileGuid != null) {
270 jTextFieldFileGuid.setText(fileGuid);
271 }
272 jTextFieldFfsKey.setText("");
273 String ffsKey = ffc.getFfsFormatKey(key);
274 if (ffsKey != null) {
275 jTextFieldFfsKey.setText(ffsKey);
276 }
277 }
278
279 public void initToolChainOptions(String key) {
280
281 optionsTableModel.setRowCount(0);
282 String[][] saa = new String[ffc.getModuleSAOptionsCount(key)][6];
283 ffc.getModuleSAOptions(key, saa);
284 for (int i = 0; i < saa.length; ++i) {
285 optionsTableModel.addRow(saa[i]);
286 }
287 }
288
289 private void filterClassConsumedByArch (Vector<LibraryClassDescriptor> v) {
290 String[] moduleInfo = moduleKey.split(" ");
291 Vector<String> vModuleArchs = new Vector<String>();
292 //
293 // Skip guid, version information, get archs to check.
294 //
295 for (int i = 4; i < moduleInfo.length; ++i) {
296 vModuleArchs.add(moduleInfo[i]);
297 }
298 //
299 // if module will be built on all platforms, no filter needed for lib classes.
300 //
301 if (vModuleArchs.size() == 0) {
302 return;
303 }
304
305 Iterator<LibraryClassDescriptor> iter = v.iterator();
306 while (iter.hasNext()) {
307 LibraryClassDescriptor libInfo = iter.next();
308
309 Vector<String> vSupArchs = libInfo.getVectorFromString(libInfo.supArchs);
310
311 if (vSupArchs.size() == 0 || (vSupArchs.size() == 1 && vSupArchs.get(0).equalsIgnoreCase(""))) {
312 //
313 // update lib info to module archs only.
314 //
315 libInfo.supArchs = "";
316 for (int i = 0; i < vModuleArchs.size(); ++i) {
317 libInfo.supArchs += vModuleArchs.get(i);
318 libInfo.supArchs += " ";
319 }
320 libInfo.supArchs.trim();
321 continue;
322 }
323 //
324 // only retain those lib class used by module archs.
325 //
326 vSupArchs.retainAll(vModuleArchs);
327 if (vSupArchs.size() > 0) {
328 //
329 // update lib info to reflect which kind of arch need to select instance.
330 //
331 libInfo.supArchs = "";
332 for (int i = 0; i < vSupArchs.size(); ++i) {
333 libInfo.supArchs += vSupArchs.get(i);
334 libInfo.supArchs += " ";
335 }
336 libInfo.supArchs.trim();
337 continue;
338 }
339 //
340 // remove this lib definition if it supports no archs module will be built under.
341 //
342 iter.remove();
343 }
344 }
345
346 private void resolveLibraryInstances(String key, Vector<String> errorMsg) throws MultipleInstanceException, NoInstanceException{
347 ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
348 PackageIdentification[] depPkgList = null;
349
350 //
351 // Get dependency pkg list into which we will search lib instances.
352 //
353 depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi);
354 //
355 // Get the lib class consumed, produced by this module itself.
356 //
357 Vector<LibraryClassDescriptor> vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
358 for (int i = 0; i < vClassConsumed.size(); ++i) {
359 vClassConsumed.get(i).supModTypes = WorkspaceProfile.getModuleType(moduleId);
360 }
361 filterClassConsumedByArch(vClassConsumed);
362 if (this.classConsumed == null) {
363 this.classConsumed = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
364 }
365
366 for (int i = 0; i < vClassConsumed.size(); ++i) {
367 ArrayList<String> consumedBy = this.classConsumed.get(vClassConsumed.get(i));
368 if (consumedBy == null) {
369 consumedBy = new ArrayList<String>();
370 }
371 consumedBy.add(key);
372 this.classConsumed.put(vClassConsumed.get(i), consumedBy);
373 }
374
375 Vector<LibraryClassDescriptor> vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
376 if (this.classProduced == null) {
377 this.classProduced = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
378 }
379 for (int i = 0; i < vClassProduced.size(); ++i) {
380 ArrayList<String> producedBy = this.classProduced.get(vClassProduced.get(i));
381 if (producedBy == null) {
382 producedBy = new ArrayList<String>();
383 }
384 //
385 // class already produced by previous module (lib instance).
386 /*
387 if (producedBy.size() == 1) {
388 String instanceKey = producedBy.get(0);
389 ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceKey);
390 throw new MultipleInstanceException (vClassProduced.get(i).className, libMi.getName(), mi.getName());
391 }
392 Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
393 while (lcdi.hasNext()) {
394 LibraryClassDescriptor lcd = lcdi.next();
395 if (vClassProduced.get(i).hasInterSectionWith(lcd)) {
396 ArrayList<String> alreadyProducedBy = this.classProduced.get(lcd);
397 String instanceKey = alreadyProducedBy.get(0);
398 ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceKey);
399 throw new MultipleInstanceException (vClassProduced.get(i).className, libMi.getName(), mi.getName());
400 }
401 }
402 */
403 // normal case.
404 //
405 producedBy.add(key);
406 this.classProduced.put(vClassProduced.get(i), producedBy);
407
408 }
409
410 //
411 // find potential instances in all pkgs for classes still in classConsumed.
412 //
413 if (classInstanceMap == null) {
414 classInstanceMap = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
415 }
416 Iterator<LibraryClassDescriptor> lic = this.classConsumed.keySet().iterator();
417 while (lic.hasNext()) {
418 LibraryClassDescriptor cls = lic.next();
419 if (isBoundedClass(cls)) {
420 continue;
421 }
422 ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
423 if (instances.size() == 0) {
424 // throw new NoInstanceException (cls.className);
425 String exceptionMsg = new NoInstanceException (cls.className).getMessage();
426 if (!errorMsg.contains(exceptionMsg)) {
427 errorMsg.add(exceptionMsg);
428 }
429
430 }
431 classInstanceMap.put(cls, instances);
432
433 }
434 // showClassToResolved();
435 }
436
437 /**Search classProduced map to see if this class has been produced by some instance (module).
438 * @param cls
439 * @return
440 */
441 private boolean isBoundedClass (LibraryClassDescriptor cls) {
442 if (this.classProduced.containsKey(cls)) {
443 return true;
444 }
445 Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
446 while (lcdi.hasNext()) {
447 LibraryClassDescriptor lcd = lcdi.next();
448 if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) {
449 return true;
450 }
451 }
452
453 return false;
454 }
455
456 private ArrayList<String> getInstancesForClass(LibraryClassDescriptor cls, PackageIdentification[] depPkgList){
457 ArrayList<String> al = new ArrayList<String>();
458
459 // for (int i = 0; i < depPkgList.length; ++i) {
460 Iterator ismi = GlobalData.vModuleList.iterator();
461 while(ismi.hasNext()) {
462 ModuleIdentification mi = (ModuleIdentification)ismi.next();
463 // if (!mi.getPackageId().getGuid().equalsIgnoreCase(depPkgList[i].getGuid())) {
464 // continue;
465 // }
466 Vector<LibraryClassDescriptor> clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
467
468 boolean isPotential = false;
469 Iterator<LibraryClassDescriptor> lcdi = clsProduced.iterator();
470 while (lcdi.hasNext()) {
471 LibraryClassDescriptor lcd = lcdi.next();
472 if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)){
473 isPotential = true;
474 }
475
476 if (hasBeenProduced(lcd)) {
477 isPotential = false;
478 break;
479 }
480 }
481 if (isPotential) {
482 al.add(mi.getGuid() + " " + mi.getVersion() + " " +
483 mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion());
484 }
485 }
486 // }
487
488 return al;
489 }
490
491 private boolean hasBeenProduced (LibraryClassDescriptor cls) {
492 Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
493 while (lcdi.hasNext()) {
494 LibraryClassDescriptor lcd = lcdi.next();
495 if (cls.hasInterSectionWith(lcd)) {
496 return true;
497 }
498 }
499 return false;
500 }
501
502 private ArrayList<String> getConsumedBy (String className) {
503 Iterator<LibraryClassDescriptor> lcdi = this.classConsumed.keySet().iterator();
504 while (lcdi.hasNext()) {
505 LibraryClassDescriptor lcd = lcdi.next();
506 if ((lcd.className != null) && lcd.className.equals(className)) {
507 return this.classConsumed.get(lcd);
508 }
509 }
510 return null;
511 }
512
513 private void removeInstance(String key) {
514 ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
515 //
516 // remove pcd information of instance from current ModuleSA
517 //
518 ffc.removePcdData(moduleKey, mi);
519 //
520 // remove class produced by this instance and add back these produced class to be bound.
521 //
522 Vector<LibraryClassDescriptor> clsProduced = getClassProduced(mi);
523 for (int i = 0; i < clsProduced.size(); ++i) {
524
525 classProduced.remove(clsProduced.get(i));
526 }
527 //
528 // remove class consumed by this instance. we do not need to bound it now.
529 //
530 String[] clsConsumed = getClassConsumed(mi);
531 for (int i = 0; i < clsConsumed.length; ++i) {
532 ArrayList<String> al = getConsumedBy (clsConsumed[i]);
533
534 if (al == null ) {
535 continue;
536 }
537 al.remove(key);
538
539 }
540
541 showClassToResolved();
542
543 }
544
545
546 private Vector<LibraryClassDescriptor> getClassProduced(ModuleIdentification mi){
547
548 Vector<LibraryClassDescriptor> clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
549 return clsProduced;
550 // String[] sClassProduced = new String[clsProduced.size()];
551 // for (int i = 0; i < clsProduced.size(); ++i) {
552 // sClassProduced[i] = clsProduced.get(i).className;
553 // }
554 // return sClassProduced;
555 }
556
557 private String[] getClassConsumed(ModuleIdentification mi){
558
559 Vector<LibraryClassDescriptor> clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
560 String[] sClassConsumed = new String[clsConsumed.size()];
561 for (int i = 0; i < clsConsumed.size(); ++i) {
562 sClassConsumed[i] = clsConsumed.get(i).className;
563 }
564 return sClassConsumed;
565 }
566
567 private void showClassToResolved(){
568 libClassTableModel.setRowCount(0);
569 libInstanceTableModel.setRowCount(0);
570 if (classConsumed == null || classConsumed.size() == 0) {
571 return;
572 }
573 Iterator<LibraryClassDescriptor> li = classConsumed.keySet().iterator();
574 while(li.hasNext()){
575 LibraryClassDescriptor lcd = li.next();
576 String[] s = {lcd.className, lcd.supArchs, lcd.supModTypes};
577 if (classConsumed.get(lcd) == null || classConsumed.get(lcd).size() == 0) {
578 continue;
579 }
580
581 if (!isBoundedClass(lcd)){
582 libClassTableModel.addRow(s);
583 }
584 }
585
586 }
587
588 private String getModuleArch () {
589 String arch = "";
590 String[] moduleInfo = moduleKey.split(" ");
591 for (int i = 4; i < moduleInfo.length; ++i) {
592 arch += moduleInfo[i];
593 arch += " ";
594 }
595 return arch.trim();
596 }
597 private void addLibInstance (ModuleIdentification libMi) throws Exception{
598
599 //
600 // Add pcd information of selected instance to current moduleSA
601 //
602 ffc.addFrameworkModulesPcdBuildDefs(libMi, getModuleArch(), ffc.getModuleSA(moduleKey));
603
604 ffc.genLibraryInstance(libMi, moduleKey);
605 }
606 /**
607 * This method initializes this
608 *
609 * @return void
610 */
611 private void initialize() {
612 this.setSize(877, 555);
613 this.setResizable(false);
614 this.centerWindow();
615 this.setModal(true);
616 this.setTitle("Module Settings");
617 this.setContentPane(getJContentPane());
618 }
619
620 /**
621 * This method initializes jContentPane
622 *
623 * @return javax.swing.JPanel
624 */
625 private JPanel getJContentPane() {
626 if (jContentPane == null) {
627 jContentPane = new JPanel();
628 jContentPane.setLayout(new BorderLayout());
629 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
630 jContentPane.add(getJPanelContentPaneSouth(), java.awt.BorderLayout.SOUTH);
631 }
632 return jContentPane;
633 }
634
635 /**
636 * This method initializes jTabbedPane
637 *
638 * @return javax.swing.JTabbedPane
639 */
640 private JTabbedPane getJTabbedPane() {
641 if (jTabbedPane == null) {
642 jTabbedPane = new JTabbedPane();
643 jTabbedPane.addTab("PCD Build Definition", null, getJPanelPcd(), null);
644 jTabbedPane.addTab("Libraries", null, getJPanelLibrary(), null);
645 jTabbedPane.addTab("FV Info", null, getJPanelModuleSaOpts(), null);
646 jTabbedPane.addTab("Custom Toolchain", null, getJPanelCustomToolChain(), null);
647
648 }
649 return jTabbedPane;
650 }
651
652 /**
653 * This method initializes jPanelPcd
654 *
655 * @return javax.swing.JPanel
656 */
657 private JPanel getJPanelPcd() {
658 if (jPanelPcd == null) {
659 jLabelPcdData = new JLabel();
660 jLabelPcdData.setText(" PCD Data");
661 jPanelPcd = new JPanel();
662 jPanelPcd.setLayout(new BorderLayout());
663 jPanelPcd.add(jLabelPcdData, java.awt.BorderLayout.NORTH);
664 jPanelPcd.add(getJScrollPaneTablePcd(), java.awt.BorderLayout.CENTER);
665 jPanelPcd.add(getJPanelPcdSouth(), java.awt.BorderLayout.SOUTH);
666 jPanelPcd.addComponentListener(new java.awt.event.ComponentAdapter() {
667 public void componentShown(java.awt.event.ComponentEvent e) {
668 initPcdBuildDefinition(moduleSaNum);
669 }
670 });
671
672 }
673 return jPanelPcd;
674 }
675
676 /**
677 * This method initializes jPanelLibrary
678 *
679 * @return javax.swing.JPanel
680 */
681 private JPanel getJPanelLibrary() {
682 if (jPanelLibrary == null) {
683 jPanelLibrary = new JPanel();
684 jPanelLibrary.setLayout(new BorderLayout());
685 jPanelLibrary.add(getJSplitPane(), java.awt.BorderLayout.NORTH);
686 jPanelLibrary.add(getJPanelLibrarySouth(), java.awt.BorderLayout.SOUTH);
687 jPanelLibrary.add(getJPanelLibraryCenter(), java.awt.BorderLayout.CENTER);
688 jPanelLibrary.addComponentListener(new java.awt.event.ComponentAdapter() {
689 public void componentShown(java.awt.event.ComponentEvent e) {
690 initLibraries(moduleKey);
691 }
692 });
693 }
694 return jPanelLibrary;
695 }
696
697 /**
698 * This method initializes jScrollPaneTablePcd
699 *
700 * @return javax.swing.JScrollPane
701 */
702 private JScrollPane getJScrollPaneTablePcd() {
703 if (jScrollPaneTablePcd == null) {
704 jScrollPaneTablePcd = new JScrollPane();
705 jScrollPaneTablePcd.setViewportView(getJTablePcd());
706 }
707 return jScrollPaneTablePcd;
708 }
709
710 /**
711 * This method initializes jTable
712 *
713 * @return javax.swing.JTable
714 */
715 private JTable getJTablePcd() {
716 if (jTablePcd == null) {
717 model = new IDefaultTableModel();
718 jTablePcd = new JTable(model);
719 jTablePcd.setRowHeight(20);
720 jTablePcd.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
721 model.addColumn("CName");
722 model.addColumn("TokenSpaceGUID");
723 model.addColumn("ItemType");
724 model.addColumn("Token");
725 model.addColumn("MaxDatumSize");
726 model.addColumn("DataType");
727 model.addColumn("DefaultValue");
728
729 jTablePcd.getColumnModel().getColumn(0).setMinWidth(250);
730
731 TableColumn tokenColumn = jTablePcd.getColumnModel().getColumn(3);
732 jTablePcd.removeColumn(tokenColumn);
733
734 jTablePcd.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
735 jTablePcd.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
736 public void valueChanged(ListSelectionEvent e) {
737
738 if (e.getValueIsAdjusting()){
739 return;
740 }
741 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
742 if (lsm.isSelectionEmpty()) {
743 return;
744 }
745 else{
746 int selectedRow = lsm.getMinSelectionIndex();
747 String cName = model.getValueAt(selectedRow, 0)+"";
748 String tsGuid = model.getValueAt(selectedRow, 1)+"";
749 String itemType = model.getValueAt(selectedRow, 2)+"";
750 //
751 // array for pcd related information: helpText, itemType, moduleType.
752 //
753 String[] pcdInfo = {"", "", ""};
754 Vector<String> validPcdTypes = new Vector<String>();
755 getPcdInfo(moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);
756 jTextAreaPcdHelp.setText(pcdInfo[0]);
757 initComboBox(pcdInfo[1], pcdInfo[2], validPcdTypes);
758 jComboBoxItemType.setSelectedItem(itemType);
759 jTextFieldMaxDatumSize.setEnabled(true);
760 jTextFieldMaxDatumSize.setVisible(true);
761 jTextFieldMaxDatumSize.setText(model.getValueAt(selectedRow, 4)+"");
762 jTextFieldPcdDefault.setEnabled(true);
763 jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+"");
764 if ((model.getValueAt(selectedRow, 5) != null) && model.getValueAt(selectedRow, 5).equals("VOID*")) {
765 if (pcdInfo[1].equals("FEATURE_FLAG")) {
766 jTextFieldMaxDatumSize.setVisible(false);
767 }
768 else if (pcdInfo[1].equals("FIXED_AT_BUILD")) {
769 try{
770 jTextFieldMaxDatumSize.setEnabled(false);
771 jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(selectedRow, 6)+"")+"");
772 }
773 catch(Exception except){
774 JOptionPane.showMessageDialog(FpdModuleSA.this, "Unacceptable PCD Value: " + except.getMessage());
775 }
776 }
777 else{
778 jTextFieldMaxDatumSize.setText(model.getValueAt(selectedRow, 4)+"");
779 }
780 }
781 else {
782 jTextFieldMaxDatumSize.setEnabled(false);
783 }
784
785 if (!model.getValueAt(selectedRow, 2).equals("DYNAMIC") && !model.getValueAt(selectedRow, 2).equals("DYNAMIC_EX")) {
786 jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+"");
787 if (model.getValueAt(selectedRow, 2).equals("FEATURE_FLAG")){
788 jTextFieldPcdDefault.setVisible(false);
789 jComboBoxFeatureFlagValue.setVisible(true);
790 jComboBoxFeatureFlagValue.setSelectedItem(model.getValueAt(selectedRow, 6)+"");
791 }
792 else{
793 jTextFieldPcdDefault.setVisible(true);
794 jTextFieldPcdDefault.setEnabled(true);
795 jComboBoxFeatureFlagValue.setVisible(false);
796 }
797 }
798 else{
799 jTextFieldPcdDefault.setEnabled(false);
800 }
801 }
802
803
804 }
805 });
806
807 }
808 return jTablePcd;
809 }
810
811 private void initComboBox(String originalType, String mType, Vector<String> validPcdTypes) {
812 jComboBoxItemType.removeAllItems();
813
814 if (originalType.equals("DYNAMIC")) {
815 for (int i = 0; i < validPcdTypes.size(); ++i) {
816 jComboBoxItemType.addItem(validPcdTypes.get(i));
817 }
818 }
819 else {
820 jComboBoxItemType.addItem(originalType);
821 }
822 }
823
824 /**
825 * @param cName
826 * @param tsGuid
827 * @param sa sa[0]: HelpText; sa[1]: itemType in Msa; sa[2]: isBinary;
828 */
829 private void getPcdInfo(String moduleKey, String cName, String tsGuid, String[] sa, Vector<String> validPcdTypes) {
830 String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];
831 ffc.getLibraryInstances(moduleKey, saa);
832
833 try{
834 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa, validPcdTypes)) {
835 return;
836 }
837 for (int j = 0; j < saa.length; ++j) {
838 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
839 cName, tsGuid, sa, validPcdTypes)) {
840 return;
841 }
842 }
843 }
844 catch(Exception e) {
845 JOptionPane.showMessageDialog(this, "Get PCD details fail: " + e.getMessage());
846 }
847 }
848
849 /**
850 * This method initializes jPanelPcdSouth
851 *
852 * @return javax.swing.JPanel
853 */
854 private JPanel getJPanelPcdSouth() {
855 if (jPanelPcdSouth == null) {
856 jLabelPcdHelp = new JLabel();
857 jLabelPcdHelp.setText("PCD Description");
858 jPanelPcdSouth = new JPanel();
859 jPanelPcdSouth.setPreferredSize(new java.awt.Dimension(607,200));
860 jPanelPcdSouth.add(jLabelPcdHelp, null);
861 jPanelPcdSouth.add(getJScrollPanePcdHelp(), null);
862 jPanelPcdSouth.add(getJPanelPcdFields(), null);
863 }
864 return jPanelPcdSouth;
865 }
866
867 /**
868 * This method initializes jScrollPanePcdHelp
869 *
870 * @return javax.swing.JScrollPane
871 */
872 private JScrollPane getJScrollPanePcdHelp() {
873 if (jScrollPanePcdHelp == null) {
874 jScrollPanePcdHelp = new JScrollPane();
875 jScrollPanePcdHelp.setPreferredSize(new java.awt.Dimension(500,100));
876 jScrollPanePcdHelp.setViewportView(getJTextAreaPcdHelp());
877 }
878 return jScrollPanePcdHelp;
879 }
880
881 /**
882 * This method initializes jTextAreaPcdHelp
883 *
884 * @return javax.swing.JTextArea
885 */
886 private JTextArea getJTextAreaPcdHelp() {
887 if (jTextAreaPcdHelp == null) {
888 jTextAreaPcdHelp = new JTextArea();
889 jTextAreaPcdHelp.setEditable(false);
890 }
891 return jTextAreaPcdHelp;
892 }
893
894 /**
895 * This method initializes jPanelContentPaneSouth
896 *
897 * @return javax.swing.JPanel
898 */
899 private JPanel getJPanelContentPaneSouth() {
900 if (jPanelContentPaneSouth == null) {
901 FlowLayout flowLayout = new FlowLayout();
902 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
903 jPanelContentPaneSouth = new JPanel();
904 jPanelContentPaneSouth.setLayout(flowLayout);
905 jPanelContentPaneSouth.add(getJButtonOk(), null);
906 jPanelContentPaneSouth.add(getJButtonCancel(), null);
907 }
908 return jPanelContentPaneSouth;
909 }
910
911 /**
912 * This method initializes jSplitPane
913 *
914 * @return javax.swing.JSplitPane
915 */
916 private JSplitPane getJSplitPane() {
917 if (jSplitPane == null) {
918 jSplitPane = new JSplitPane();
919 jSplitPane.setDividerLocation(200);
920 jSplitPane.setLeftComponent(getJPanelLibraryLeft());
921 jSplitPane.setRightComponent(getJPanelLibraryRight());
922 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
923 }
924 return jSplitPane;
925 }
926
927 /**
928 * This method initializes jPanelLibraryLeft
929 *
930 * @return javax.swing.JPanel
931 */
932 private JPanel getJPanelLibraryLeft() {
933 if (jPanelLibraryLeft == null) {
934 jLabelLibClass = new JLabel();
935 jLabelLibClass.setText("Library Classes Uninstantiated");
936 jPanelLibraryLeft = new JPanel();
937 jPanelLibraryLeft.add(jLabelLibClass, null);
938 jPanelLibraryLeft.add(getJScrollPaneLibClass(), null);
939 }
940 return jPanelLibraryLeft;
941 }
942
943 /**
944 * This method initializes jPanelLibraryRight
945 *
946 * @return javax.swing.JPanel
947 */
948 private JPanel getJPanelLibraryRight() {
949 if (jPanelLibraryRight == null) {
950 jLabelQualifiedInstance = new JLabel();
951 jLabelQualifiedInstance.setText("Instances Available");
952 jPanelLibraryRight = new JPanel();
953 jPanelLibraryRight.add(jLabelQualifiedInstance, null);
954 jPanelLibraryRight.add(getJScrollPaneQualifiedInstance(), null);
955 }
956 return jPanelLibraryRight;
957 }
958
959 /**
960 * This method initializes jScrollPaneSelectedInstances
961 *
962 * @return javax.swing.JScrollPane
963 */
964 private JScrollPane getJScrollPaneSelectedInstances() {
965 if (jScrollPaneSelectedInstances == null) {
966 jScrollPaneSelectedInstances = new JScrollPane();
967 jScrollPaneSelectedInstances.setPreferredSize(new java.awt.Dimension(600,150));
968 jScrollPaneSelectedInstances.setViewportView(getJTableSelectedInstances());
969 }
970 return jScrollPaneSelectedInstances;
971 }
972
973 /**
974 * This method initializes jTableSelectedInstances
975 *
976 * @return javax.swing.JTable
977 */
978 private JTable getJTableSelectedInstances() {
979 if (jTableSelectedInstances == null) {
980 selectedInstancesTableModel = new IDefaultTableModel();
981 selectedInstancesTableModel.addColumn("Name");
982 selectedInstancesTableModel.addColumn("ModuleGUID");
983 selectedInstancesTableModel.addColumn("ModuleVersion");
984 selectedInstancesTableModel.addColumn("PackageGUID");
985 selectedInstancesTableModel.addColumn("PackageVersion");
986 jTableSelectedInstances = new JTable(selectedInstancesTableModel);
987 jTableSelectedInstances.setRowHeight(20);
988
989 jTableSelectedInstances.getColumnModel().getColumn(0).setMinWidth(250);
990
991 jTableSelectedInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
992 jTableSelectedInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
993
994 }
995 return jTableSelectedInstances;
996 }
997
998 /**
999 * This method initializes jScrollPaneLibClass
1000 *
1001 * @return javax.swing.JScrollPane
1002 */
1003 private JScrollPane getJScrollPaneLibClass() {
1004 if (jScrollPaneLibClass == null) {
1005 jScrollPaneLibClass = new JScrollPane();
1006 jScrollPaneLibClass.setPreferredSize(new java.awt.Dimension(200,170));
1007 jScrollPaneLibClass.setViewportView(getJTableLibClass());
1008 }
1009 return jScrollPaneLibClass;
1010 }
1011
1012 /**
1013 * This method initializes jTableLibClass
1014 *
1015 * @return javax.swing.JTable
1016 */
1017 private JTable getJTableLibClass() {
1018 if (jTableLibClass == null) {
1019 libClassTableModel = new IDefaultTableModel();
1020 libClassTableModel.addColumn("LibraryClass");
1021 libClassTableModel.addColumn("Arch");
1022 libClassTableModel.addColumn("ModType");
1023 jTableLibClass = new JTable(libClassTableModel);
1024 jTableLibClass.setRowHeight(20);
1025 jTableLibClass.setShowGrid(false);
1026 jTableLibClass.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1027
1028 TableColumn column = jTableLibClass.getColumnModel().getColumn(1);
1029 jTableLibClass.getColumnModel().removeColumn(column);
1030 column = jTableLibClass.getColumnModel().getColumn(1);
1031 jTableLibClass.getColumnModel().removeColumn(column);
1032
1033 jTableLibClass.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
1034 public void valueChanged(ListSelectionEvent e) {
1035 if (e.getValueIsAdjusting()){
1036 return;
1037 }
1038 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
1039 if (lsm.isSelectionEmpty()) {
1040 return;
1041 }
1042 else{
1043 int selectedRow2 = lsm.getMinSelectionIndex();
1044 if (selectedRow2 < 0) {
1045 return;
1046 }
1047 //
1048 // display potential lib instances according to class selection
1049 //
1050 libInstanceTableModel.setRowCount(0);
1051 String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();
1052 String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString();
1053 String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString();
1054 ArrayList<String> al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType));
1055 if (al == null) {
1056 return;
1057 }
1058 ListIterator<String> li = al.listIterator();
1059 while(li.hasNext()) {
1060 String instance = li.next();
1061 String[] s = {"", "", "", "", ""};
1062 if (WorkspaceProfile.getModuleId(instance) != null) {
1063 s[0] = WorkspaceProfile.getModuleId(instance).getName();
1064 }
1065
1066 String[] instancePart = instance.split(" ");
1067 for (int i = 0; i < instancePart.length; ++i){
1068 s[i+1] = instancePart[i];
1069 }
1070 libInstanceTableModel.addRow(s);
1071 }
1072
1073 }
1074 }
1075 });
1076 }
1077 return jTableLibClass;
1078 }
1079
1080 /**
1081 * This method initializes jScrollPaneQualifiedInstance
1082 *
1083 * @return javax.swing.JScrollPane
1084 */
1085 private JScrollPane getJScrollPaneQualifiedInstance() {
1086 if (jScrollPaneQualifiedInstance == null) {
1087 jScrollPaneQualifiedInstance = new JScrollPane();
1088 jScrollPaneQualifiedInstance.setPreferredSize(new java.awt.Dimension(600,170));
1089 jScrollPaneQualifiedInstance.setViewportView(getJTableLibInstances());
1090 }
1091 return jScrollPaneQualifiedInstance;
1092 }
1093
1094 /**
1095 * This method initializes jTableLibInstances
1096 *
1097 * @return javax.swing.JTable
1098 */
1099 private JTable getJTableLibInstances() {
1100 if (jTableLibInstances == null) {
1101 libInstanceTableModel = new IDefaultTableModel();
1102 libInstanceTableModel.addColumn("Name");
1103 libInstanceTableModel.addColumn("ModuleGUID");
1104 libInstanceTableModel.addColumn("ModuleVersion");
1105 libInstanceTableModel.addColumn("PackageGUID");
1106 libInstanceTableModel.addColumn("PackageVersion");
1107 jTableLibInstances = new JTable(libInstanceTableModel);
1108 jTableLibInstances.setRowHeight(20);
1109
1110 jTableLibInstances.getColumnModel().getColumn(0).setMinWidth(250);
1111
1112 jTableLibInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
1113 jTableLibInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1114
1115 }
1116 return jTableLibInstances;
1117 }
1118
1119 /**
1120 * This method initializes jPanelLibrarySouth
1121 *
1122 * @return javax.swing.JPanel
1123 */
1124 private JPanel getJPanelLibrarySouth() {
1125 if (jPanelLibrarySouth == null) {
1126 jPanelLibrarySouth = new JPanel();
1127 }
1128 return jPanelLibrarySouth;
1129 }
1130
1131 /**
1132 * This method initializes jPanelLibraryCenter
1133 *
1134 * @return javax.swing.JPanel
1135 */
1136 private JPanel getJPanelLibraryCenter() {
1137 if (jPanelLibraryCenter == null) {
1138 jLabelInstanceHelp = new JLabel();
1139 jLabelInstanceHelp.setText("Instance Description");
1140 jLabelSelectedInstances = new JLabel();
1141 jLabelSelectedInstances.setText("Selected Instances");
1142 jPanelLibraryCenter = new JPanel();
1143 jPanelLibraryCenter.setLayout(new BorderLayout());
1144
1145 jPanelLibraryCenter.add(getJPanelLibraryCenterC(), java.awt.BorderLayout.CENTER);
1146 jPanelLibraryCenter.add(getJPanelLibraryCenterN(), java.awt.BorderLayout.NORTH);
1147
1148 }
1149 return jPanelLibraryCenter;
1150 }
1151
1152 /**
1153 * This method initializes jScrollPaneInstanceHelp
1154 *
1155 * @return javax.swing.JScrollPane
1156 */
1157 private JScrollPane getJScrollPaneInstanceHelp() {
1158 if (jScrollPaneInstanceHelp == null) {
1159 jScrollPaneInstanceHelp = new JScrollPane();
1160 jScrollPaneInstanceHelp.setPreferredSize(new java.awt.Dimension(400,50));
1161 jScrollPaneInstanceHelp.setViewportView(getJTextAreaInstanceHelp());
1162 }
1163 return jScrollPaneInstanceHelp;
1164 }
1165
1166 /**
1167 * This method initializes jTextAreaInstanceHelp
1168 *
1169 * @return javax.swing.JTextArea
1170 */
1171 private JTextArea getJTextAreaInstanceHelp() {
1172 if (jTextAreaInstanceHelp == null) {
1173 jTextAreaInstanceHelp = new JTextArea();
1174 jTextAreaInstanceHelp.setEditable(false);
1175 }
1176 return jTextAreaInstanceHelp;
1177 }
1178
1179 /**
1180 * This method initializes jButtonAdd
1181 *
1182 * @return javax.swing.JButton
1183 */
1184 private JButton getJButtonAdd() {
1185 if (jButtonAdd == null) {
1186 jButtonAdd = new JButton();
1187 jButtonAdd.setPreferredSize(new java.awt.Dimension(80,20));
1188 jButtonAdd.setText("Add");
1189 jButtonAdd.addActionListener(new java.awt.event.ActionListener() {
1190 public void actionPerformed(java.awt.event.ActionEvent e) {
1191 int row = jTableLibInstances.getSelectedRow();
1192 if (row < 0) {
1193 return;
1194 }
1195
1196 String instanceValue = libInstanceTableModel.getValueAt(row, 1) + " " +
1197 libInstanceTableModel.getValueAt(row, 2) + " " +
1198 libInstanceTableModel.getValueAt(row, 3) + " " +
1199 libInstanceTableModel.getValueAt(row, 4);
1200 ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceValue);
1201 try {
1202 addLibInstance (libMi);
1203 }
1204 catch (Exception exception) {
1205 JOptionPane.showMessageDialog(FpdModuleSA.this, "Adding Instance " + libMi.getName() + " : \n"+ exception.getMessage());
1206 return;
1207 }
1208 docConsole.setSaved(false);
1209 Object[] s = {libInstanceTableModel.getValueAt(row, 0), libInstanceTableModel.getValueAt(row, 1),
1210 libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),
1211 libInstanceTableModel.getValueAt(row, 4)};
1212 selectedInstancesTableModel.addRow(s);
1213
1214 Vector<String> errorMsg = new Vector<String>();
1215 try {
1216 resolveLibraryInstances(instanceValue, errorMsg);
1217 }
1218 catch (Exception exp) {
1219 JOptionPane.showMessageDialog(FpdModuleSA.this, exp.getMessage());
1220 }
1221
1222 if (errorMsg.size() > 0) {
1223 String errors = "";
1224 for (int i = 0; i < errorMsg.size(); ++i) {
1225 errors += " " + errorMsg.get(i) + "\n";
1226 }
1227 JOptionPane.showMessageDialog(FpdModuleSA.this, errors);
1228 }
1229 showClassToResolved();
1230 }
1231 });
1232 }
1233 return jButtonAdd;
1234 }
1235
1236 /**
1237 * This method initializes jButton1
1238 *
1239 * @return javax.swing.JButton
1240 */
1241 private JButton getJButtonDeleteInstance() {
1242 if (jButtonDeleteInstance == null) {
1243 jButtonDeleteInstance = new JButton();
1244 jButtonDeleteInstance.setPreferredSize(new java.awt.Dimension(80,20));
1245 jButtonDeleteInstance.setText("Delete");
1246 jButtonDeleteInstance.addActionListener(new java.awt.event.ActionListener() {
1247 public void actionPerformed(java.awt.event.ActionEvent e) {
1248 int row = jTableSelectedInstances.getSelectedRow();
1249 if (row < 0) {
1250 return;
1251 }
1252 docConsole.setSaved(false);
1253 removeInstance(selectedInstancesTableModel.getValueAt(row, 1) + " " +
1254 selectedInstancesTableModel.getValueAt(row, 2) + " " +
1255 selectedInstancesTableModel.getValueAt(row, 3) + " " +
1256 selectedInstancesTableModel.getValueAt(row, 4));
1257 ffc.removeLibraryInstance(moduleKey, row);
1258 selectedInstancesTableModel.removeRow(row);
1259
1260 }
1261 });
1262 }
1263 return jButtonDeleteInstance;
1264 }
1265
1266 /**
1267 * This method initializes jButton2
1268 *
1269 * @return javax.swing.JButton
1270 */
1271 private JButton getJButtonOk() {
1272 if (jButtonOk == null) {
1273 jButtonOk = new JButton();
1274 jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
1275 jButtonOk.setText("Close");
1276 jButtonOk.addActionListener(this);
1277 }
1278 return jButtonOk;
1279 }
1280
1281 /**
1282 * This method initializes jButton3
1283 *
1284 * @return javax.swing.JButton
1285 */
1286 private JButton getJButtonCancel() {
1287 if (jButtonCancel == null) {
1288 jButtonCancel = new JButton();
1289 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
1290 jButtonCancel.setText("Cancel");
1291 jButtonCancel.setVisible(false);
1292 }
1293 return jButtonCancel;
1294 }
1295 public void actionPerformed(ActionEvent arg0) {
1296
1297 if (arg0.getSource() == jButtonOk) {
1298 if (jTableModuleSaOptions.isEditing()) {
1299 jTableModuleSaOptions.getCellEditor().stopCellEditing();
1300 }
1301 this.setVisible(false);
1302 }
1303 }
1304 /**
1305 * This method initializes jPanelModuleSaOpts
1306 *
1307 * @return javax.swing.JPanel
1308 */
1309 private JPanel getJPanelModuleSaOpts() {
1310 if (jPanelModuleSaOpts == null) {
1311 FlowLayout flowLayout4 = new FlowLayout();
1312 flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
1313 jLabelFfsFormatKey = new JLabel();
1314 jLabelFfsFormatKey.setText("FFS Format Key");
1315 jLabelFfsFormatKey.setPreferredSize(new java.awt.Dimension(90,16));
1316 jLabelFfsFileGuid = new JLabel();
1317 jLabelFfsFileGuid.setText("FFS File GUID");
1318 jLabelFfsFileGuid.setPreferredSize(new java.awt.Dimension(90,16));
1319 jLabelFfsFileGuid.setVisible(false);
1320 jLabelFvBinding = new JLabel();
1321 jLabelFvBinding.setText("FV Binding");
1322 jLabelFvBinding.setPreferredSize(new java.awt.Dimension(90,16));
1323 jPanelModuleSaOpts = new JPanel();
1324 jPanelModuleSaOpts.setLayout(flowLayout4);
1325 jPanelModuleSaOpts.add(jLabelFvBinding, null);
1326 jPanelModuleSaOpts.add(getJTextFieldFvBinding(), null);
1327 jPanelModuleSaOpts.add(jLabelFfsFileGuid, null);
1328 jPanelModuleSaOpts.add(getJTextFieldFileGuid(), null);
1329 jPanelModuleSaOpts.add(jLabelFfsFormatKey, null);
1330 jPanelModuleSaOpts.add(getJTextFieldFfsKey(), null);
1331 jPanelModuleSaOpts.addComponentListener(new java.awt.event.ComponentAdapter() {
1332 public void componentShown(java.awt.event.ComponentEvent e) {
1333 initFvInfo(moduleKey);
1334 }
1335 });
1336 }
1337 return jPanelModuleSaOpts;
1338 }
1339
1340 private Vector<String> getVectorFromString (String s) {
1341 if (s == null || s.equals("null")) {
1342 s = "";
1343 }
1344 String[] sa1 = s.split(" ");
1345 Vector<String> v = new Vector<String>();
1346 for (int i = 0; i < sa1.length; ++i) {
1347 v.add(sa1[i]);
1348 }
1349 return v;
1350 }
1351
1352 /**
1353 * This method initializes jTextField
1354 *
1355 * @return javax.swing.JTextField
1356 */
1357 private JTextField getJTextFieldFvBinding() {
1358 if (jTextFieldFvBinding == null) {
1359 jTextFieldFvBinding = new JTextField();
1360 jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(400,20));
1361 jTextFieldFvBinding.setEditable(true);
1362 jTextFieldFvBinding.addFocusListener(new java.awt.event.FocusAdapter() {
1363 public void focusLost(java.awt.event.FocusEvent e) {
1364 String originalFvBinding = ffc.getFvBinding(moduleKey);
1365 String newFvBinding = jTextFieldFvBinding.getText();
1366 if (newFvBinding.equals(originalFvBinding)) {
1367 return;
1368 }
1369 if (newFvBinding.length() == 0 && originalFvBinding == null) {
1370 return;
1371 }
1372
1373 Vector<String> oldFvList = getVectorFromString (originalFvBinding);
1374 Vector<String> newFvList = getVectorFromString (newFvBinding);
1375 String moduleInfo[] = moduleKey.split(" ");
1376 ffc.setFvBinding(moduleKey, newFvBinding);
1377 //
1378 // remove module from Fvs that not in newFvList now.
1379 //
1380 oldFvList.removeAll(newFvList);
1381 for (int j = 0; j < oldFvList.size(); ++j) {
1382 ffc.removeModuleInBuildOptionsUserExtensions(oldFvList.get(j), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
1383 }
1384 //
1385 // add module to Fvs that were not in oldFvList.
1386 //
1387 oldFvList = getVectorFromString (originalFvBinding);
1388 newFvList.removeAll(oldFvList);
1389 for (int i = 0; i < newFvList.size(); ++i) {
1390 ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
1391 }
1392 docConsole.setSaved(false);
1393 }
1394 });
1395
1396 }
1397 return jTextFieldFvBinding;
1398 }
1399 /**
1400 * This method initializes jTextField1
1401 *
1402 * @return javax.swing.JTextField
1403 */
1404 private JTextField getJTextFieldFileGuid() {
1405 if (jTextFieldFileGuid == null) {
1406 jTextFieldFileGuid = new JTextField();
1407 jTextFieldFileGuid.setPreferredSize(new java.awt.Dimension(300,20));
1408 jTextFieldFileGuid.setVisible(false);
1409 jTextFieldFileGuid.addFocusListener(new java.awt.event.FocusAdapter() {
1410 public void focusLost(java.awt.event.FocusEvent e) {
1411 String originalFileGuid = ffc.getFfsFileNameGuid(moduleKey);
1412 String newFileGuid = jTextFieldFileGuid.getText();
1413 if (newFileGuid.equals(originalFileGuid)) {
1414 return;
1415 }
1416 if (newFileGuid.length() == 0 && originalFileGuid == null) {
1417 return;
1418 }
1419 if (newFileGuid.length() > 0) {
1420 if (!DataValidation.isGuid(newFileGuid)) {
1421 JOptionPane.showMessageDialog(FpdModuleSA.this, "FFS File Guid is NOT GUID Type.");
1422 return;
1423 }
1424 }
1425
1426 docConsole.setSaved(false);
1427 if (newFileGuid.length() == 0) {
1428 newFileGuid = null;
1429 }
1430 ffc.setFfsFileNameGuid(moduleKey, newFileGuid);
1431 }
1432 });
1433
1434 }
1435 return jTextFieldFileGuid;
1436 }
1437 /**
1438 * This method initializes jTextFieldFfsKey
1439 *
1440 * @return javax.swing.JTextField
1441 */
1442 private JTextField getJTextFieldFfsKey() {
1443 if (jTextFieldFfsKey == null) {
1444 jTextFieldFfsKey = new JTextField();
1445 jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(250,20));
1446 jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {
1447 public void focusLost(java.awt.event.FocusEvent e) {
1448 String originalFfsKey = ffc.getFfsFormatKey(moduleKey);
1449 String newFfsKey = jTextFieldFfsKey.getText();
1450 if (newFfsKey.equals(originalFfsKey)) {
1451 return;
1452 }
1453 if (newFfsKey.length() == 0 && originalFfsKey == null) {
1454 return;
1455 }
1456 docConsole.setSaved(false);
1457 ffc.setFfsFormatKey(moduleKey, newFfsKey);
1458 }
1459 });
1460
1461 }
1462 return jTextFieldFfsKey;
1463 }
1464 /**
1465 * This method initializes jScrollPaneModuleSaOptions
1466 *
1467 * @return javax.swing.JScrollPane
1468 */
1469 private JScrollPane getJScrollPaneModuleSaOptions() {
1470 if (jScrollPaneModuleSaOptions == null) {
1471 jScrollPaneModuleSaOptions = new JScrollPane();
1472 jScrollPaneModuleSaOptions.setPreferredSize(new java.awt.Dimension(600,350));
1473 jScrollPaneModuleSaOptions.setViewportView(getJTableModuleSaOptions());
1474 }
1475 return jScrollPaneModuleSaOptions;
1476 }
1477 /**
1478 * This method initializes jTableModuleSaOptions
1479 *
1480 * @return javax.swing.JTable
1481 */
1482 private JTable getJTableModuleSaOptions() {
1483 if (jTableModuleSaOptions == null) {
1484 optionsTableModel = new DefaultTableModel();
1485 optionsTableModel.addColumn("BuildTargets");
1486 optionsTableModel.addColumn("ToolChainFamily");
1487 optionsTableModel.addColumn("TagName");
1488 optionsTableModel.addColumn("ToolCode");
1489 optionsTableModel.addColumn("SupportedArchs");
1490 optionsTableModel.addColumn("Contents");
1491 jTableModuleSaOptions = new JTable(optionsTableModel);
1492 jTableModuleSaOptions.setRowHeight(20);
1493
1494 jTableModuleSaOptions.getColumnModel().getColumn(0).setMinWidth(buildTargetWidth);
1495 jTableModuleSaOptions.getColumnModel().getColumn(1).setMinWidth(toolChainFamilyWidth);
1496 jTableModuleSaOptions.getColumnModel().getColumn(2).setMinWidth(tagNameWidth);
1497 jTableModuleSaOptions.getColumnModel().getColumn(3).setMinWidth(toolCmdCodeWidth);
1498 jTableModuleSaOptions.getColumnModel().getColumn(4).setMinWidth(supportArchWidth);
1499 jTableModuleSaOptions.getColumnModel().getColumn(5).setMinWidth(argWidth);
1500 // javax.swing.table.TableColumn toolFamilyCol = jTableModuleSaOptions.getColumnModel().getColumn(1);
1501 // JComboBox cb = new JComboBox();
1502 // cb.addItem("MSFT");
1503 // cb.addItem("GCC");
1504 // cb.addItem("CYGWIN");
1505 // cb.addItem("INTEL");
1506 // cb.addItem("USER_DEFINED");
1507 // toolFamilyCol.setCellEditor(new DefaultCellEditor(cb));
1508
1509 Vector<String> vArch = new Vector<String>();
1510 vArch.add("IA32");
1511 vArch.add("X64");
1512 vArch.add("IPF");
1513 vArch.add("EBC");
1514 vArch.add("ARM");
1515 vArch.add("PPC");
1516 jTableModuleSaOptions.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch, FrameworkWizardUI.getInstance()));
1517
1518 jTableModuleSaOptions.getColumnModel().getColumn(5).setCellEditor(new LongTextEditor(FrameworkWizardUI.getInstance()));
1519
1520 jTableModuleSaOptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1521 jTableModuleSaOptions.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
1522 jTableModuleSaOptions.getModel().addTableModelListener(new TableModelListener() {
1523 public void tableChanged(TableModelEvent arg0) {
1524 // TODO Auto-generated method stub
1525 int row = arg0.getFirstRow();
1526 TableModel m = (TableModel)arg0.getSource();
1527
1528 if (arg0.getType() == TableModelEvent.UPDATE){
1529 //ToDo Data Validition check.
1530 String targets = m.getValueAt(row, 0) + "";
1531 Vector<Object> targetName = null;
1532 if (targets.length() > 0) {
1533 targetName = new Vector<Object>();
1534 String[] sArray = targets.split(" ");
1535 for (int i = 0; i < sArray.length; ++i) {
1536 targetName.add(sArray[i]);
1537 }
1538 }
1539
1540 String toolChain = m.getValueAt(row, 1) + "";
1541 String tagName = m.getValueAt(row, 2) + "";
1542 String toolCode = m.getValueAt(row, 3) + "";
1543 String archs = m.getValueAt(row, 4) + "";
1544 Vector<Object> supArch = null;
1545 if (archs.length() > 0) {
1546 supArch = new Vector<Object>();
1547 String[] sArray1 = archs.split(" ");
1548 for (int i = 0; i < sArray1.length; ++i) {
1549 supArch.add(sArray1[i]);
1550 }
1551 }
1552
1553 String contents = m.getValueAt(row, 5) + "";
1554 docConsole.setSaved(false);
1555 ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);
1556 }
1557 }
1558 });
1559 }
1560 return jTableModuleSaOptions;
1561 }
1562 /**
1563 * This method initializes jButtonNew
1564 *
1565 * @return javax.swing.JButton
1566 */
1567 private JButton getJButtonNew() {
1568 if (jButtonNew == null) {
1569 jButtonNew = new JButton();
1570 jButtonNew.setPreferredSize(new java.awt.Dimension(80,20));
1571 jButtonNew.setText("New");
1572 jButtonNew.addActionListener(new java.awt.event.ActionListener() {
1573 public void actionPerformed(java.awt.event.ActionEvent e) {
1574 String[] row = {"", "", "", "", "", ""};
1575 optionsTableModel.addRow(row);
1576 Vector<Object> v = null;
1577 Vector<Object> v1 = null;
1578 docConsole.setSaved(false);
1579 ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");
1580 }
1581 });
1582 }
1583 return jButtonNew;
1584 }
1585 /**
1586 * This method initializes jButtonDelete
1587 *
1588 * @return javax.swing.JButton
1589 */
1590 private JButton getJButtonDeleteOption() {
1591 if (jButtonDeleteOption == null) {
1592 jButtonDeleteOption = new JButton();
1593 jButtonDeleteOption.setPreferredSize(new java.awt.Dimension(80,20));
1594 jButtonDeleteOption.setText("Delete");
1595 jButtonDeleteOption.addActionListener(new java.awt.event.ActionListener() {
1596 public void actionPerformed(java.awt.event.ActionEvent e) {
1597 if (jTableModuleSaOptions.getSelectedRow() < 0) {
1598 return;
1599 }
1600 docConsole.setSaved(false);
1601 ffc.removeModuleSAOptionsOpt(moduleKey, jTableModuleSaOptions.getSelectedRow());
1602 optionsTableModel.removeRow(jTableModuleSaOptions.getSelectedRow());
1603 }
1604 });
1605 }
1606 return jButtonDeleteOption;
1607 }
1608
1609 /**
1610 Start the window at the center of screen
1611
1612 **/
1613 protected void centerWindow(int intWidth, int intHeight) {
1614 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
1615 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
1616 }
1617
1618 /**
1619 Start the window at the center of screen
1620
1621 **/
1622 protected void centerWindow() {
1623 centerWindow(this.getSize().width, this.getSize().height);
1624 }
1625 /**
1626 * This method initializes jPanelPcdFields
1627 *
1628 * @return javax.swing.JPanel
1629 */
1630 private JPanel getJPanelPcdFields() {
1631 if (jPanelPcdFields == null) {
1632 GridLayout gridLayout = new GridLayout();
1633 gridLayout.setRows(3);
1634 gridLayout.setColumns(2);
1635 jPanelPcdFields = new JPanel();
1636 jPanelPcdFields.setLayout(gridLayout);
1637 jPanelPcdFields.setPreferredSize(new java.awt.Dimension(600,90));
1638 jPanelPcdFields.add(getJPanelPcdFieldsFirstRow(), null);
1639 jPanelPcdFields.add(getJPanelPcdFieldsSecondRow(), null);
1640 jPanelPcdFields.add(getJPanelPcdFieldsThirdRow(), null);
1641 }
1642 return jPanelPcdFields;
1643 }
1644 /**
1645 * This method initializes jPanelPcdFieldsSecondRow
1646 *
1647 * @return javax.swing.JPanel
1648 */
1649 private JPanel getJPanelPcdFieldsSecondRow() {
1650 if (jPanelPcdFieldsSecondRow == null) {
1651 FlowLayout flowLayout2 = new FlowLayout();
1652 flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
1653 jLabelMaxDatumSize = new JLabel();
1654 jLabelMaxDatumSize.setText("Max Datum Size");
1655 jPanelPcdFieldsSecondRow = new JPanel();
1656 jPanelPcdFieldsSecondRow.setLayout(flowLayout2);
1657 jPanelPcdFieldsSecondRow.add(jLabelMaxDatumSize, null);
1658 jPanelPcdFieldsSecondRow.add(getJTextFieldMaxDatumSize(), null);
1659 }
1660 return jPanelPcdFieldsSecondRow;
1661 }
1662 /**
1663 * This method initializes jPanelPcdFieldsThirdRow
1664 *
1665 * @return javax.swing.JPanel
1666 */
1667 private JPanel getJPanelPcdFieldsThirdRow() {
1668 if (jPanelPcdFieldsThirdRow == null) {
1669 FlowLayout flowLayout3 = new FlowLayout();
1670 flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
1671 jLabelPcdDefaultValue = new JLabel();
1672 jLabelPcdDefaultValue.setText("Default Value");
1673 jLabelPcdDefaultValue.setPreferredSize(new java.awt.Dimension(91,16));
1674 jPanelPcdFieldsThirdRow = new JPanel();
1675 jPanelPcdFieldsThirdRow.setLayout(flowLayout3);
1676 jPanelPcdFieldsThirdRow.add(jLabelPcdDefaultValue, null);
1677 jPanelPcdFieldsThirdRow.add(getJTextFieldPcdDefault(), null);
1678 jPanelPcdFieldsThirdRow.add(getJComboBoxFeatureFlagValue(), null);
1679 jPanelPcdFieldsThirdRow.add(getJButtonUpdatePcd(), null);
1680 }
1681 return jPanelPcdFieldsThirdRow;
1682 }
1683 /**
1684 * This method initializes jPanelPcdFieldsFirstRow
1685 *
1686 * @return javax.swing.JPanel
1687 */
1688 private JPanel getJPanelPcdFieldsFirstRow() {
1689 if (jPanelPcdFieldsFirstRow == null) {
1690 FlowLayout flowLayout1 = new FlowLayout();
1691 flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
1692 jLabelItemType = new JLabel();
1693 jLabelItemType.setText("Item Type");
1694 jLabelItemType.setPreferredSize(new java.awt.Dimension(91,16));
1695 jPanelPcdFieldsFirstRow = new JPanel();
1696 jPanelPcdFieldsFirstRow.setLayout(flowLayout1);
1697 jPanelPcdFieldsFirstRow.add(jLabelItemType, null);
1698 jPanelPcdFieldsFirstRow.add(getJComboBoxItemType(), null);
1699 }
1700 return jPanelPcdFieldsFirstRow;
1701 }
1702 /**
1703 * This method initializes jComboBoxItemType
1704 *
1705 * @return javax.swing.JComboBox
1706 */
1707 private JComboBox getJComboBoxItemType() {
1708 if (jComboBoxItemType == null) {
1709 jComboBoxItemType = new JComboBox();
1710 jComboBoxItemType.setPreferredSize(new java.awt.Dimension(200,20));
1711 jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() {
1712 public void itemStateChanged(java.awt.event.ItemEvent e) {
1713
1714 int row = jTablePcd.getSelectedRow();
1715 if (row < 0) {
1716 return;
1717 }
1718
1719 if (jComboBoxItemType.getSelectedItem() != null && jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {
1720 jTextFieldPcdDefault.setEnabled(true);
1721 }
1722 else {
1723 jTextFieldPcdDefault.setEnabled(false);
1724 }
1725 }
1726 });
1727 }
1728 return jComboBoxItemType;
1729 }
1730
1731 private void pcdDynamicToNonDynamic(String cName, String tsGuid) {
1732 String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];
1733 ffc.getDynamicPcdBuildData(saa);
1734 String maxSize = "";
1735 String value = "";
1736 for (int i = 0; i < saa.length; ++i) {
1737 if (saa[i][0].equals(cName) && saa[i][2].equals(tsGuid)) {
1738 maxSize = saa[i][3];
1739 value = ffc.getDynamicPcdBuildDataValue(i);
1740 break;
1741 }
1742 }
1743
1744 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1745 for (int i = 0; i < al.size(); ++i) {
1746 String mKey = moduleInfo (al.get(i));
1747 value = null;
1748 String itemType = jComboBoxItemType.getSelectedItem()+"";
1749 ffc.updatePcdData(mKey, cName, tsGuid, itemType, maxSize, value);
1750 al.set(i, mKey + " " + itemType);
1751 }
1752
1753 ffc.removeDynamicPcdBuildData(cName, tsGuid);
1754 }
1755
1756 private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
1757 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1758 for (int i = 0; i < al.size(); ++i) {
1759 String mKey = moduleInfo (al.get(i));
1760 String itemType = jComboBoxItemType.getSelectedItem()+"";
1761 ffc.updatePcdData(mKey, cName, tsGuid, itemType, jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");
1762 al.set(i, mKey + " " + itemType);
1763 }
1764 try{
1765 ffc.addDynamicPcdBuildData(cName, model.getValueAt(jTablePcd.getSelectedRow(), 3), tsGuid, "DYNAMIC", model.getValueAt(jTablePcd.getSelectedRow(), 5)+"", jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");
1766 }
1767 catch(Exception e){
1768 JOptionPane.showMessageDialog(FpdModuleSA.this, "PCD value format: " + e.getMessage());
1769 }
1770 }
1771
1772 private void changePcdTypeWithinSameCategory (String cName, String tsGuid) {
1773 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1774 for (int i = 0; i < al.size(); ++i) {
1775 String mKey = moduleInfo (al.get(i));
1776 String itemType = jComboBoxItemType.getSelectedItem()+"";
1777 ffc.updatePcdData(mKey, cName, tsGuid, itemType, null, null);
1778 al.set(i, mKey + " " + itemType);
1779 }
1780 }
1781
1782 private String moduleInfo (String pcdInfo) {
1783
1784 return pcdInfo.substring(0, pcdInfo.lastIndexOf(" "));
1785 }
1786
1787 /**
1788 * This method initializes jTextFieldMaxDatumSize
1789 *
1790 * @return javax.swing.JTextField
1791 */
1792 private JTextField getJTextFieldMaxDatumSize() {
1793 if (jTextFieldMaxDatumSize == null) {
1794 jTextFieldMaxDatumSize = new JTextField();
1795 jTextFieldMaxDatumSize.setPreferredSize(new java.awt.Dimension(200,20));
1796 }
1797 return jTextFieldMaxDatumSize;
1798 }
1799 /**
1800 * This method initializes jTextField4
1801 *
1802 * @return javax.swing.JTextField
1803 */
1804 private JTextField getJTextFieldPcdDefault() {
1805 if (jTextFieldPcdDefault == null) {
1806 jTextFieldPcdDefault = new JTextField();
1807 jTextFieldPcdDefault.setPreferredSize(new java.awt.Dimension(200,20));
1808 }
1809 return jTextFieldPcdDefault;
1810 }
1811 /**
1812 * This method initializes jButton6
1813 *
1814 * @return javax.swing.JButton
1815 */
1816 private JButton getJButtonUpdatePcd() {
1817 if (jButtonUpdatePcd == null) {
1818 jButtonUpdatePcd = new JButton();
1819 jButtonUpdatePcd.setPreferredSize(new java.awt.Dimension(150,20));
1820 jButtonUpdatePcd.setText("Update PCD Data");
1821 jButtonUpdatePcd.addActionListener(new java.awt.event.ActionListener() {
1822 public void actionPerformed(java.awt.event.ActionEvent e) {
1823 int row = jTablePcd.getSelectedRow();
1824 if (row < 0) {
1825 return;
1826 }
1827
1828 String cName = model.getValueAt(row, 0)+"";
1829 String tsGuid = model.getValueAt(row, 1)+"";
1830 String oldItemType = model.getValueAt(row, 2)+"";
1831 String dataType = model.getValueAt(row, 5)+"";
1832 String newItemType = jComboBoxItemType.getSelectedItem()+"";
1833 String newValue = jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem()+"";
1834 if (newValue.length() == 0){
1835
1836 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {
1837 newValue = "0";
1838 }
1839 if (dataType.equals("BOOLEAN")){
1840 newValue = "FALSE";
1841 }
1842 if (dataType.equals("VOID*")) {
1843 newValue = "L\"\"";
1844 }
1845 }
1846
1847 String[] pcdInfo = {"", "", ""};
1848 Vector<String> validPcdTypes = new Vector<String>();
1849 getPcdInfo (moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);
1850 if (pcdInfo[1].equals("FIXED_AT_BUILD") && model.getValueAt(row, 5).equals("VOID*")) {
1851 try {
1852 jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(newValue)+"");
1853 }
1854 catch (Exception exp) {
1855 JOptionPane.showMessageDialog(FpdModuleSA.this, "PCD Value MalFormed: " + exp.getMessage());
1856 return;
1857 }
1858 }
1859 String newMaxDatumSize = jTextFieldMaxDatumSize.getText();
1860
1861 if (!newItemType.equals(oldItemType)) {
1862 Vector<ModuleIdentification> moduleInfo = new Vector<ModuleIdentification>();
1863 try {
1864 boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo);
1865 if (!changable) {
1866 JOptionPane.showMessageDialog(FpdModuleSA.this, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName());
1867 return;
1868 }
1869 }
1870 catch (Exception exp) {
1871 JOptionPane.showMessageDialog(FpdModuleSA.this, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage());
1872 return;
1873 }
1874
1875 if ((oldItemType.equals("DYNAMIC") || oldItemType.equals("DYNAMIC_EX")) && !newItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC_EX")) {
1876 pcdDynamicToNonDynamic(cName, tsGuid);
1877 }
1878 if (!oldItemType.equals("DYNAMIC") && !oldItemType.equals("DYNAMIC_EX") && (newItemType.equals("DYNAMIC") || newItemType.equals("DYNAMIC_EX"))) {
1879 pcdNonDynamicToDynamic(cName, tsGuid);
1880 }
1881 else {
1882 changePcdTypeWithinSameCategory (cName, tsGuid);
1883 }
1884 model.setValueAt(newItemType, row, 2);
1885 }
1886
1887 ffc.updatePcdData(moduleKey, cName, tsGuid, model.getValueAt(row, 2)+"", newMaxDatumSize, newValue);
1888 docConsole.setSaved(false);
1889 model.setValueAt(newValue, row, 6);
1890 model.setValueAt(newMaxDatumSize, row, 4);
1891
1892 }
1893 });
1894 }
1895 return jButtonUpdatePcd;
1896 }
1897
1898 private boolean itemTypeCouldBeChanged (String cName, String tsGuid, String newItemType, Vector<ModuleIdentification> mi) throws Exception{
1899 ArrayList<String> pcdConsumers = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1900 for (int i = 0; i < pcdConsumers.size(); ++i) {
1901 String consumerInfo = moduleInfo (pcdConsumers.get(i));
1902 mi.removeAllElements();
1903 mi.add(WorkspaceProfile.getModuleId(consumerInfo));
1904 String[] sa = {"", "", ""};
1905 Vector<String> validPcdTypes = new Vector<String>();
1906 getPcdInfo (consumerInfo, cName, tsGuid, sa, validPcdTypes);
1907 if (validPcdTypes.size() == 0) {
1908 return false;
1909 }
1910 if (!sa[1].equals("DYNAMIC")) {
1911 return false;
1912 }
1913 if (!validPcdTypes.contains(newItemType)) {
1914 return false;
1915 }
1916 }
1917 return true;
1918 }
1919
1920 /**
1921 * This method initializes jComboBoxFeatureFlagValue
1922 *
1923 * @return javax.swing.JComboBox
1924 */
1925 private JComboBox getJComboBoxFeatureFlagValue() {
1926 if (jComboBoxFeatureFlagValue == null) {
1927 jComboBoxFeatureFlagValue = new JComboBox();
1928 jComboBoxFeatureFlagValue.setPreferredSize(new java.awt.Dimension(100,20));
1929 jComboBoxFeatureFlagValue.setVisible(false);
1930 jComboBoxFeatureFlagValue.addItem("TRUE");
1931 jComboBoxFeatureFlagValue.addItem("FALSE");
1932 }
1933 return jComboBoxFeatureFlagValue;
1934 }
1935 /**
1936 * This method initializes jPanelCustomToolChain
1937 *
1938 * @return javax.swing.JPanel
1939 */
1940 private JPanel getJPanelCustomToolChain() {
1941 if (jPanelCustomToolChain == null) {
1942 jPanelCustomToolChain = new JPanel();
1943 jPanelCustomToolChain.setLayout(new BorderLayout());
1944 jPanelCustomToolChain.add(getJPanelToolchainS(), java.awt.BorderLayout.SOUTH);
1945 jPanelCustomToolChain.add(getJScrollPaneModuleSaOptions(), java.awt.BorderLayout.CENTER);
1946 jPanelCustomToolChain.addComponentListener(new java.awt.event.ComponentAdapter() {
1947 public void componentShown(java.awt.event.ComponentEvent e) {
1948 initToolChainOptions(moduleKey);
1949 }
1950 });
1951 }
1952 return jPanelCustomToolChain;
1953 }
1954 /**
1955 * This method initializes jPanelToolchainS
1956 *
1957 * @return javax.swing.JPanel
1958 */
1959 private JPanel getJPanelToolchainS() {
1960 if (jPanelToolchainS == null) {
1961 jPanelToolchainS = new JPanel();
1962 jPanelToolchainS.add(getJButtonNew(), null);
1963 jPanelToolchainS.add(getJButtonDeleteOption(), null);
1964 }
1965 return jPanelToolchainS;
1966 }
1967
1968 /**
1969 * This method initializes jPanelLibraryCenterN
1970 *
1971 * @return javax.swing.JPanel
1972 */
1973 private JPanel getJPanelLibraryCenterN() {
1974 if (jPanelLibraryCenterN == null) {
1975 FlowLayout flowLayout5 = new FlowLayout();
1976 flowLayout5.setAlignment(java.awt.FlowLayout.CENTER);
1977 flowLayout5.setHgap(10);
1978 jPanelLibraryCenterN = new JPanel();
1979 jPanelLibraryCenterN.setLayout(flowLayout5);
1980 jPanelLibraryCenterN.add(jLabelInstanceHelp, null);
1981 jPanelLibraryCenterN.add(getJScrollPaneInstanceHelp(), null);
1982 jPanelLibraryCenterN.add(getJButtonAdd(), null);
1983 jPanelLibraryCenterN.add(getJButtonDeleteInstance(), null);
1984 }
1985 return jPanelLibraryCenterN;
1986 }
1987 /**
1988 * This method initializes jPanelLibraryCenterC
1989 *
1990 * @return javax.swing.JPanel
1991 */
1992 private JPanel getJPanelLibraryCenterC() {
1993 if (jPanelLibraryCenterC == null) {
1994 jPanelLibraryCenterC = new JPanel();
1995 jPanelLibraryCenterC.add(jLabelSelectedInstances, null);
1996 jPanelLibraryCenterC.add(getJScrollPaneSelectedInstances(), null);
1997 }
1998 return jPanelLibraryCenterC;
1999 }
2000
2001
2002 } // @jve:decl-index=0:visual-constraint="10,10"
2003
2004 class MultipleInstanceException extends Exception {
2005
2006 /**
2007 *
2008 */
2009 private static final long serialVersionUID = -9148463005930920297L;
2010 private String className = null;
2011 private String libInstance1 = null;
2012 private String libInstance2 = null;
2013
2014 MultipleInstanceException (String libClass, String instance1, String instance2) {
2015 super();
2016 className = libClass;
2017 libInstance1 = instance1;
2018 libInstance2 = instance2;
2019 }
2020
2021 /* (non-Javadoc)
2022 * @see java.lang.Throwable#getMessage()
2023 */
2024 @Override
2025 public String getMessage() {
2026 // TODO Auto-generated method stub
2027 return " Library Class " + className + "is Produced by Two Instances: "
2028 + libInstance1 + " and " + libInstance2 + ". Platform Build will Fail.";
2029 }
2030
2031 }
2032
2033 class NoInstanceException extends Exception {
2034
2035 /**
2036 *
2037 */
2038 private static final long serialVersionUID = 1987122786598970598L;
2039
2040 private String className = null;
2041
2042 NoInstanceException (String libClass) {
2043 className = libClass;
2044 }
2045
2046 public String getMessage() {
2047 return "No Applicable Instance for Library Class " + className
2048 + ", Platform Build will Fail.";
2049 }
2050 }