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