Modify FrameworkModules editor for FPD files to meet the new PCD type adjust operatio...
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 2 Nov 2006 11:04:27 +0000 (11:04 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 2 Nov 2006 11:04:27 +0000 (11:04 +0000)
a. Add a module with PCD type Dyn.
If this PCD not exists in platform,
ModuleSA.PcdType is set as Dyn (choose one from spd).
Else
ModuleSA.PcdType is set as existing type ?
(Give a error message if this module pcd can NOT be set as existing type. And Pcd will not be added for this module into platform.)

If PCD type is determined to be Dyn.
Add PCD to DynamicPcdBuildDefinitions if it not exists there.
SkuId = 0;
SkuInfo.value = MSA default | SPD default | give default based on DatumType.
If DatumType == void*
Set ModuleSA.PcdMaxDatumSize;

b. Add a module with PCD type DynEx.
If this PCD not exists in platform,
ModuleSA.PcdType is set as DynEx.
Else
ModuleSA.PcdType is set as existing type ?
(Give a error message if this module pcd can NOT be set as existing type. And Pcd will not be added for this module into platform.)

Add PCD to DynamicPcdBuildDefinitions if it not exists there.
SkuId = 0;
SkuInfo.value = MSA default | SPD default | give default based on DatumType.
If DatumType == void*
    Set ModuleSA.PcdMaxDatumSize;

c. Add a module with PCD type FixedAtBuild, PIM, FF
If this PCD not exists in platform,
ModuleSA.PcdType is set as FaB | PIM | FF.
Else
ModuleSA.PcdType is set as existing type ?
(Give a error message if this module pcd can NOT be set as existing type. And Pcd will not be added for this module into platform..)

ModuleSA.PcdValue = MSA default | SPD default | give default based on DatumType.
If DatumType == void*
Set ModuleSA.PcdMaxDatumSize;

d. Edit ModuleSA.PcdType
Get the corresponding MSA.PcdType in MSA file for this ModuleSA.

If MSA.PcdType == Dyn.
ModuleSA.PcdType could be [(valid Pcd types in SPD)]

    Else
ModuleSA.PcdType can NOT be changed.

1) Change ModuleSa.PcdType from Dynamic. to [valid Pcd types in SPD]:
All same PCDs in FrameworkModules are changed to one of valid Pcd types in SPD according to user selection.
Check in whole platform other ModuleSA for the same pcd, if the corresponding MSAes for other ModuleSAes pcd can NOT accept the new type, give error message.

Keep old ModuleSA.PcdValue.
Remove this PCD in DynamicPcdBuildDefintion.

2) Change ModuleSa.PcdType from [FaBor PIM] to Dynamic, DynEx.:
All same PCDs in FrameworkModules are changed to Dynamic | DynEx.
Check in whole platform other ModuleSA for the same pcd, if the corresponding MSAes for other ModuleSAes pcd can NOT accept the new type, give error message.

Keep old ModuleSA.PcdValue?
Add one new dynamic PCD in DynamicPcdBuildDefintion.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1888 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java
Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java
Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java

index 58701918c913106ebe7ac2f7f41d8e0edbc0c898..8ee2da170cc81007a286be2141b7bc7f79ff9c8e 100644 (file)
@@ -36,6 +36,8 @@ import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
 import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
 import javax.swing.JCheckBox;\r
+import javax.swing.event.DocumentEvent;\r
+import javax.swing.event.DocumentListener;\r
 \r
 /**\r
  The class is used to create, update spdHeader of Spd file\r
@@ -44,7 +46,7 @@ import javax.swing.JCheckBox;
  @since PackageEditor 1.0\r
 \r
  **/\r
-public class SpdHeader extends IInternalFrame {\r
+public class SpdHeader extends IInternalFrame implements DocumentListener{\r
 \r
     private int dialogWidth = 560;\r
 \r
@@ -185,6 +187,7 @@ public class SpdHeader extends IInternalFrame {
             jPackageNameTextField = new JTextField();\r
             jPackageNameTextField.setBounds(new java.awt.Rectangle(valueColumn, rowOne, valueWidth, oneRowHeight));\r
             jPackageNameTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
+            jPackageNameTextField.getDocument().addDocumentListener(this);\r
             jPackageNameTextField.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isUiNameType(jPackageNameTextField.getText())) {\r
@@ -194,7 +197,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jPackageNameTextField.getText().equals(sfc.getSpdHdrPkgName())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrPkgName(jPackageNameTextField.getText());\r
                 }\r
             });\r
@@ -213,6 +215,7 @@ public class SpdHeader extends IInternalFrame {
             jGuidTextField = new JTextField();\r
             jGuidTextField.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, shortValueWidth, oneRowHeight));\r
             jGuidTextField.setPreferredSize(new java.awt.Dimension(shortValueWidth, oneRowHeight));\r
+            jGuidTextField.getDocument().addDocumentListener(this);\r
             jGuidTextField.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isGuid(jGuidTextField.getText())) {\r
@@ -222,7 +225,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jGuidTextField.getText().equals(sfc.getSpdHdrGuidValue())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrGuidValue(jGuidTextField.getText());\r
                 }\r
             });\r
@@ -241,6 +243,7 @@ public class SpdHeader extends IInternalFrame {
             jVersionTextField = new JTextField();\r
             jVersionTextField.setBounds(new java.awt.Rectangle(valueColumn, rowThree, valueWidth, oneRowHeight));\r
             jVersionTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
+            jVersionTextField.getDocument().addDocumentListener(this);\r
             jVersionTextField.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isVersion(jVersionTextField.getText())) {\r
@@ -250,7 +253,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jVersionTextField.getText().equals(sfc.getSpdHdrVer())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrVer(jVersionTextField.getText());\r
                 }\r
             });\r
@@ -283,8 +285,8 @@ public class SpdHeader extends IInternalFrame {
     private JTextArea getJLicenseTextArea() {\r
         if (jLicenseTextArea == null) {\r
             jLicenseTextArea = new JTextArea();\r
-            //            jLicenseTextArea.setText("");\r
             jLicenseTextArea.setLineWrap(true);\r
+            jLicenseTextArea.getDocument().addDocumentListener(this);\r
             jLicenseTextArea.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (jLicenseTextArea.getText().length() == 0) {\r
@@ -294,7 +296,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jLicenseTextArea.getText().equals(sfc.getSpdHdrLicense())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrLicense(jLicenseTextArea.getText());\r
                 }\r
             });\r
@@ -312,6 +313,7 @@ public class SpdHeader extends IInternalFrame {
         if (jDescriptionTextArea == null) {\r
             jDescriptionTextArea = new JTextArea();\r
             jDescriptionTextArea.setLineWrap(true);\r
+            jDescriptionTextArea.getDocument().addDocumentListener(this);\r
             jDescriptionTextArea.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (jDescriptionTextArea.getText().length() == 0) {\r
@@ -323,7 +325,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jDescriptionTextArea.getText().equals(sfc.getSpdHdrDescription())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrDescription(jDescriptionTextArea.getText());\r
                 }\r
             });\r
@@ -400,6 +401,7 @@ public class SpdHeader extends IInternalFrame {
             jAbstractTextField = new JTextField();\r
             jAbstractTextField.setBounds(new java.awt.Rectangle(valueColumn, rowSeven, valueWidth, oneRowHeight));\r
             jAbstractTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
+            jAbstractTextField.getDocument().addDocumentListener(this);\r
             jAbstractTextField.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isAbstract(jAbstractTextField.getText())) {\r
@@ -409,7 +411,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jAbstractTextField.getText().equals(sfc.getSpdHdrAbs())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrAbs(jAbstractTextField.getText());\r
                 }\r
             });\r
@@ -438,6 +439,7 @@ public class SpdHeader extends IInternalFrame {
             jCopyrightTextArea = new JTextArea();\r
             jCopyrightTextArea.setWrapStyleWord(true);\r
             jCopyrightTextArea.setLineWrap(true);\r
+            jCopyrightTextArea.getDocument().addDocumentListener(this);\r
             jCopyrightTextArea.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {\r
@@ -447,7 +449,6 @@ public class SpdHeader extends IInternalFrame {
                     if (jCopyrightTextArea.getText().equals(sfc.getSpdHdrCopyright())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     sfc.setSpdHdrCopyright(jCopyrightTextArea.getText());\r
                 }\r
             });\r
@@ -465,6 +466,7 @@ public class SpdHeader extends IInternalFrame {
             jUrlTextField = new JTextField();\r
             jUrlTextField.setBounds(new java.awt.Rectangle(valueColumn, rowSix, valueWidth, oneRowHeight));\r
             jUrlTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
+            jUrlTextField.getDocument().addDocumentListener(this);\r
             jUrlTextField.addFocusListener(new FocusAdapter() {\r
                 public void focusLost(FocusEvent e) {\r
                     if (jUrlTextField.getText().length() == 0 && sfc.getSpdHdrUrl() == null) {\r
@@ -475,7 +477,6 @@ public class SpdHeader extends IInternalFrame {
                     }\r
                     sfc.setSpdHdrLicense(jLicenseTextArea.getText());\r
                     sfc.setSpdHdrUrl(jUrlTextField.getText());\r
-                    docConsole.setSaved(false);\r
                 }\r
             });\r
         }\r
@@ -731,7 +732,6 @@ public class SpdHeader extends IInternalFrame {
         if (arg0.getSource() == jGenerateGuidButton) {\r
             //ToDo: invoke GuidValueEditor\r
             jGuidTextField.setText(Tools.generateUuidString());\r
-            docConsole.setSaved(false);\r
             sfc.setSpdHdrGuidValue(jGuidTextField.getText());\r
         }\r
     }\r
@@ -785,4 +785,32 @@ public class SpdHeader extends IInternalFrame {
         }\r
         return topScrollPane;\r
     }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)\r
+     */\r
+    public void changedUpdate(DocumentEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)\r
+     */\r
+    public void insertUpdate(DocumentEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        if (docConsole != null) {\r
+            docConsole.setSaved(false);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)\r
+     */\r
+    public void removeUpdate(DocumentEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        if (docConsole != null) {\r
+            docConsole.setSaved(false);    \r
+        }\r
+    }\r
 }\r
index a59b2d4f792b5f6078ab37ac623fafade111942a..82a3ded696cd50b1471073e2fc5f6cca528b5b1d 100644 (file)
@@ -389,9 +389,9 @@ public class FpdFileContents {
         int pcdCount = getPcdDataCount(seqModuleSa);\r
         String[][] saaModuleSaPcd = new String[pcdCount][7];\r
         getPcdData(seqModuleSa, saaModuleSaPcd);\r
-        String mg = moduleSa.getModuleGuid();\r
+        String mg = moduleSa.getModuleGuid().toLowerCase();\r
         String mv = moduleSa.getModuleVersion();\r
-        String pg = moduleSa.getPackageGuid();\r
+        String pg = moduleSa.getPackageGuid().toLowerCase();\r
         String pv = moduleSa.getPackageVersion();\r
         String arch = listToString(moduleSa.getSupArchList());\r
         //\r
@@ -440,7 +440,7 @@ public class FpdFileContents {
                     ArrayList<String> al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName());\r
                     if (al != null) {\r
                         for (int j = 0; j < al.size(); ++j) {\r
-                            if (al.get(j).contains(moduleKey)) {\r
+                            if (al.get(j).startsWith(moduleKey)) {\r
                                 continue msaPcdIter;\r
                             }\r
                         }\r
@@ -462,7 +462,7 @@ public class FpdFileContents {
                                                                         : msaPcd.getDefaultValue();\r
 \r
                     genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(),\r
-                               msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa);\r
+                               msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa, spdPcd);\r
                     dataModified = true;\r
                  }\r
 \r
@@ -607,54 +607,49 @@ public class FpdFileContents {
      * @param sa Results: HelpText, Original item type.\r
      * @return\r
      */\r
-    public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{\r
-        try {\r
-           \r
-            ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r
-            if (msa.getPcdCoded() == null) {\r
-                return false;\r
+    public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa, Vector<String> validPcdTypes) throws Exception{\r
+       \r
+        ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r
+                                                                                                                        .getModuleXmlObject(mi);\r
+        if (msa.getPcdCoded() == null) {\r
+            return false;\r
+        }\r
+\r
+        PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r
+        //\r
+        // First look through MSA pcd entries.\r
+        //\r
+        List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r
+        ListIterator li = l.listIterator();\r
+        while (li.hasNext()) {\r
+            PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r
+            if (!msaPcd.getCName().equals(cName)) {\r
+                continue;\r
             }\r
-            \r
-            Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
-            m.put("ModuleSurfaceArea", msa);\r
-            SurfaceAreaQuery.setDoc(m);\r
-            PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r
-            //\r
-            // First look through MSA pcd entries.\r
-            //\r
-            List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r
-            ListIterator li = l.listIterator();\r
-            while(li.hasNext()) {\r
-                PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r
-                if (!msaPcd.getCName().equals(cName)) {\r
-                    continue;\r
-                }\r
-                if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {\r
-                    continue;\r
-                }\r
-                PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
-                if (spdPcd == null) {\r
-                    //\r
-                    // ToDo Error \r
-                    //\r
-                    throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r
-                }\r
+            if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {\r
+                continue;\r
+            }\r
+            PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
+            if (spdPcd == null || spdPcd.getValidUsage() == null) {\r
                 //\r
-                // Get Pcd help text and original item type.\r
+                // ToDo Error \r
                 //\r
-                sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();\r
-                sa[1] = msaPcd.getPcdItemType()+"";\r
-                sa[2] = msa.getModuleDefinitions().getBinaryModule()+"";\r
-                return true;\r
+                throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r
             }\r
-            \r
-            \r
-        }\r
-        catch (Exception e){\r
-            e.printStackTrace();\r
-            throw e;\r
+            //\r
+            // Get Pcd help text and original item type.\r
+            //\r
+            sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();\r
+            sa[1] = msaPcd.getPcdItemType() + "";\r
+            sa[2] = msa.getModuleDefinitions().getBinaryModule() + "";\r
+            ListIterator iter = spdPcd.getValidUsage().listIterator();\r
+            while (iter.hasNext()) {\r
+                String usage = iter.next().toString();\r
+                validPcdTypes.add(usage);\r
+            }\r
+            return true;\r
         }\r
-        \r
+\r
         return false;\r
     }\r
     \r
@@ -1151,46 +1146,40 @@ public class FpdFileContents {
     public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r
         //ToDo add Arch filter\r
         \r
-        try {\r
-            if (moduleSa == null) {\r
-                moduleSa = genModuleSA(mi, arch);\r
-            }\r
-            \r
-            ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r
-            if (msa.getPcdCoded() == null) {\r
-                return;\r
-            }\r
-            \r
-            Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
-            m.put("ModuleSurfaceArea", msa);\r
-            SurfaceAreaQuery.setDoc(m);\r
-            PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r
-            //\r
-            // Implementing InitializePlatformPcdBuildDefinitions\r
-            //\r
-            List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r
-            ListIterator li = l.listIterator();\r
-            while(li.hasNext()) {\r
-                PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r
-                PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
-                if (spdPcd == null) {\r
-                    //\r
-                    // ToDo Error \r
-                    //\r
-                    throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r
-                }\r
+        if (moduleSa == null) {\r
+            moduleSa = genModuleSA(mi, arch);\r
+        }\r
+\r
+        ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r
+                                                                                                                        .getModuleXmlObject(mi);\r
+        if (msa.getPcdCoded() == null) {\r
+            return;\r
+        }\r
+\r
+        PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r
+        //\r
+        // Implementing InitializePlatformPcdBuildDefinitions\r
+        //\r
+        List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r
+        ListIterator li = l.listIterator();\r
+        while (li.hasNext()) {\r
+            PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r
+            PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
+            if (spdPcd == null) {\r
                 //\r
-                // AddItem to ModuleSA PcdBuildDefinitions\r
+                // ToDo Error \r
                 //\r
-                String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r
-                \r
-                genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r
+                throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r
+                                          + mi.getName());\r
             }\r
-            \r
-        }\r
-        catch (Exception e){\r
-            \r
-            throw e; \r
+            //\r
+            // AddItem to ModuleSA PcdBuildDefinitions\r
+            //\r
+            String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r
+\r
+            genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType()\r
+                                                                                                    .toString(),\r
+                       spdPcd.getDatumType() + "", defaultVal, moduleSa, spdPcd);\r
         }\r
         \r
     }\r
@@ -1251,7 +1240,25 @@ public class FpdFileContents {
         return msa;\r
     }\r
     \r
-    private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r
+    private String chooseDefaultPcdType (List validPcdTypes) {\r
+        String choosedType = "";\r
+        if (validPcdTypes.contains("FIXED_AT_BUILD")) {\r
+            choosedType = "FIXED_AT_BUILD";\r
+        }\r
+        else if (validPcdTypes.contains("DYNAMIC")) {\r
+            choosedType = "DYNAMIC";\r
+        }\r
+        else if (validPcdTypes.contains("PATCHABLE_IN_MODULE")) {\r
+            choosedType = "PATCHABLE_IN_MODULE";\r
+        }\r
+        else if (validPcdTypes.contains("DYNAMIC_EX")) {\r
+            choosedType = "DYNAMIC_EX";\r
+        }\r
+        return choosedType;\r
+    }\r
+    \r
+    private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, \r
+                             ModuleSADocument.ModuleSA moduleSa, PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd) \r
     throws PcdItemTypeConflictException, PcdValueMalFormed{\r
         if (moduleSa.getPcdBuildDefinition() == null){\r
             moduleSa.addNewPcdBuildDefinition();\r
@@ -1275,12 +1282,43 @@ public class FpdFileContents {
                 return;\r
             }\r
         }\r
+        // if pcd type from MSA file is Dynamic\r
+        // we must choose one default type from SPD file for it.\r
+        //\r
+        List validPcdTypes = spdPcd.getValidUsage();\r
         //\r
         // Using existing Pcd type, if this pcd already exists in other ModuleSA\r
         //\r
         if (pcdConsumer.size() > 0) {\r
+            //\r
+            // platform should only contain one type for each pcd.\r
+            //\r
+            String existingItemType = itemType (pcdConsumer.get(0));\r
+            for (int i = 1; i < pcdConsumer.size(); ++i) {\r
+                if (!existingItemType.equals(itemType(pcdConsumer.get(i)))) {\r
+                    throw new PcdItemTypeConflictException (cName, pcdConsumer.get(0), pcdConsumer.get(i));\r
+                }\r
+            }\r
             \r
-            itemType = itemType (pcdConsumer.get(0));\r
+            if (itemType.equals("DYNAMIC")) {\r
+                if (!validPcdTypes.contains(existingItemType)) {\r
+                    throw new PcdItemTypeConflictException(cName, pcdConsumer.get(0));\r
+                }\r
+                itemType = existingItemType;\r
+            }\r
+            else {\r
+                if (!itemType.equals(existingItemType)) {\r
+                    throw new PcdItemTypeConflictException(cName, pcdConsumer.get(0));\r
+                }\r
+            }\r
+        }\r
+        //\r
+        // if this is the first occurence of this pcd. \r
+        //\r
+        else {\r
+            if (itemType.equals("DYNAMIC")) {\r
+                itemType = chooseDefaultPcdType (validPcdTypes);\r
+            }\r
         }\r
         String listValue = moduleInfo + " " + itemType;\r
         pcdConsumer.add(listValue);\r
@@ -3636,9 +3674,36 @@ class PcdItemTypeConflictException extends Exception {
     private static final long serialVersionUID = 1L;\r
     private String details = null;\r
     \r
-    PcdItemTypeConflictException(String pcdName, String info){\r
+    PcdItemTypeConflictException (String pcdName, String info) {\r
         ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r
-        details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();\r
+        if (mi != null) {\r
+            details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();    \r
+        }\r
+        else {\r
+            details = pcdName + " ItemType Conflicts with " + info;\r
+        }\r
+    }\r
+    \r
+    PcdItemTypeConflictException (String pcdName, String info1, String info2) {\r
+        ModuleIdentification mi1 = WorkspaceProfile.getModuleId(info1);\r
+        ModuleIdentification mi2 = WorkspaceProfile.getModuleId(info2);\r
+        String moduleInfo1 = "";\r
+        String moduleInfo2 = "";\r
+        if (mi1 != null) {\r
+            moduleInfo1 = mi1.getName() + " in Pkg " + mi1.getPackageId().getName();\r
+        }\r
+        else {\r
+            moduleInfo1 = info1;\r
+        }\r
+        \r
+        if (mi2 != null) {\r
+            moduleInfo2 = mi2.getName() + " in Pkg " + mi2.getPackageId().getName();\r
+        }\r
+        else {\r
+            moduleInfo2 = info2;\r
+        }\r
+        \r
+        details = pcdName + " ItemType Conflicts in " + moduleInfo1 + " and " + moduleInfo2;\r
     }\r
     \r
     public String getMessage() {\r
index 78ea7d641a7bf48edad8ee1d0a6369af5fd116ca..7c41dd96234c1d368041443b0344c37152f45efc 100644 (file)
@@ -665,6 +665,7 @@ public class FpdFrameworkModules extends IInternalFrame {
     private void showSettingsDlg (int row) {\r
         try {\r
             if (ffc.adjustPcd(row)) {\r
+                JOptionPane.showMessageDialog(frame, "Pcd entries sync. with those in MSA files.");\r
                 docConsole.setSaved(false);\r
             }\r
         }\r
index bcb0e6f5c99084e3028a965710db0432cf9e0e93..06a376bfc53dc9dd6cbcbf2a59ba3c4e0c3754e4 100644 (file)
@@ -30,6 +30,8 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;\r
 import javax.swing.JTextArea;\r
 import javax.swing.JTextField;\r
+import javax.swing.event.DocumentEvent;\r
+import javax.swing.event.DocumentListener;\r
 \r
 \r
 \r
@@ -48,7 +50,7 @@ import org.tianocore.frameworkwizard.common.ui.StarLabel;
  @since PackageEditor 1.0\r
 \r
  **/\r
-public class FpdHeader extends IInternalFrame {\r
+public class FpdHeader extends IInternalFrame implements DocumentListener{\r
 \r
     private int dialogWidth = 560;\r
 \r
@@ -181,6 +183,7 @@ public class FpdHeader extends IInternalFrame {
             jTextFieldBaseName = new JTextField();\r
             jTextFieldBaseName.setBounds(new java.awt.Rectangle(valueColumn, rowOne, valueWidth, oneRowHeight));\r
             jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(valueWidth,oneRowHeight));\r
+            jTextFieldBaseName.getDocument().addDocumentListener(this);\r
             jTextFieldBaseName.addFocusListener(new FocusAdapter(){\r
                public void focusLost(FocusEvent e) {\r
                    if (!DataValidation.isUiNameType(jTextFieldBaseName.getText())) {\r
@@ -190,7 +193,6 @@ public class FpdHeader extends IInternalFrame {
                    if (jTextFieldBaseName.getText().equals(ffc.getFpdHdrPlatformName())) {\r
                        return;\r
                    }\r
-                   docConsole.setSaved(false);\r
                    ffc.setFpdHdrPlatformName(jTextFieldBaseName.getText());\r
                } \r
             });\r
@@ -209,6 +211,7 @@ public class FpdHeader extends IInternalFrame {
             jTextFieldGuid = new JTextField();\r
             jTextFieldGuid.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, shortValueWidth, oneRowHeight));\r
             jTextFieldGuid.setPreferredSize(new java.awt.Dimension(shortValueWidth,oneRowHeight));\r
+            jTextFieldGuid.getDocument().addDocumentListener(this);\r
             jTextFieldGuid.addFocusListener(new FocusAdapter(){\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isGuid(jTextFieldGuid.getText())) {\r
@@ -218,7 +221,6 @@ public class FpdHeader extends IInternalFrame {
                     if (jTextFieldGuid.getText().equals(ffc.getFpdHdrGuidValue())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     ffc.setFpdHdrGuidValue(jTextFieldGuid.getText());\r
                 } \r
              });\r
@@ -237,6 +239,7 @@ public class FpdHeader extends IInternalFrame {
             jTextFieldVersion = new JTextField();\r
             jTextFieldVersion.setBounds(new java.awt.Rectangle(valueColumn, rowThree, valueWidth, oneRowHeight));\r
             jTextFieldVersion.setPreferredSize(new java.awt.Dimension(valueWidth,oneRowHeight));\r
+            jTextFieldVersion.getDocument().addDocumentListener(this);\r
             jTextFieldVersion.addFocusListener(new FocusAdapter(){\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isVersion(jTextFieldVersion.getText())) {\r
@@ -246,7 +249,6 @@ public class FpdHeader extends IInternalFrame {
                     if (jTextFieldVersion.getText().equals(ffc.getFpdHdrVer())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     ffc.setFpdHdrVer(jTextFieldVersion.getText());\r
                 } \r
              });\r
@@ -281,6 +283,7 @@ public class FpdHeader extends IInternalFrame {
             jTextAreaLicense = new JTextArea();\r
             jTextAreaLicense.setText("");\r
             jTextAreaLicense.setLineWrap(true);\r
+            jTextAreaLicense.getDocument().addDocumentListener(this);\r
             jTextAreaLicense.addFocusListener(new FocusAdapter(){\r
                 public void focusLost(FocusEvent e) {\r
                     if (jTextAreaLicense.getText().length() == 0) {\r
@@ -290,7 +293,6 @@ public class FpdHeader extends IInternalFrame {
                     if (jTextAreaLicense.getText().equals(ffc.getFpdHdrLicense())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     ffc.setFpdHdrLicense(jTextAreaLicense.getText());\r
                 } \r
              });\r
@@ -308,6 +310,7 @@ public class FpdHeader extends IInternalFrame {
         if (jTextAreaDescription == null) {\r
             jTextAreaDescription = new JTextArea();\r
             jTextAreaDescription.setLineWrap(true);\r
+            jTextAreaDescription.getDocument().addDocumentListener(this);\r
             jTextAreaDescription.addFocusListener(new FocusAdapter(){\r
                 public void focusLost(FocusEvent e) {\r
                     if (jTextAreaDescription.getText().length() == 0) {\r
@@ -317,7 +320,6 @@ public class FpdHeader extends IInternalFrame {
                     if (jTextAreaDescription.getText().equals(ffc.getFpdHdrDescription())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     ffc.setFpdHdrDescription(jTextAreaDescription.getText());\r
                 } \r
              });\r
@@ -338,11 +340,11 @@ public class FpdHeader extends IInternalFrame {
             jTextFieldSpecification.setEditable(false);\r
             jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(specWidth,oneRowHeight));\r
             jTextFieldSpecification.setBorder(null);\r
-            jTextFieldSpecification.addFocusListener(new FocusAdapter(){\r
-                public void focusLost(FocusEvent e) {\r
-                    ffc.setFpdHdrSpec(jTextFieldSpecification.getText());\r
-                } \r
-             });\r
+//            jTextFieldSpecification.addFocusListener(new FocusAdapter(){\r
+//                public void focusLost(FocusEvent e) {\r
+//                    ffc.setFpdHdrSpec(jTextFieldSpecification.getText());\r
+//                } \r
+//             });\r
         }\r
         return jTextFieldSpecification;\r
     }\r
@@ -426,6 +428,7 @@ public class FpdHeader extends IInternalFrame {
             jTextFieldAbstract = new JTextField();\r
             jTextFieldAbstract.setBounds(new java.awt.Rectangle(valueColumn,rowSeven,valueWidth,oneRowHeight));\r
             jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));\r
+            jTextFieldAbstract.getDocument().addDocumentListener(this);\r
             jTextFieldAbstract.addFocusListener(new FocusAdapter(){\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isAbstract(jTextFieldAbstract.getText())) {\r
@@ -435,7 +438,6 @@ public class FpdHeader extends IInternalFrame {
                     if (jTextFieldAbstract.getText().equals(ffc.getFpdHdrAbs())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     ffc.setFpdHdrAbs(jTextFieldAbstract.getText());\r
                 } \r
              });\r
@@ -464,6 +466,7 @@ public class FpdHeader extends IInternalFrame {
             jCopyrightTextArea = new JTextArea();\r
             jCopyrightTextArea.setWrapStyleWord(true);\r
             jCopyrightTextArea.setLineWrap(true);\r
+            jCopyrightTextArea.getDocument().addDocumentListener(this);\r
             jCopyrightTextArea.addFocusListener(new FocusAdapter(){\r
                 public void focusLost(FocusEvent e) {\r
                     if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {\r
@@ -473,7 +476,6 @@ public class FpdHeader extends IInternalFrame {
                     if (jCopyrightTextArea.getText().equals(ffc.getFpdHdrCopyright())) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
                     ffc.setFpdHdrCopyright(jCopyrightTextArea.getText());\r
                 } \r
              });\r
@@ -491,6 +493,7 @@ public class FpdHeader extends IInternalFrame {
             jTextFieldUrl = new JTextField();\r
             jTextFieldUrl.setBounds(new java.awt.Rectangle(valueColumn,rowSix,valueWidth,oneRowHeight));\r
             jTextFieldUrl.setPreferredSize(new Dimension(valueWidth, oneRowHeight));\r
+            jTextFieldUrl.getDocument().addDocumentListener(this);\r
             jTextFieldUrl.addFocusListener(new FocusAdapter(){\r
                public void focusLost(FocusEvent e){\r
                    if (jTextFieldUrl.getText().length() == 0 && ffc.getFpdHdrUrl() == null) {\r
@@ -501,7 +504,6 @@ public class FpdHeader extends IInternalFrame {
                    }\r
                    ffc.setFpdHdrLicense(jTextAreaLicense.getText());\r
                    ffc.setFpdHdrUrl(jTextFieldUrl.getText());\r
-                   docConsole.setSaved(false);\r
                } \r
             });\r
         }\r
@@ -717,7 +719,6 @@ public class FpdHeader extends IInternalFrame {
     public void actionPerformed(ActionEvent arg0) {\r
         \r
         if (arg0.getSource() == jButtonGenerateGuid) {\r
-            docConsole.setSaved(false);\r
             jTextFieldGuid.setText(Tools.generateUuidString());\r
             ffc.setFpdHdrGuidValue(jTextFieldGuid.getText());\r
         }\r
@@ -756,4 +757,32 @@ public class FpdHeader extends IInternalFrame {
                \r
         \r
        }\r
+    \r
+    /* (non-Javadoc)\r
+     * @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)\r
+     */\r
+    public void changedUpdate(DocumentEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)\r
+     */\r
+    public void insertUpdate(DocumentEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        if (docConsole != null) {\r
+            docConsole.setSaved(false);\r
+        }\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)\r
+     */\r
+    public void removeUpdate(DocumentEvent arg0) {\r
+        // TODO Auto-generated method stub\r
+        if (docConsole != null) {\r
+            docConsole.setSaved(false);    \r
+        }\r
+    }\r
 }\r
index 917585908ca0192258ed9dd374d66d2a4ba3bd06..8f6d31057f6956589ed9692086201246b8c2f15f 100644 (file)
@@ -282,8 +282,9 @@ public class FpdModuleSA extends JDialog implements ActionListener {
             return;\r
         }\r
         \r
-        for (int j = 0; j < v.size(); ++j) {\r
-            LibraryClassDescriptor libInfo = v.get(j);\r
+        Iterator<LibraryClassDescriptor> iter = v.iterator();\r
+        while (iter.hasNext()) {\r
+            LibraryClassDescriptor libInfo = iter.next();\r
 \r
             Vector<String> vSupArchs = libInfo.getVectorFromString(libInfo.supArchs);\r
             \r
@@ -318,7 +319,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
             //\r
             // remove this lib definition if it supports no archs module will be built under.\r
             //\r
-            v.iterator().remove();\r
+            iter.remove();\r
         }\r
     }\r
     \r
@@ -712,9 +713,10 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                         // array for pcd related information: helpText, itemType, moduleType.\r
                         //\r
                         String[] pcdInfo = {"", "", ""};\r
-                        getPcdInfo(cName, tsGuid, pcdInfo);\r
+                        Vector<String> validPcdTypes = new Vector<String>();\r
+                        getPcdInfo(moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);\r
                         jTextAreaPcdHelp.setText(pcdInfo[0]);\r
-                        initComboBox(pcdInfo[1], pcdInfo[2]);\r
+                        initComboBox(pcdInfo[1], pcdInfo[2], validPcdTypes);\r
                         jComboBoxItemType.setSelectedItem(itemType);\r
                         jTextFieldMaxDatumSize.setEnabled(true);\r
                         jTextFieldMaxDatumSize.setVisible(true);\r
@@ -768,15 +770,16 @@ public class FpdModuleSA extends JDialog implements ActionListener {
         return jTablePcd;\r
     }\r
     \r
-    private void initComboBox(String originalType, String mType) {\r
+    private void initComboBox(String originalType, String mType, Vector<String> validPcdTypes) {\r
         jComboBoxItemType.removeAllItems();\r
-        jComboBoxItemType.addItem(originalType);\r
-        if (originalType.equals("PATCHABLE_IN_MODULE") && mType.equalsIgnoreCase("false")) {\r
-            jComboBoxItemType.addItem("FIXED_AT_BUILD");\r
-        }\r
+\r
         if (originalType.equals("DYNAMIC")) {\r
-            jComboBoxItemType.addItem("FIXED_AT_BUILD");\r
-            jComboBoxItemType.addItem("PATCHABLE_IN_MODULE");\r
+            for (int i = 0; i < validPcdTypes.size(); ++i) {\r
+                jComboBoxItemType.addItem(validPcdTypes.get(i));\r
+            }\r
+        }\r
+        else {\r
+            jComboBoxItemType.addItem(originalType);\r
         }\r
     }\r
     \r
@@ -785,17 +788,17 @@ public class FpdModuleSA extends JDialog implements ActionListener {
      * @param tsGuid\r
      * @param sa sa[0]: HelpText; sa[1]: itemType in Msa; sa[2]: isBinary;\r
      */\r
-    private void getPcdInfo(String cName, String tsGuid, String[] sa) {\r
+    private void getPcdInfo(String moduleKey, String cName, String tsGuid, String[] sa, Vector<String> validPcdTypes) {\r
         String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];\r
         ffc.getLibraryInstances(moduleKey, saa);\r
         \r
         try{\r
-            if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa)) {\r
+            if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa, validPcdTypes)) {\r
                 return;\r
             }\r
             for (int j = 0; j < saa.length; ++j) {\r
                 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),\r
-                                            cName, tsGuid, sa)) {\r
+                                            cName, tsGuid, sa, validPcdTypes)) {\r
                     return;\r
                 }\r
             }\r
@@ -1657,26 +1660,25 @@ private JComboBox getJComboBoxItemType() {
     if (jComboBoxItemType == null) {\r
         jComboBoxItemType = new JComboBox();\r
         jComboBoxItemType.setPreferredSize(new java.awt.Dimension(200,20));\r
-        jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() {\r
-            public void itemStateChanged(java.awt.event.ItemEvent e) {\r
-                int row = jTablePcd.getSelectedRow();\r
-                if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) {\r
-                    return;\r
-                }\r
-                if (jComboBoxItemType.getItemCount() == 3) {\r
-                    if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) {\r
-                        \r
-                        if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {\r
-                            jTextFieldPcdDefault.setText("");\r
-                            jTextFieldPcdDefault.setEnabled(true);\r
-                        }\r
-                    }\r
-                    else{\r
-                        \r
-                    }\r
-                }\r
-            }\r
-        });\r
+//        jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() {\r
+//            public void itemStateChanged(java.awt.event.ItemEvent e) {\r
+//                \r
+//                int row = jTablePcd.getSelectedRow();\r
+//                if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) {\r
+//                    return;\r
+//                }\r
+//                    if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) {\r
+//                        \r
+//                        if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {\r
+//                            jTextFieldPcdDefault.setText("");\r
+//                            jTextFieldPcdDefault.setEnabled(true);\r
+//                        }\r
+//                    }\r
+//                    else{\r
+//                        \r
+//                    }\r
+//                }\r
+//        });\r
     }\r
     return jComboBoxItemType;\r
 }\r
@@ -1698,8 +1700,8 @@ private void pcdDynamicToNonDynamic(String cName, String tsGuid) {
     for (int i = 0; i < al.size(); ++i) {\r
         String mKey = moduleInfo (al.get(i));\r
         value = null;\r
-        ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", maxSize, value);\r
         String itemType = jComboBoxItemType.getSelectedItem()+"";\r
+        ffc.updatePcdData(mKey, cName, tsGuid, itemType, maxSize, value);\r
         al.set(i, mKey + " " + itemType);\r
     }\r
     \r
@@ -1710,8 +1712,8 @@ private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
     ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
     for (int i = 0; i < al.size(); ++i) {\r
         String mKey = moduleInfo (al.get(i));\r
-        ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");\r
         String itemType = jComboBoxItemType.getSelectedItem()+"";\r
+        ffc.updatePcdData(mKey, cName, tsGuid, itemType, jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");\r
         al.set(i, mKey + " " + itemType);\r
     }\r
     try{\r
@@ -1722,6 +1724,16 @@ private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
     }\r
 }\r
 \r
+private void changePcdTypeWithinSameCategory (String cName, String tsGuid) {\r
+    ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
+    for (int i = 0; i < al.size(); ++i) {\r
+        String mKey = moduleInfo (al.get(i));\r
+        String itemType = jComboBoxItemType.getSelectedItem()+"";\r
+        ffc.updatePcdData(mKey, cName, tsGuid, itemType, null, null);\r
+        al.set(i, mKey + " " + itemType);\r
+    }\r
+}\r
+\r
 private String moduleInfo (String pcdInfo) {\r
     \r
     return pcdInfo.substring(0, pcdInfo.lastIndexOf(" "));\r
@@ -1767,14 +1779,17 @@ private JButton getJButtonUpdatePcd() {
                 if (row < 0) {\r
                     return;\r
                 }\r
-                docConsole.setSaved(false);\r
+                \r
+                String cName = model.getValueAt(row, 0)+"";\r
+                String tsGuid = model.getValueAt(row, 1)+"";\r
                 String oldItemType = model.getValueAt(row, 2)+"";\r
                 String newItemType = jComboBoxItemType.getSelectedItem()+"";\r
-                model.setValueAt(newItemType, row, 2);\r
+                \r
                 model.setValueAt(jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem(), row, 6);\r
                 \r
                 String[] pcdInfo = {"", "", ""};\r
-                getPcdInfo (model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", pcdInfo);\r
+                Vector<String> validPcdTypes = new Vector<String>();\r
+                getPcdInfo (moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);\r
                 if (pcdInfo[1].equals("FIXED_AT_BUILD") && model.getValueAt(row, 5).equals("VOID*")) {\r
                     try {\r
                         jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(row, 6)+"")+"");\r
@@ -1786,18 +1801,62 @@ private JButton getJButtonUpdatePcd() {
                 }\r
                 model.setValueAt(jTextFieldMaxDatumSize.getText(), row, 4);\r
                 \r
-                if (oldItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC")) {\r
-                    pcdDynamicToNonDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"");\r
-                }\r
-                if (!oldItemType.equals("DYNAMIC") && newItemType.equals("DYNAMIC")) {\r
-                    pcdNonDynamicToDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"");\r
+                if (newItemType != oldItemType) {\r
+                    Vector<ModuleIdentification> moduleInfo = new Vector<ModuleIdentification>();\r
+                    try {\r
+                        boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo);\r
+                        if (!changable) {\r
+                            JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName());\r
+                            return;\r
+                        }\r
+                    }\r
+                    catch (Exception exp) {\r
+                        JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage());\r
+                        return;\r
+                    }\r
+                    \r
+                    if ((oldItemType.equals("DYNAMIC") || oldItemType.equals("DYNAMIC_EX")) && !newItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC_EX")) {\r
+                        pcdDynamicToNonDynamic(cName, tsGuid);\r
+                    }\r
+                    if (!oldItemType.equals("DYNAMIC") && !oldItemType.equals("DYNAMIC_EX") && (newItemType.equals("DYNAMIC") || newItemType.equals("DYNAMIC_EX"))) {\r
+                        pcdNonDynamicToDynamic(cName, tsGuid);\r
+                    }\r
+                    else {\r
+                        changePcdTypeWithinSameCategory (cName, tsGuid);\r
+                    }\r
+                    model.setValueAt(newItemType, row, 2);\r
                 }\r
-                ffc.updatePcdData(moduleKey, model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");\r
+                \r
+                ffc.updatePcdData(moduleKey, cName, tsGuid, model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");\r
+                docConsole.setSaved(false);\r
             }\r
         });\r
     }\r
     return jButtonUpdatePcd;\r
 }\r
+\r
+private boolean itemTypeCouldBeChanged (String cName, String tsGuid, String newItemType, Vector<ModuleIdentification> mi) throws Exception{\r
+    ArrayList<String> pcdConsumers = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
+    for (int i = 0; i < pcdConsumers.size(); ++i) {\r
+        String consumerInfo = moduleInfo (pcdConsumers.get(i));\r
+        mi.removeAllElements();\r
+        mi.add(WorkspaceProfile.getModuleId(consumerInfo));\r
+        String[] sa = {"", "", ""};\r
+        Vector<String> validPcdTypes = new Vector<String>();\r
+        getPcdInfo (consumerInfo, cName, tsGuid, sa, validPcdTypes);\r
+        if (validPcdTypes.size() == 0) {\r
+            return false;\r
+        }\r
+        if (!sa[1].equals("DYNAMIC")) {\r
+            return false;\r
+        }\r
+        if (!validPcdTypes.contains(newItemType)) {\r
+            return false;\r
+        }\r
+    }\r
+    return true;\r
+}\r
+\r
 /**\r
  * This method initializes jComboBoxFeatureFlagValue\r
  *     \r