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