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