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