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