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