579f56145a89104fee5dca26cd489b273181374e
[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.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
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 void addLibInstance (ModuleIdentification libMi) throws Exception{
584
585 //
586 // Add pcd information of selected instance to current moduleSA
587 //
588 ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));
589
590 ffc.genLibraryInstance(libMi, moduleKey);
591 }
592 /**
593 * This method initializes this
594 *
595 * @return void
596 */
597 private void initialize() {
598 this.setSize(877, 555);
599 this.setResizable(false);
600 this.centerWindow();
601 this.setModal(true);
602 this.setTitle("Module Settings");
603 this.setContentPane(getJContentPane());
604 }
605
606 /**
607 * This method initializes jContentPane
608 *
609 * @return javax.swing.JPanel
610 */
611 private JPanel getJContentPane() {
612 if (jContentPane == null) {
613 jContentPane = new JPanel();
614 jContentPane.setLayout(new BorderLayout());
615 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
616 jContentPane.add(getJPanelContentPaneSouth(), java.awt.BorderLayout.SOUTH);
617 }
618 return jContentPane;
619 }
620
621 /**
622 * This method initializes jTabbedPane
623 *
624 * @return javax.swing.JTabbedPane
625 */
626 private JTabbedPane getJTabbedPane() {
627 if (jTabbedPane == null) {
628 jTabbedPane = new JTabbedPane();
629 jTabbedPane.addTab("PCD Build Definition", null, getJPanelPcd(), null);
630 jTabbedPane.addTab("Libraries", null, getJPanelLibrary(), null);
631 jTabbedPane.addTab("FV Info", null, getJPanelModuleSaOpts(), null);
632 jTabbedPane.addTab("Custom Toolchain", null, getJPanelCustomToolChain(), null);
633
634 }
635 return jTabbedPane;
636 }
637
638 /**
639 * This method initializes jPanelPcd
640 *
641 * @return javax.swing.JPanel
642 */
643 private JPanel getJPanelPcd() {
644 if (jPanelPcd == null) {
645 jLabelPcdData = new JLabel();
646 jLabelPcdData.setText(" PCD Data");
647 jPanelPcd = new JPanel();
648 jPanelPcd.setLayout(new BorderLayout());
649 jPanelPcd.add(jLabelPcdData, java.awt.BorderLayout.NORTH);
650 jPanelPcd.add(getJScrollPaneTablePcd(), java.awt.BorderLayout.CENTER);
651 jPanelPcd.add(getJPanelPcdSouth(), java.awt.BorderLayout.SOUTH);
652 jPanelPcd.addComponentListener(new java.awt.event.ComponentAdapter() {
653 public void componentShown(java.awt.event.ComponentEvent e) {
654 initPcdBuildDefinition(moduleSaNum);
655 }
656 });
657
658 }
659 return jPanelPcd;
660 }
661
662 /**
663 * This method initializes jPanelLibrary
664 *
665 * @return javax.swing.JPanel
666 */
667 private JPanel getJPanelLibrary() {
668 if (jPanelLibrary == null) {
669 jPanelLibrary = new JPanel();
670 jPanelLibrary.setLayout(new BorderLayout());
671 jPanelLibrary.add(getJSplitPane(), java.awt.BorderLayout.NORTH);
672 jPanelLibrary.add(getJPanelLibrarySouth(), java.awt.BorderLayout.SOUTH);
673 jPanelLibrary.add(getJPanelLibraryCenter(), java.awt.BorderLayout.CENTER);
674 jPanelLibrary.addComponentListener(new java.awt.event.ComponentAdapter() {
675 public void componentShown(java.awt.event.ComponentEvent e) {
676 initLibraries(moduleKey);
677 }
678 });
679 }
680 return jPanelLibrary;
681 }
682
683 /**
684 * This method initializes jScrollPaneTablePcd
685 *
686 * @return javax.swing.JScrollPane
687 */
688 private JScrollPane getJScrollPaneTablePcd() {
689 if (jScrollPaneTablePcd == null) {
690 jScrollPaneTablePcd = new JScrollPane();
691 jScrollPaneTablePcd.setViewportView(getJTablePcd());
692 }
693 return jScrollPaneTablePcd;
694 }
695
696 /**
697 * This method initializes jTable
698 *
699 * @return javax.swing.JTable
700 */
701 private JTable getJTablePcd() {
702 if (jTablePcd == null) {
703 model = new IDefaultTableModel();
704 jTablePcd = new JTable(model);
705 jTablePcd.setRowHeight(20);
706 jTablePcd.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
707 model.addColumn("CName");
708 model.addColumn("TokenSpaceGUID");
709 model.addColumn("ItemType");
710 model.addColumn("Token");
711 model.addColumn("MaxDatumSize");
712 model.addColumn("DataType");
713 model.addColumn("DefaultValue");
714
715 jTablePcd.getColumnModel().getColumn(0).setMinWidth(250);
716
717 TableColumn tokenColumn = jTablePcd.getColumnModel().getColumn(3);
718 jTablePcd.removeColumn(tokenColumn);
719
720 jTablePcd.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
721 jTablePcd.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
722 public void valueChanged(ListSelectionEvent e) {
723
724 if (e.getValueIsAdjusting()){
725 return;
726 }
727 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
728 if (lsm.isSelectionEmpty()) {
729 return;
730 }
731 else{
732 int selectedRow = lsm.getMinSelectionIndex();
733 String cName = model.getValueAt(selectedRow, 0)+"";
734 String tsGuid = model.getValueAt(selectedRow, 1)+"";
735 String itemType = model.getValueAt(selectedRow, 2)+"";
736 //
737 // array for pcd related information: helpText, itemType, moduleType.
738 //
739 String[] pcdInfo = {"", "", ""};
740 Vector<String> validPcdTypes = new Vector<String>();
741 getPcdInfo(moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);
742 jTextAreaPcdHelp.setText(pcdInfo[0]);
743 initComboBox(pcdInfo[1], pcdInfo[2], validPcdTypes);
744 jComboBoxItemType.setSelectedItem(itemType);
745 jTextFieldMaxDatumSize.setEnabled(true);
746 jTextFieldMaxDatumSize.setVisible(true);
747 jTextFieldMaxDatumSize.setText(model.getValueAt(selectedRow, 4)+"");
748 jTextFieldPcdDefault.setEnabled(true);
749 jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+"");
750 if (model.getValueAt(selectedRow, 5).equals("VOID*")) {
751 if (pcdInfo[1].equals("FEATURE_FLAG")) {
752 jTextFieldMaxDatumSize.setVisible(false);
753 }
754 else if (pcdInfo[1].equals("FIXED_AT_BUILD")) {
755 try{
756 jTextFieldMaxDatumSize.setEnabled(false);
757 jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(selectedRow, 6)+"")+"");
758 }
759 catch(Exception except){
760 JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage());
761 }
762 }
763 else{
764 jTextFieldMaxDatumSize.setText(model.getValueAt(selectedRow, 4)+"");
765 }
766 }
767 else {
768 jTextFieldMaxDatumSize.setEnabled(false);
769 }
770
771 if (!model.getValueAt(selectedRow, 2).equals("DYNAMIC") && !model.getValueAt(selectedRow, 2).equals("DYNAMIC_EX")) {
772 jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+"");
773 if (model.getValueAt(selectedRow, 2).equals("FEATURE_FLAG")){
774 jTextFieldPcdDefault.setVisible(false);
775 jComboBoxFeatureFlagValue.setVisible(true);
776 jComboBoxFeatureFlagValue.setSelectedItem(model.getValueAt(selectedRow, 6)+"");
777 }
778 else{
779 jTextFieldPcdDefault.setVisible(true);
780 jTextFieldPcdDefault.setEnabled(true);
781 jComboBoxFeatureFlagValue.setVisible(false);
782 }
783 }
784 else{
785 jTextFieldPcdDefault.setEnabled(false);
786 }
787 }
788
789
790 }
791 });
792
793 }
794 return jTablePcd;
795 }
796
797 private void initComboBox(String originalType, String mType, Vector<String> validPcdTypes) {
798 jComboBoxItemType.removeAllItems();
799
800 if (originalType.equals("DYNAMIC")) {
801 for (int i = 0; i < validPcdTypes.size(); ++i) {
802 jComboBoxItemType.addItem(validPcdTypes.get(i));
803 }
804 }
805 else {
806 jComboBoxItemType.addItem(originalType);
807 }
808 }
809
810 /**
811 * @param cName
812 * @param tsGuid
813 * @param sa sa[0]: HelpText; sa[1]: itemType in Msa; sa[2]: isBinary;
814 */
815 private void getPcdInfo(String moduleKey, String cName, String tsGuid, String[] sa, Vector<String> validPcdTypes) {
816 String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];
817 ffc.getLibraryInstances(moduleKey, saa);
818
819 try{
820 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa, validPcdTypes)) {
821 return;
822 }
823 for (int j = 0; j < saa.length; ++j) {
824 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
825 cName, tsGuid, sa, validPcdTypes)) {
826 return;
827 }
828 }
829 }
830 catch(Exception e) {
831 JOptionPane.showMessageDialog(this, "Get PCD details fail: " + e.getMessage());
832 }
833 }
834
835 /**
836 * This method initializes jPanelPcdSouth
837 *
838 * @return javax.swing.JPanel
839 */
840 private JPanel getJPanelPcdSouth() {
841 if (jPanelPcdSouth == null) {
842 jLabelPcdHelp = new JLabel();
843 jLabelPcdHelp.setText("PCD Description");
844 jPanelPcdSouth = new JPanel();
845 jPanelPcdSouth.setPreferredSize(new java.awt.Dimension(607,200));
846 jPanelPcdSouth.add(jLabelPcdHelp, null);
847 jPanelPcdSouth.add(getJScrollPanePcdHelp(), null);
848 jPanelPcdSouth.add(getJPanelPcdFields(), null);
849 }
850 return jPanelPcdSouth;
851 }
852
853 /**
854 * This method initializes jScrollPanePcdHelp
855 *
856 * @return javax.swing.JScrollPane
857 */
858 private JScrollPane getJScrollPanePcdHelp() {
859 if (jScrollPanePcdHelp == null) {
860 jScrollPanePcdHelp = new JScrollPane();
861 jScrollPanePcdHelp.setPreferredSize(new java.awt.Dimension(500,100));
862 jScrollPanePcdHelp.setViewportView(getJTextAreaPcdHelp());
863 }
864 return jScrollPanePcdHelp;
865 }
866
867 /**
868 * This method initializes jTextAreaPcdHelp
869 *
870 * @return javax.swing.JTextArea
871 */
872 private JTextArea getJTextAreaPcdHelp() {
873 if (jTextAreaPcdHelp == null) {
874 jTextAreaPcdHelp = new JTextArea();
875 jTextAreaPcdHelp.setEditable(false);
876 }
877 return jTextAreaPcdHelp;
878 }
879
880 /**
881 * This method initializes jPanelContentPaneSouth
882 *
883 * @return javax.swing.JPanel
884 */
885 private JPanel getJPanelContentPaneSouth() {
886 if (jPanelContentPaneSouth == null) {
887 FlowLayout flowLayout = new FlowLayout();
888 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
889 jPanelContentPaneSouth = new JPanel();
890 jPanelContentPaneSouth.setLayout(flowLayout);
891 jPanelContentPaneSouth.add(getJButtonOk(), null);
892 jPanelContentPaneSouth.add(getJButtonCancel(), null);
893 }
894 return jPanelContentPaneSouth;
895 }
896
897 /**
898 * This method initializes jSplitPane
899 *
900 * @return javax.swing.JSplitPane
901 */
902 private JSplitPane getJSplitPane() {
903 if (jSplitPane == null) {
904 jSplitPane = new JSplitPane();
905 jSplitPane.setDividerLocation(200);
906 jSplitPane.setLeftComponent(getJPanelLibraryLeft());
907 jSplitPane.setRightComponent(getJPanelLibraryRight());
908 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
909 }
910 return jSplitPane;
911 }
912
913 /**
914 * This method initializes jPanelLibraryLeft
915 *
916 * @return javax.swing.JPanel
917 */
918 private JPanel getJPanelLibraryLeft() {
919 if (jPanelLibraryLeft == null) {
920 jLabelLibClass = new JLabel();
921 jLabelLibClass.setText("Library Classes Uninstantiated");
922 jPanelLibraryLeft = new JPanel();
923 jPanelLibraryLeft.add(jLabelLibClass, null);
924 jPanelLibraryLeft.add(getJScrollPaneLibClass(), null);
925 }
926 return jPanelLibraryLeft;
927 }
928
929 /**
930 * This method initializes jPanelLibraryRight
931 *
932 * @return javax.swing.JPanel
933 */
934 private JPanel getJPanelLibraryRight() {
935 if (jPanelLibraryRight == null) {
936 jLabelQualifiedInstance = new JLabel();
937 jLabelQualifiedInstance.setText("Instances Available");
938 jPanelLibraryRight = new JPanel();
939 jPanelLibraryRight.add(jLabelQualifiedInstance, null);
940 jPanelLibraryRight.add(getJScrollPaneQualifiedInstance(), null);
941 }
942 return jPanelLibraryRight;
943 }
944
945 /**
946 * This method initializes jScrollPaneSelectedInstances
947 *
948 * @return javax.swing.JScrollPane
949 */
950 private JScrollPane getJScrollPaneSelectedInstances() {
951 if (jScrollPaneSelectedInstances == null) {
952 jScrollPaneSelectedInstances = new JScrollPane();
953 jScrollPaneSelectedInstances.setPreferredSize(new java.awt.Dimension(600,150));
954 jScrollPaneSelectedInstances.setViewportView(getJTableSelectedInstances());
955 }
956 return jScrollPaneSelectedInstances;
957 }
958
959 /**
960 * This method initializes jTableSelectedInstances
961 *
962 * @return javax.swing.JTable
963 */
964 private JTable getJTableSelectedInstances() {
965 if (jTableSelectedInstances == null) {
966 selectedInstancesTableModel = new IDefaultTableModel();
967 selectedInstancesTableModel.addColumn("Name");
968 selectedInstancesTableModel.addColumn("ModuleGUID");
969 selectedInstancesTableModel.addColumn("ModuleVersion");
970 selectedInstancesTableModel.addColumn("PackageGUID");
971 selectedInstancesTableModel.addColumn("PackageVersion");
972 jTableSelectedInstances = new JTable(selectedInstancesTableModel);
973 jTableSelectedInstances.setRowHeight(20);
974
975 jTableSelectedInstances.getColumnModel().getColumn(0).setMinWidth(250);
976
977 jTableSelectedInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
978 jTableSelectedInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
979
980 }
981 return jTableSelectedInstances;
982 }
983
984 /**
985 * This method initializes jScrollPaneLibClass
986 *
987 * @return javax.swing.JScrollPane
988 */
989 private JScrollPane getJScrollPaneLibClass() {
990 if (jScrollPaneLibClass == null) {
991 jScrollPaneLibClass = new JScrollPane();
992 jScrollPaneLibClass.setPreferredSize(new java.awt.Dimension(200,170));
993 jScrollPaneLibClass.setViewportView(getJTableLibClass());
994 }
995 return jScrollPaneLibClass;
996 }
997
998 /**
999 * This method initializes jTableLibClass
1000 *
1001 * @return javax.swing.JTable
1002 */
1003 private JTable getJTableLibClass() {
1004 if (jTableLibClass == null) {
1005 libClassTableModel = new IDefaultTableModel();
1006 libClassTableModel.addColumn("LibraryClass");
1007 libClassTableModel.addColumn("Arch");
1008 libClassTableModel.addColumn("ModType");
1009 jTableLibClass = new JTable(libClassTableModel);
1010 jTableLibClass.setRowHeight(20);
1011 jTableLibClass.setShowGrid(false);
1012 jTableLibClass.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1013
1014 TableColumn column = jTableLibClass.getColumnModel().getColumn(1);
1015 jTableLibClass.getColumnModel().removeColumn(column);
1016 column = jTableLibClass.getColumnModel().getColumn(1);
1017 jTableLibClass.getColumnModel().removeColumn(column);
1018
1019 jTableLibClass.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
1020 public void valueChanged(ListSelectionEvent e) {
1021 if (e.getValueIsAdjusting()){
1022 return;
1023 }
1024 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
1025 if (lsm.isSelectionEmpty()) {
1026 return;
1027 }
1028 else{
1029 int selectedRow2 = lsm.getMinSelectionIndex();
1030 if (selectedRow2 < 0) {
1031 return;
1032 }
1033 //
1034 // display potential lib instances according to class selection
1035 //
1036 libInstanceTableModel.setRowCount(0);
1037 String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();
1038 String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString();
1039 String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString();
1040 ArrayList<String> al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType));
1041 if (al == null) {
1042 return;
1043 }
1044 ListIterator<String> li = al.listIterator();
1045 while(li.hasNext()) {
1046 String instance = li.next();
1047 String[] s = {"", "", "", "", ""};
1048 if (WorkspaceProfile.getModuleId(instance) != null) {
1049 s[0] = WorkspaceProfile.getModuleId(instance).getName();
1050 }
1051
1052 String[] instancePart = instance.split(" ");
1053 for (int i = 0; i < instancePart.length; ++i){
1054 s[i+1] = instancePart[i];
1055 }
1056 libInstanceTableModel.addRow(s);
1057 }
1058
1059 }
1060 }
1061 });
1062 }
1063 return jTableLibClass;
1064 }
1065
1066 /**
1067 * This method initializes jScrollPaneQualifiedInstance
1068 *
1069 * @return javax.swing.JScrollPane
1070 */
1071 private JScrollPane getJScrollPaneQualifiedInstance() {
1072 if (jScrollPaneQualifiedInstance == null) {
1073 jScrollPaneQualifiedInstance = new JScrollPane();
1074 jScrollPaneQualifiedInstance.setPreferredSize(new java.awt.Dimension(600,170));
1075 jScrollPaneQualifiedInstance.setViewportView(getJTableLibInstances());
1076 }
1077 return jScrollPaneQualifiedInstance;
1078 }
1079
1080 /**
1081 * This method initializes jTableLibInstances
1082 *
1083 * @return javax.swing.JTable
1084 */
1085 private JTable getJTableLibInstances() {
1086 if (jTableLibInstances == null) {
1087 libInstanceTableModel = new IDefaultTableModel();
1088 libInstanceTableModel.addColumn("Name");
1089 libInstanceTableModel.addColumn("ModuleGUID");
1090 libInstanceTableModel.addColumn("ModuleVersion");
1091 libInstanceTableModel.addColumn("PackageGUID");
1092 libInstanceTableModel.addColumn("PackageVersion");
1093 jTableLibInstances = new JTable(libInstanceTableModel);
1094 jTableLibInstances.setRowHeight(20);
1095
1096 jTableLibInstances.getColumnModel().getColumn(0).setMinWidth(250);
1097
1098 jTableLibInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
1099 jTableLibInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1100
1101 }
1102 return jTableLibInstances;
1103 }
1104
1105 /**
1106 * This method initializes jPanelLibrarySouth
1107 *
1108 * @return javax.swing.JPanel
1109 */
1110 private JPanel getJPanelLibrarySouth() {
1111 if (jPanelLibrarySouth == null) {
1112 jPanelLibrarySouth = new JPanel();
1113 }
1114 return jPanelLibrarySouth;
1115 }
1116
1117 /**
1118 * This method initializes jPanelLibraryCenter
1119 *
1120 * @return javax.swing.JPanel
1121 */
1122 private JPanel getJPanelLibraryCenter() {
1123 if (jPanelLibraryCenter == null) {
1124 jLabelInstanceHelp = new JLabel();
1125 jLabelInstanceHelp.setText("Instance Description");
1126 jLabelSelectedInstances = new JLabel();
1127 jLabelSelectedInstances.setText("Selected Instances");
1128 jPanelLibraryCenter = new JPanel();
1129 jPanelLibraryCenter.setLayout(new BorderLayout());
1130
1131 jPanelLibraryCenter.add(getJPanelLibraryCenterC(), java.awt.BorderLayout.CENTER);
1132 jPanelLibraryCenter.add(getJPanelLibraryCenterN(), java.awt.BorderLayout.NORTH);
1133
1134 }
1135 return jPanelLibraryCenter;
1136 }
1137
1138 /**
1139 * This method initializes jScrollPaneInstanceHelp
1140 *
1141 * @return javax.swing.JScrollPane
1142 */
1143 private JScrollPane getJScrollPaneInstanceHelp() {
1144 if (jScrollPaneInstanceHelp == null) {
1145 jScrollPaneInstanceHelp = new JScrollPane();
1146 jScrollPaneInstanceHelp.setPreferredSize(new java.awt.Dimension(400,50));
1147 jScrollPaneInstanceHelp.setViewportView(getJTextAreaInstanceHelp());
1148 }
1149 return jScrollPaneInstanceHelp;
1150 }
1151
1152 /**
1153 * This method initializes jTextAreaInstanceHelp
1154 *
1155 * @return javax.swing.JTextArea
1156 */
1157 private JTextArea getJTextAreaInstanceHelp() {
1158 if (jTextAreaInstanceHelp == null) {
1159 jTextAreaInstanceHelp = new JTextArea();
1160 jTextAreaInstanceHelp.setEditable(false);
1161 }
1162 return jTextAreaInstanceHelp;
1163 }
1164
1165 /**
1166 * This method initializes jButtonAdd
1167 *
1168 * @return javax.swing.JButton
1169 */
1170 private JButton getJButtonAdd() {
1171 if (jButtonAdd == null) {
1172 jButtonAdd = new JButton();
1173 jButtonAdd.setPreferredSize(new java.awt.Dimension(80,20));
1174 jButtonAdd.setText("Add");
1175 jButtonAdd.addActionListener(new java.awt.event.ActionListener() {
1176 public void actionPerformed(java.awt.event.ActionEvent e) {
1177 int row = jTableLibInstances.getSelectedRow();
1178 if (row < 0) {
1179 return;
1180 }
1181
1182 String instanceValue = libInstanceTableModel.getValueAt(row, 1) + " " +
1183 libInstanceTableModel.getValueAt(row, 2) + " " +
1184 libInstanceTableModel.getValueAt(row, 3) + " " +
1185 libInstanceTableModel.getValueAt(row, 4);
1186 ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceValue);
1187 try {
1188 addLibInstance (libMi);
1189 }
1190 catch (Exception exception) {
1191 JOptionPane.showMessageDialog(frame, "Adding Instance" + libMi.getName() + ": "+ exception.getMessage());
1192 return;
1193 }
1194 docConsole.setSaved(false);
1195 Object[] s = {libInstanceTableModel.getValueAt(row, 0), libInstanceTableModel.getValueAt(row, 1),
1196 libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),
1197 libInstanceTableModel.getValueAt(row, 4)};
1198 selectedInstancesTableModel.addRow(s);
1199
1200 Vector<String> errorMsg = new Vector<String>();
1201 try {
1202 resolveLibraryInstances(instanceValue, errorMsg);
1203 }
1204 catch (Exception exp) {
1205 JOptionPane.showMessageDialog(frame, exp.getMessage());
1206 }
1207
1208 if (errorMsg.size() > 0) {
1209 String errors = "";
1210 for (int i = 0; i < errorMsg.size(); ++i) {
1211 errors += " " + errorMsg.get(i) + "\n";
1212 }
1213 JOptionPane.showMessageDialog(frame, errors);
1214 }
1215 showClassToResolved();
1216 }
1217 });
1218 }
1219 return jButtonAdd;
1220 }
1221
1222 /**
1223 * This method initializes jButton1
1224 *
1225 * @return javax.swing.JButton
1226 */
1227 private JButton getJButtonDeleteInstance() {
1228 if (jButtonDeleteInstance == null) {
1229 jButtonDeleteInstance = new JButton();
1230 jButtonDeleteInstance.setPreferredSize(new java.awt.Dimension(80,20));
1231 jButtonDeleteInstance.setText("Delete");
1232 jButtonDeleteInstance.addActionListener(new java.awt.event.ActionListener() {
1233 public void actionPerformed(java.awt.event.ActionEvent e) {
1234 int row = jTableSelectedInstances.getSelectedRow();
1235 if (row < 0) {
1236 return;
1237 }
1238 docConsole.setSaved(false);
1239 removeInstance(selectedInstancesTableModel.getValueAt(row, 1) + " " +
1240 selectedInstancesTableModel.getValueAt(row, 2) + " " +
1241 selectedInstancesTableModel.getValueAt(row, 3) + " " +
1242 selectedInstancesTableModel.getValueAt(row, 4));
1243 ffc.removeLibraryInstance(moduleKey, row);
1244 selectedInstancesTableModel.removeRow(row);
1245
1246 }
1247 });
1248 }
1249 return jButtonDeleteInstance;
1250 }
1251
1252 /**
1253 * This method initializes jButton2
1254 *
1255 * @return javax.swing.JButton
1256 */
1257 private JButton getJButtonOk() {
1258 if (jButtonOk == null) {
1259 jButtonOk = new JButton();
1260 jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
1261 jButtonOk.setText("Close");
1262 jButtonOk.addActionListener(this);
1263 }
1264 return jButtonOk;
1265 }
1266
1267 /**
1268 * This method initializes jButton3
1269 *
1270 * @return javax.swing.JButton
1271 */
1272 private JButton getJButtonCancel() {
1273 if (jButtonCancel == null) {
1274 jButtonCancel = new JButton();
1275 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
1276 jButtonCancel.setText("Cancel");
1277 jButtonCancel.setVisible(false);
1278 }
1279 return jButtonCancel;
1280 }
1281 public void actionPerformed(ActionEvent arg0) {
1282
1283 if (arg0.getSource() == jButtonOk) {
1284 if (jTableModuleSaOptions.isEditing()) {
1285 jTableModuleSaOptions.getCellEditor().stopCellEditing();
1286 }
1287 this.setVisible(false);
1288 }
1289 }
1290 /**
1291 * This method initializes jPanelModuleSaOpts
1292 *
1293 * @return javax.swing.JPanel
1294 */
1295 private JPanel getJPanelModuleSaOpts() {
1296 if (jPanelModuleSaOpts == null) {
1297 FlowLayout flowLayout4 = new FlowLayout();
1298 flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
1299 jLabelFfsFormatKey = new JLabel();
1300 jLabelFfsFormatKey.setText("FFS Format Key");
1301 jLabelFfsFormatKey.setPreferredSize(new java.awt.Dimension(90,16));
1302 jLabelFfsFileGuid = new JLabel();
1303 jLabelFfsFileGuid.setText("FFS File GUID");
1304 jLabelFfsFileGuid.setPreferredSize(new java.awt.Dimension(90,16));
1305 jLabelFfsFileGuid.setVisible(false);
1306 jLabelFvBinding = new JLabel();
1307 jLabelFvBinding.setText("FV Binding");
1308 jLabelFvBinding.setPreferredSize(new java.awt.Dimension(90,16));
1309 jPanelModuleSaOpts = new JPanel();
1310 jPanelModuleSaOpts.setLayout(flowLayout4);
1311 jPanelModuleSaOpts.add(jLabelFvBinding, null);
1312 jPanelModuleSaOpts.add(getJTextFieldFvBinding(), null);
1313 jPanelModuleSaOpts.add(jLabelFfsFileGuid, null);
1314 jPanelModuleSaOpts.add(getJTextFieldFileGuid(), null);
1315 jPanelModuleSaOpts.add(jLabelFfsFormatKey, null);
1316 jPanelModuleSaOpts.add(getJTextFieldFfsKey(), null);
1317 jPanelModuleSaOpts.addComponentListener(new java.awt.event.ComponentAdapter() {
1318 public void componentShown(java.awt.event.ComponentEvent e) {
1319 initFvInfo(moduleKey);
1320 }
1321 });
1322 }
1323 return jPanelModuleSaOpts;
1324 }
1325
1326 private Vector<String> getVectorFromString (String s) {
1327 if (s == null || s.equals("null")) {
1328 s = "";
1329 }
1330 String[] sa1 = s.split(" ");
1331 Vector<String> v = new Vector<String>();
1332 for (int i = 0; i < sa1.length; ++i) {
1333 v.add(sa1[i]);
1334 }
1335 return v;
1336 }
1337
1338 /**
1339 * This method initializes jTextField
1340 *
1341 * @return javax.swing.JTextField
1342 */
1343 private JTextField getJTextFieldFvBinding() {
1344 if (jTextFieldFvBinding == null) {
1345 jTextFieldFvBinding = new JTextField();
1346 jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(400,20));
1347 jTextFieldFvBinding.setEditable(true);
1348 jTextFieldFvBinding.addFocusListener(new java.awt.event.FocusAdapter() {
1349 public void focusLost(java.awt.event.FocusEvent e) {
1350 String originalFvBinding = ffc.getFvBinding(moduleKey);
1351 String newFvBinding = jTextFieldFvBinding.getText();
1352 if (newFvBinding.equals(originalFvBinding)) {
1353 return;
1354 }
1355 if (newFvBinding.length() == 0 && originalFvBinding == null) {
1356 return;
1357 }
1358
1359 Vector<String> oldFvList = getVectorFromString (originalFvBinding);
1360 Vector<String> newFvList = getVectorFromString (newFvBinding);
1361 String moduleInfo[] = moduleKey.split(" ");
1362 ffc.setFvBinding(moduleKey, newFvBinding);
1363 //
1364 // remove module from Fvs that not in newFvList now.
1365 //
1366 oldFvList.removeAll(newFvList);
1367 for (int j = 0; j < oldFvList.size(); ++j) {
1368 ffc.removeModuleInBuildOptionsUserExtensions(oldFvList.get(j), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
1369 }
1370 //
1371 // add module to Fvs that were not in oldFvList.
1372 //
1373 oldFvList = getVectorFromString (originalFvBinding);
1374 newFvList.removeAll(oldFvList);
1375 for (int i = 0; i < newFvList.size(); ++i) {
1376 ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
1377 }
1378 docConsole.setSaved(false);
1379 }
1380 });
1381
1382 }
1383 return jTextFieldFvBinding;
1384 }
1385 /**
1386 * This method initializes jTextField1
1387 *
1388 * @return javax.swing.JTextField
1389 */
1390 private JTextField getJTextFieldFileGuid() {
1391 if (jTextFieldFileGuid == null) {
1392 jTextFieldFileGuid = new JTextField();
1393 jTextFieldFileGuid.setPreferredSize(new java.awt.Dimension(300,20));
1394 jTextFieldFileGuid.setVisible(false);
1395 jTextFieldFileGuid.addFocusListener(new java.awt.event.FocusAdapter() {
1396 public void focusLost(java.awt.event.FocusEvent e) {
1397 String originalFileGuid = ffc.getFfsFileNameGuid(moduleKey);
1398 String newFileGuid = jTextFieldFileGuid.getText();
1399 if (newFileGuid.equals(originalFileGuid)) {
1400 return;
1401 }
1402 if (newFileGuid.length() == 0 && originalFileGuid == null) {
1403 return;
1404 }
1405 if (newFileGuid.length() > 0) {
1406 if (!DataValidation.isGuid(newFileGuid)) {
1407 JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type.");
1408 return;
1409 }
1410 }
1411
1412 docConsole.setSaved(false);
1413 if (newFileGuid.length() == 0) {
1414 newFileGuid = null;
1415 }
1416 ffc.setFfsFileNameGuid(moduleKey, newFileGuid);
1417 }
1418 });
1419
1420 }
1421 return jTextFieldFileGuid;
1422 }
1423 /**
1424 * This method initializes jTextFieldFfsKey
1425 *
1426 * @return javax.swing.JTextField
1427 */
1428 private JTextField getJTextFieldFfsKey() {
1429 if (jTextFieldFfsKey == null) {
1430 jTextFieldFfsKey = new JTextField();
1431 jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(250,20));
1432 jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {
1433 public void focusLost(java.awt.event.FocusEvent e) {
1434 String originalFfsKey = ffc.getFfsFormatKey(moduleKey);
1435 String newFfsKey = jTextFieldFfsKey.getText();
1436 if (newFfsKey.equals(originalFfsKey)) {
1437 return;
1438 }
1439 if (newFfsKey.length() == 0 && originalFfsKey == null) {
1440 return;
1441 }
1442 docConsole.setSaved(false);
1443 ffc.setFfsFormatKey(moduleKey, newFfsKey);
1444 }
1445 });
1446
1447 }
1448 return jTextFieldFfsKey;
1449 }
1450 /**
1451 * This method initializes jScrollPaneModuleSaOptions
1452 *
1453 * @return javax.swing.JScrollPane
1454 */
1455 private JScrollPane getJScrollPaneModuleSaOptions() {
1456 if (jScrollPaneModuleSaOptions == null) {
1457 jScrollPaneModuleSaOptions = new JScrollPane();
1458 jScrollPaneModuleSaOptions.setPreferredSize(new java.awt.Dimension(600,350));
1459 jScrollPaneModuleSaOptions.setViewportView(getJTableModuleSaOptions());
1460 }
1461 return jScrollPaneModuleSaOptions;
1462 }
1463 /**
1464 * This method initializes jTableModuleSaOptions
1465 *
1466 * @return javax.swing.JTable
1467 */
1468 private JTable getJTableModuleSaOptions() {
1469 if (jTableModuleSaOptions == null) {
1470 optionsTableModel = new DefaultTableModel();
1471 optionsTableModel.addColumn("BuildTargets");
1472 optionsTableModel.addColumn("ToolChainFamily");
1473 optionsTableModel.addColumn("TagName");
1474 optionsTableModel.addColumn("ToolCode");
1475 optionsTableModel.addColumn("SupportedArchs");
1476 optionsTableModel.addColumn("Contents");
1477 jTableModuleSaOptions = new JTable(optionsTableModel);
1478 jTableModuleSaOptions.setRowHeight(20);
1479
1480 jTableModuleSaOptions.getColumnModel().getColumn(0).setMinWidth(buildTargetWidth);
1481 jTableModuleSaOptions.getColumnModel().getColumn(1).setMinWidth(toolChainFamilyWidth);
1482 jTableModuleSaOptions.getColumnModel().getColumn(2).setMinWidth(tagNameWidth);
1483 jTableModuleSaOptions.getColumnModel().getColumn(3).setMinWidth(toolCmdCodeWidth);
1484 jTableModuleSaOptions.getColumnModel().getColumn(4).setMinWidth(supportArchWidth);
1485 jTableModuleSaOptions.getColumnModel().getColumn(5).setMinWidth(argWidth);
1486 // javax.swing.table.TableColumn toolFamilyCol = jTableModuleSaOptions.getColumnModel().getColumn(1);
1487 // JComboBox cb = new JComboBox();
1488 // cb.addItem("MSFT");
1489 // cb.addItem("GCC");
1490 // cb.addItem("CYGWIN");
1491 // cb.addItem("INTEL");
1492 // cb.addItem("USER_DEFINED");
1493 // toolFamilyCol.setCellEditor(new DefaultCellEditor(cb));
1494
1495 Vector<String> vArch = new Vector<String>();
1496 vArch.add("IA32");
1497 vArch.add("X64");
1498 vArch.add("IPF");
1499 vArch.add("EBC");
1500 vArch.add("ARM");
1501 vArch.add("PPC");
1502 jTableModuleSaOptions.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch));
1503
1504 jTableModuleSaOptions.getColumnModel().getColumn(5).setCellEditor(new LongTextEditor());
1505
1506 jTableModuleSaOptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1507 jTableModuleSaOptions.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
1508 jTableModuleSaOptions.getModel().addTableModelListener(new TableModelListener() {
1509 public void tableChanged(TableModelEvent arg0) {
1510 // TODO Auto-generated method stub
1511 int row = arg0.getFirstRow();
1512 TableModel m = (TableModel)arg0.getSource();
1513
1514 if (arg0.getType() == TableModelEvent.UPDATE){
1515 //ToDo Data Validition check.
1516 String targets = m.getValueAt(row, 0) + "";
1517 Vector<Object> targetName = null;
1518 if (targets.length() > 0) {
1519 targetName = new Vector<Object>();
1520 String[] sArray = targets.split(" ");
1521 for (int i = 0; i < sArray.length; ++i) {
1522 targetName.add(sArray[i]);
1523 }
1524 }
1525
1526 String toolChain = m.getValueAt(row, 1) + "";
1527 String tagName = m.getValueAt(row, 2) + "";
1528 String toolCode = m.getValueAt(row, 3) + "";
1529 String archs = m.getValueAt(row, 4) + "";
1530 Vector<Object> supArch = null;
1531 if (archs.length() > 0) {
1532 supArch = new Vector<Object>();
1533 String[] sArray1 = archs.split(" ");
1534 for (int i = 0; i < sArray1.length; ++i) {
1535 supArch.add(sArray1[i]);
1536 }
1537 }
1538
1539 String contents = m.getValueAt(row, 5) + "";
1540 docConsole.setSaved(false);
1541 ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);
1542 }
1543 }
1544 });
1545 }
1546 return jTableModuleSaOptions;
1547 }
1548 /**
1549 * This method initializes jButtonNew
1550 *
1551 * @return javax.swing.JButton
1552 */
1553 private JButton getJButtonNew() {
1554 if (jButtonNew == null) {
1555 jButtonNew = new JButton();
1556 jButtonNew.setPreferredSize(new java.awt.Dimension(80,20));
1557 jButtonNew.setText("New");
1558 jButtonNew.addActionListener(new java.awt.event.ActionListener() {
1559 public void actionPerformed(java.awt.event.ActionEvent e) {
1560 String[] row = {"", "", "", "", "", ""};
1561 optionsTableModel.addRow(row);
1562 Vector<Object> v = null;
1563 Vector<Object> v1 = null;
1564 docConsole.setSaved(false);
1565 ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");
1566 }
1567 });
1568 }
1569 return jButtonNew;
1570 }
1571 /**
1572 * This method initializes jButtonDelete
1573 *
1574 * @return javax.swing.JButton
1575 */
1576 private JButton getJButtonDeleteOption() {
1577 if (jButtonDeleteOption == null) {
1578 jButtonDeleteOption = new JButton();
1579 jButtonDeleteOption.setPreferredSize(new java.awt.Dimension(80,20));
1580 jButtonDeleteOption.setText("Delete");
1581 jButtonDeleteOption.addActionListener(new java.awt.event.ActionListener() {
1582 public void actionPerformed(java.awt.event.ActionEvent e) {
1583 if (jTableModuleSaOptions.getSelectedRow() < 0) {
1584 return;
1585 }
1586 docConsole.setSaved(false);
1587 ffc.removeModuleSAOptionsOpt(moduleKey, jTableModuleSaOptions.getSelectedRow());
1588 optionsTableModel.removeRow(jTableModuleSaOptions.getSelectedRow());
1589 }
1590 });
1591 }
1592 return jButtonDeleteOption;
1593 }
1594
1595 /**
1596 Start the window at the center of screen
1597
1598 **/
1599 protected void centerWindow(int intWidth, int intHeight) {
1600 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
1601 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
1602 }
1603
1604 /**
1605 Start the window at the center of screen
1606
1607 **/
1608 protected void centerWindow() {
1609 centerWindow(this.getSize().width, this.getSize().height);
1610 }
1611 /**
1612 * This method initializes jPanelPcdFields
1613 *
1614 * @return javax.swing.JPanel
1615 */
1616 private JPanel getJPanelPcdFields() {
1617 if (jPanelPcdFields == null) {
1618 GridLayout gridLayout = new GridLayout();
1619 gridLayout.setRows(3);
1620 gridLayout.setColumns(2);
1621 jPanelPcdFields = new JPanel();
1622 jPanelPcdFields.setLayout(gridLayout);
1623 jPanelPcdFields.setPreferredSize(new java.awt.Dimension(600,90));
1624 jPanelPcdFields.add(getJPanelPcdFieldsFirstRow(), null);
1625 jPanelPcdFields.add(getJPanelPcdFieldsSecondRow(), null);
1626 jPanelPcdFields.add(getJPanelPcdFieldsThirdRow(), null);
1627 }
1628 return jPanelPcdFields;
1629 }
1630 /**
1631 * This method initializes jPanelPcdFieldsSecondRow
1632 *
1633 * @return javax.swing.JPanel
1634 */
1635 private JPanel getJPanelPcdFieldsSecondRow() {
1636 if (jPanelPcdFieldsSecondRow == null) {
1637 FlowLayout flowLayout2 = new FlowLayout();
1638 flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
1639 jLabelMaxDatumSize = new JLabel();
1640 jLabelMaxDatumSize.setText("Max Datum Size");
1641 jPanelPcdFieldsSecondRow = new JPanel();
1642 jPanelPcdFieldsSecondRow.setLayout(flowLayout2);
1643 jPanelPcdFieldsSecondRow.add(jLabelMaxDatumSize, null);
1644 jPanelPcdFieldsSecondRow.add(getJTextFieldMaxDatumSize(), null);
1645 }
1646 return jPanelPcdFieldsSecondRow;
1647 }
1648 /**
1649 * This method initializes jPanelPcdFieldsThirdRow
1650 *
1651 * @return javax.swing.JPanel
1652 */
1653 private JPanel getJPanelPcdFieldsThirdRow() {
1654 if (jPanelPcdFieldsThirdRow == null) {
1655 FlowLayout flowLayout3 = new FlowLayout();
1656 flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
1657 jLabelPcdDefaultValue = new JLabel();
1658 jLabelPcdDefaultValue.setText("Default Value");
1659 jLabelPcdDefaultValue.setPreferredSize(new java.awt.Dimension(91,16));
1660 jPanelPcdFieldsThirdRow = new JPanel();
1661 jPanelPcdFieldsThirdRow.setLayout(flowLayout3);
1662 jPanelPcdFieldsThirdRow.add(jLabelPcdDefaultValue, null);
1663 jPanelPcdFieldsThirdRow.add(getJTextFieldPcdDefault(), null);
1664 jPanelPcdFieldsThirdRow.add(getJComboBoxFeatureFlagValue(), null);
1665 jPanelPcdFieldsThirdRow.add(getJButtonUpdatePcd(), null);
1666 }
1667 return jPanelPcdFieldsThirdRow;
1668 }
1669 /**
1670 * This method initializes jPanelPcdFieldsFirstRow
1671 *
1672 * @return javax.swing.JPanel
1673 */
1674 private JPanel getJPanelPcdFieldsFirstRow() {
1675 if (jPanelPcdFieldsFirstRow == null) {
1676 FlowLayout flowLayout1 = new FlowLayout();
1677 flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
1678 jLabelItemType = new JLabel();
1679 jLabelItemType.setText("Item Type");
1680 jLabelItemType.setPreferredSize(new java.awt.Dimension(91,16));
1681 jPanelPcdFieldsFirstRow = new JPanel();
1682 jPanelPcdFieldsFirstRow.setLayout(flowLayout1);
1683 jPanelPcdFieldsFirstRow.add(jLabelItemType, null);
1684 jPanelPcdFieldsFirstRow.add(getJComboBoxItemType(), null);
1685 }
1686 return jPanelPcdFieldsFirstRow;
1687 }
1688 /**
1689 * This method initializes jComboBoxItemType
1690 *
1691 * @return javax.swing.JComboBox
1692 */
1693 private JComboBox getJComboBoxItemType() {
1694 if (jComboBoxItemType == null) {
1695 jComboBoxItemType = new JComboBox();
1696 jComboBoxItemType.setPreferredSize(new java.awt.Dimension(200,20));
1697 // jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() {
1698 // public void itemStateChanged(java.awt.event.ItemEvent e) {
1699 //
1700 // int row = jTablePcd.getSelectedRow();
1701 // if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) {
1702 // return;
1703 // }
1704 // if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) {
1705 //
1706 // if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {
1707 // jTextFieldPcdDefault.setText("");
1708 // jTextFieldPcdDefault.setEnabled(true);
1709 // }
1710 // }
1711 // else{
1712 //
1713 // }
1714 // }
1715 // });
1716 }
1717 return jComboBoxItemType;
1718 }
1719
1720 private void pcdDynamicToNonDynamic(String cName, String tsGuid) {
1721 String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];
1722 ffc.getDynamicPcdBuildData(saa);
1723 String maxSize = "";
1724 String value = "";
1725 for (int i = 0; i < saa.length; ++i) {
1726 if (saa[i][0].equals(cName) && saa[i][2].equals(tsGuid)) {
1727 maxSize = saa[i][3];
1728 value = ffc.getDynamicPcdBuildDataValue(i);
1729 break;
1730 }
1731 }
1732
1733 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1734 for (int i = 0; i < al.size(); ++i) {
1735 String mKey = moduleInfo (al.get(i));
1736 value = null;
1737 String itemType = jComboBoxItemType.getSelectedItem()+"";
1738 ffc.updatePcdData(mKey, cName, tsGuid, itemType, maxSize, value);
1739 al.set(i, mKey + " " + itemType);
1740 }
1741
1742 ffc.removeDynamicPcdBuildData(cName, tsGuid);
1743 }
1744
1745 private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
1746 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1747 for (int i = 0; i < al.size(); ++i) {
1748 String mKey = moduleInfo (al.get(i));
1749 String itemType = jComboBoxItemType.getSelectedItem()+"";
1750 ffc.updatePcdData(mKey, cName, tsGuid, itemType, jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");
1751 al.set(i, mKey + " " + itemType);
1752 }
1753 try{
1754 ffc.addDynamicPcdBuildData(cName, jTablePcd.getValueAt(jTablePcd.getSelectedRow(), 3), tsGuid, "DYNAMIC", jTablePcd.getValueAt(jTablePcd.getSelectedRow(), 5)+"", jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");
1755 }
1756 catch(Exception e){
1757 JOptionPane.showMessageDialog(frame, "PCD value format: " + e.getMessage());
1758 }
1759 }
1760
1761 private void changePcdTypeWithinSameCategory (String cName, String tsGuid) {
1762 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1763 for (int i = 0; i < al.size(); ++i) {
1764 String mKey = moduleInfo (al.get(i));
1765 String itemType = jComboBoxItemType.getSelectedItem()+"";
1766 ffc.updatePcdData(mKey, cName, tsGuid, itemType, null, null);
1767 al.set(i, mKey + " " + itemType);
1768 }
1769 }
1770
1771 private String moduleInfo (String pcdInfo) {
1772
1773 return pcdInfo.substring(0, pcdInfo.lastIndexOf(" "));
1774 }
1775
1776 /**
1777 * This method initializes jTextFieldMaxDatumSize
1778 *
1779 * @return javax.swing.JTextField
1780 */
1781 private JTextField getJTextFieldMaxDatumSize() {
1782 if (jTextFieldMaxDatumSize == null) {
1783 jTextFieldMaxDatumSize = new JTextField();
1784 jTextFieldMaxDatumSize.setPreferredSize(new java.awt.Dimension(200,20));
1785 }
1786 return jTextFieldMaxDatumSize;
1787 }
1788 /**
1789 * This method initializes jTextField4
1790 *
1791 * @return javax.swing.JTextField
1792 */
1793 private JTextField getJTextFieldPcdDefault() {
1794 if (jTextFieldPcdDefault == null) {
1795 jTextFieldPcdDefault = new JTextField();
1796 jTextFieldPcdDefault.setPreferredSize(new java.awt.Dimension(200,20));
1797 }
1798 return jTextFieldPcdDefault;
1799 }
1800 /**
1801 * This method initializes jButton6
1802 *
1803 * @return javax.swing.JButton
1804 */
1805 private JButton getJButtonUpdatePcd() {
1806 if (jButtonUpdatePcd == null) {
1807 jButtonUpdatePcd = new JButton();
1808 jButtonUpdatePcd.setPreferredSize(new java.awt.Dimension(150,20));
1809 jButtonUpdatePcd.setText("Update PCD Data");
1810 jButtonUpdatePcd.addActionListener(new java.awt.event.ActionListener() {
1811 public void actionPerformed(java.awt.event.ActionEvent e) {
1812 int row = jTablePcd.getSelectedRow();
1813 if (row < 0) {
1814 return;
1815 }
1816
1817 String cName = model.getValueAt(row, 0)+"";
1818 String tsGuid = model.getValueAt(row, 1)+"";
1819 String oldItemType = model.getValueAt(row, 2)+"";
1820 String dataType = model.getValueAt(row, 5)+"";
1821 String newItemType = jComboBoxItemType.getSelectedItem()+"";
1822 String newValue = jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem()+"";
1823 if (newValue.length() == 0){
1824
1825 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {
1826 newValue = "0";
1827 }
1828 if (dataType.equals("BOOLEAN")){
1829 newValue = "FALSE";
1830 }
1831 if (dataType.equals("VOID*")) {
1832 newValue = "L\"\"";
1833 }
1834 }
1835
1836 String[] pcdInfo = {"", "", ""};
1837 Vector<String> validPcdTypes = new Vector<String>();
1838 getPcdInfo (moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);
1839 if (pcdInfo[1].equals("FIXED_AT_BUILD") && model.getValueAt(row, 5).equals("VOID*")) {
1840 try {
1841 jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(newValue)+"");
1842 }
1843 catch (Exception exp) {
1844 JOptionPane.showMessageDialog(frame, "PCD Value MalFormed: " + exp.getMessage());
1845 return;
1846 }
1847 }
1848 String newMaxDatumSize = jTextFieldMaxDatumSize.getText();
1849
1850 if (!newItemType.equals(oldItemType)) {
1851 Vector<ModuleIdentification> moduleInfo = new Vector<ModuleIdentification>();
1852 try {
1853 boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo);
1854 if (!changable) {
1855 JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName());
1856 return;
1857 }
1858 }
1859 catch (Exception exp) {
1860 JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage());
1861 return;
1862 }
1863
1864 if ((oldItemType.equals("DYNAMIC") || oldItemType.equals("DYNAMIC_EX")) && !newItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC_EX")) {
1865 pcdDynamicToNonDynamic(cName, tsGuid);
1866 }
1867 if (!oldItemType.equals("DYNAMIC") && !oldItemType.equals("DYNAMIC_EX") && (newItemType.equals("DYNAMIC") || newItemType.equals("DYNAMIC_EX"))) {
1868 pcdNonDynamicToDynamic(cName, tsGuid);
1869 }
1870 else {
1871 changePcdTypeWithinSameCategory (cName, tsGuid);
1872 }
1873 model.setValueAt(newItemType, row, 2);
1874 }
1875
1876 ffc.updatePcdData(moduleKey, cName, tsGuid, model.getValueAt(row, 2)+"", newMaxDatumSize, newValue);
1877 docConsole.setSaved(false);
1878 model.setValueAt(newValue, row, 6);
1879 model.setValueAt(newMaxDatumSize, row, 4);
1880
1881 }
1882 });
1883 }
1884 return jButtonUpdatePcd;
1885 }
1886
1887 private boolean itemTypeCouldBeChanged (String cName, String tsGuid, String newItemType, Vector<ModuleIdentification> mi) throws Exception{
1888 ArrayList<String> pcdConsumers = ffc.getDynPcdMapValue(cName + " " + tsGuid);
1889 for (int i = 0; i < pcdConsumers.size(); ++i) {
1890 String consumerInfo = moduleInfo (pcdConsumers.get(i));
1891 mi.removeAllElements();
1892 mi.add(WorkspaceProfile.getModuleId(consumerInfo));
1893 String[] sa = {"", "", ""};
1894 Vector<String> validPcdTypes = new Vector<String>();
1895 getPcdInfo (consumerInfo, cName, tsGuid, sa, validPcdTypes);
1896 if (validPcdTypes.size() == 0) {
1897 return false;
1898 }
1899 if (!sa[1].equals("DYNAMIC")) {
1900 return false;
1901 }
1902 if (!validPcdTypes.contains(newItemType)) {
1903 return false;
1904 }
1905 }
1906 return true;
1907 }
1908
1909 /**
1910 * This method initializes jComboBoxFeatureFlagValue
1911 *
1912 * @return javax.swing.JComboBox
1913 */
1914 private JComboBox getJComboBoxFeatureFlagValue() {
1915 if (jComboBoxFeatureFlagValue == null) {
1916 jComboBoxFeatureFlagValue = new JComboBox();
1917 jComboBoxFeatureFlagValue.setPreferredSize(new java.awt.Dimension(100,20));
1918 jComboBoxFeatureFlagValue.setVisible(false);
1919 jComboBoxFeatureFlagValue.addItem("TRUE");
1920 jComboBoxFeatureFlagValue.addItem("FALSE");
1921 }
1922 return jComboBoxFeatureFlagValue;
1923 }
1924 /**
1925 * This method initializes jPanelCustomToolChain
1926 *
1927 * @return javax.swing.JPanel
1928 */
1929 private JPanel getJPanelCustomToolChain() {
1930 if (jPanelCustomToolChain == null) {
1931 jPanelCustomToolChain = new JPanel();
1932 jPanelCustomToolChain.setLayout(new BorderLayout());
1933 jPanelCustomToolChain.add(getJPanelToolchainS(), java.awt.BorderLayout.SOUTH);
1934 jPanelCustomToolChain.add(getJScrollPaneModuleSaOptions(), java.awt.BorderLayout.CENTER);
1935 jPanelCustomToolChain.addComponentListener(new java.awt.event.ComponentAdapter() {
1936 public void componentShown(java.awt.event.ComponentEvent e) {
1937 initToolChainOptions(moduleKey);
1938 }
1939 });
1940 }
1941 return jPanelCustomToolChain;
1942 }
1943 /**
1944 * This method initializes jPanelToolchainS
1945 *
1946 * @return javax.swing.JPanel
1947 */
1948 private JPanel getJPanelToolchainS() {
1949 if (jPanelToolchainS == null) {
1950 jPanelToolchainS = new JPanel();
1951 jPanelToolchainS.add(getJButtonNew(), null);
1952 jPanelToolchainS.add(getJButtonDeleteOption(), null);
1953 }
1954 return jPanelToolchainS;
1955 }
1956
1957 /**
1958 * This method initializes jPanelLibraryCenterN
1959 *
1960 * @return javax.swing.JPanel
1961 */
1962 private JPanel getJPanelLibraryCenterN() {
1963 if (jPanelLibraryCenterN == null) {
1964 FlowLayout flowLayout5 = new FlowLayout();
1965 flowLayout5.setAlignment(java.awt.FlowLayout.CENTER);
1966 flowLayout5.setHgap(10);
1967 jPanelLibraryCenterN = new JPanel();
1968 jPanelLibraryCenterN.setLayout(flowLayout5);
1969 jPanelLibraryCenterN.add(jLabelInstanceHelp, null);
1970 jPanelLibraryCenterN.add(getJScrollPaneInstanceHelp(), null);
1971 jPanelLibraryCenterN.add(getJButtonAdd(), null);
1972 jPanelLibraryCenterN.add(getJButtonDeleteInstance(), null);
1973 }
1974 return jPanelLibraryCenterN;
1975 }
1976 /**
1977 * This method initializes jPanelLibraryCenterC
1978 *
1979 * @return javax.swing.JPanel
1980 */
1981 private JPanel getJPanelLibraryCenterC() {
1982 if (jPanelLibraryCenterC == null) {
1983 jPanelLibraryCenterC = new JPanel();
1984 jPanelLibraryCenterC.add(jLabelSelectedInstances, null);
1985 jPanelLibraryCenterC.add(getJScrollPaneSelectedInstances(), null);
1986 }
1987 return jPanelLibraryCenterC;
1988 }
1989
1990
1991 } // @jve:decl-index=0:visual-constraint="10,10"
1992
1993 class MultipleInstanceException extends Exception {
1994
1995 /**
1996 *
1997 */
1998 private static final long serialVersionUID = -9148463005930920297L;
1999 private String className = null;
2000 private String libInstance1 = null;
2001 private String libInstance2 = null;
2002
2003 MultipleInstanceException (String libClass, String instance1, String instance2) {
2004 super();
2005 className = libClass;
2006 libInstance1 = instance1;
2007 libInstance2 = instance2;
2008 }
2009
2010 /* (non-Javadoc)
2011 * @see java.lang.Throwable#getMessage()
2012 */
2013 @Override
2014 public String getMessage() {
2015 // TODO Auto-generated method stub
2016 return " Library Class " + className + "is Produced by Two Instances: "
2017 + libInstance1 + " and " + libInstance2 + ". Platform Build will Fail.";
2018 }
2019
2020 }
2021
2022 class NoInstanceException extends Exception {
2023
2024 /**
2025 *
2026 */
2027 private static final long serialVersionUID = 1987122786598970598L;
2028
2029 private String className = null;
2030
2031 NoInstanceException (String libClass) {
2032 className = libClass;
2033 }
2034
2035 public String getMessage() {
2036 return "No Applicable Instance for Library Class " + className
2037 + ", Platform Build will Fail.";
2038 }
2039 }