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