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