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