Fix EDKT143.
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 27 Jul 2006 07:40:21 +0000 (07:40 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 27 Jul 2006 07:40:21 +0000 (07:40 +0000)
Add the feature of inserting Xml Comments before ModuleSA elements and library instance elements.

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

Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java

index 6e7c79f..fa0924a 100644 (file)
@@ -286,6 +286,13 @@ public class FpdFileContents {
                     maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo);\r
                 }\r
             }\r
+            \r
+            cursor.push();\r
+            cursor.toPrevToken();\r
+            if (cursor.isComment()) {\r
+                cursor.removeXml();\r
+            }\r
+            cursor.pop();\r
             cursor.removeXml();\r
             if (getFrameworkModulesCount() == 0) {\r
                 cursor.toParent();\r
@@ -448,25 +455,31 @@ public class FpdFileContents {
             while(li.hasNext()) {\r
                 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r
                 ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);\r
-                XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r
-                if (cursor.toFirstChild()) {\r
-                    PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r
-                    if (msaPcd.getCName().equals(pcdData.getCName()) && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
-                        \r
-                        maintainDynPcdMap(pcdData.getCName()+" "+pcdData.getTokenSpaceGuidCName(), moduleKey);\r
-                        cursor.removeXml();\r
-                        break;\r
-                    }\r
-                    while (cursor.toNextSibling()) {\r
-                        pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r
-                        if (msaPcd.getCName().equals(pcdData.getCName()) && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
-                            maintainDynPcdMap(pcdData.getCName()+" "+pcdData.getTokenSpaceGuidCName(), moduleKey);\r
+                if (moduleSA.getPcdBuildDefinition() != null) {\r
+                    XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r
+                    if (cursor.toFirstChild()) {\r
+                        PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
+                                                                                                                                                      .getObject();\r
+                        if (msaPcd.getCName().equals(pcdData.getCName())\r
+                            && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
+\r
+                            maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleKey);\r
                             cursor.removeXml();\r
                             break;\r
                         }\r
+                        while (cursor.toNextSibling()) {\r
+                            pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor.getObject();\r
+                            if (msaPcd.getCName().equals(pcdData.getCName())\r
+                                && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
+                                maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r
+                                                  moduleKey);\r
+                                cursor.removeXml();\r
+                                break;\r
+                            }\r
+                        }\r
                     }\r
+                    cursor.dispose();\r
                 }\r
-                cursor.dispose();\r
             }\r
             \r
         }\r
@@ -513,13 +526,23 @@ public class FpdFileContents {
             for (int j = 0; j < i; ++j) {\r
                 cursor.toNextSibling();\r
             }\r
+            cursor.push();\r
+            cursor.toPrevToken();\r
+            if (cursor.isComment()) {\r
+                cursor.removeXml();\r
+            }\r
+            cursor.pop();\r
             cursor.removeXml();\r
+            if (getLibraryInstancesCount(key) == 0) {\r
+                cursor.toParent();\r
+                cursor.removeXml();\r
+            }\r
         }\r
         \r
         cursor.dispose();\r
     }\r
     \r
-    public void genLibraryInstance(String mg, String mv, String pg, String pv, String key) {\r
+    public void genLibraryInstance(ModuleIdentification libMi, String key) {\r
         ModuleSADocument.ModuleSA msa = getModuleSA(key);\r
         if (msa == null){\r
             msa = getfpdFrameworkModules().addNewModuleSA();\r
@@ -529,7 +552,26 @@ public class FpdFileContents {
             libs = msa.addNewLibraries();\r
         }\r
         \r
+        String mn = libMi.getName();\r
+        String mg = libMi.getGuid();\r
+        String mv = libMi.getVersion();\r
+        String pn = libMi.getPackage().getName();\r
+        String pg = libMi.getPackage().getGuid();\r
+        String pv = libMi.getPackage().getVersion();\r
         LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r
+        XmlCursor cursor = instance.newCursor();\r
+        try{\r
+            String comment = "Pkg: " + pn + " Mod: " + mn \r
+                + " Path: " + GlobalData.getMsaFile(libMi).getPath();\r
+            cursor.insertComment(comment);\r
+        }\r
+        catch (Exception e){\r
+            e.printStackTrace();\r
+        }\r
+        finally {\r
+            cursor.dispose();\r
+        }\r
+        \r
         instance.setModuleGuid(mg);\r
         instance.setModuleVersion(mv);\r
         instance.setPackageGuid(pg);\r
@@ -776,6 +818,18 @@ public class FpdFileContents {
     private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {\r
         PackageIdentification pi = GlobalData.getPackageForModule(mi);\r
         ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r
+        XmlCursor cursor = msa.newCursor();\r
+        try{\r
+            String comment = "Mod: " + mi.getName() + " Type: " + mi.getModuleType() + " Path: "\r
+                            + GlobalData.getMsaFile(mi).getPath();\r
+            cursor.insertComment(comment);\r
+        }\r
+        catch(Exception e){\r
+            e.printStackTrace();\r
+        }\r
+        finally { \r
+            cursor.dispose();\r
+        }\r
         msa.setModuleGuid(mi.getGuid());\r
         msa.setModuleVersion(mi.getVersion());\r
         msa.setPackageGuid(pi.getGuid());\r
index d90d079..5164c0f 100644 (file)
@@ -328,7 +328,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
         //\r
         // remove pcd information of instance from current ModuleSA\r
         //\r
-        ffc.removePcdData(key, mi);\r
+        ffc.removePcdData(moduleKey, mi);\r
         //\r
         // remove class produced by this instance and add back these produced class to be bound.\r
         //\r
@@ -1018,12 +1018,13 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     model3.getValueAt(row, 2) + " " +\r
                     model3.getValueAt(row, 3) + " " +\r
                     model3.getValueAt(row, 4);\r
-                    ffc.genLibraryInstance(model3.getValueAt(row, 1)+"", model3.getValueAt(row, 2)+"", model3.getValueAt(row, 3)+"", model3.getValueAt(row, 4)+"", moduleKey);\r
+                    ModuleIdentification libMi = getModuleId(instanceValue);\r
+                    ffc.genLibraryInstance(libMi, moduleKey);\r
                     //\r
                     // Add pcd information of selected instance to current moduleSA\r
                     //\r
                     try{\r
-                        ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), null, ffc.getModuleSA(moduleKey));\r
+                        ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));\r
                     }\r
                     catch (Exception exception) {\r
                         JOptionPane.showMessageDialog(frame, "PCD Insertion Fail. " + exception.getMessage());\r