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