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