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