]> git.proxmox.com Git - mirror_edk2.git/commitdiff
remove comments before ModuleSA and library instance , if any, in xml file when delet...
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 15 Sep 2006 09:13:04 +0000 (09:13 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 15 Sep 2006 09:13:04 +0000 (09:13 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1545 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/FpdFrameworkModules.java

index 946a6b64d9d8a4fea1d1d22d6eda493c4062bca6..b89f967fa3e53000e18993fbbb172b84a1e35dce 100644 (file)
@@ -70,6 +70,7 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification;
 public class FpdFileContents {\r
 \r
     static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r
+    static final String regNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";\r
     \r
     private PlatformSurfaceAreaDocument fpdd = null;\r
     \r
@@ -345,10 +346,21 @@ public class FpdFileContents {
             }\r
             \r
             cursor.push();\r
-            cursor.toPrevToken();\r
+            while (cursor.hasPrevToken()) {\r
+                cursor.toPrevToken();\r
+                if (!cursor.isText()) {\r
+                    break;\r
+                }\r
+                String s = cursor.getTextValue();\r
+                if (s.matches(regNewLineAndSpaces)) {\r
+                    continue;\r
+                }\r
+            }\r
+\r
             if (cursor.isComment()) {\r
                 cursor.removeXml();\r
             }\r
+            \r
             cursor.pop();\r
             cursor.removeXml();\r
             if (getFrameworkModulesCount() == 0) {\r
@@ -655,6 +667,7 @@ public class FpdFileContents {
                 ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);\r
                 if (moduleSA.getPcdBuildDefinition() != null) {\r
                     XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r
+                    cursor.push();\r
                     if (cursor.toFirstChild()) {\r
                         do {\r
                             PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
@@ -669,6 +682,11 @@ public class FpdFileContents {
                             }\r
                         } while (cursor.toNextSibling());\r
                     }\r
+                    \r
+                    cursor.pop();\r
+                    if (moduleSA.getPcdBuildDefinition().getPcdDataList().size() == 0) {\r
+                        cursor.removeXml();\r
+                    }\r
                     cursor.dispose();\r
                 }\r
             }\r
@@ -718,7 +736,17 @@ public class FpdFileContents {
                 cursor.toNextSibling();\r
             }\r
             cursor.push();\r
-            cursor.toPrevToken();\r
+            while (cursor.hasPrevToken()) {\r
+                cursor.toPrevToken();\r
+                if (!cursor.isText()) {\r
+                    break;\r
+                }\r
+                String s = cursor.getTextValue();\r
+                if (s.matches(regNewLineAndSpaces)) {\r
+                    continue;\r
+                }\r
+            }\r
+            \r
             if (cursor.isComment()) {\r
                 cursor.removeXml();\r
             }\r
index b831703235e3519336c60b5c6d1266c9beda48fe..57af40ea0719804cb9b1a75802ffbe2fea297d25 100644 (file)
@@ -614,7 +614,7 @@ public class FpdFrameworkModules extends IInternalFrame {
                     if (selectedRow < 0) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
+                    \r
 \r
                     TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
                     selectedRow = sorter.getModelRowIndex(selectedRow);\r
@@ -627,22 +627,35 @@ public class FpdFrameworkModules extends IInternalFrame {
                     String pv = sa[ffcPkgVer];\r
                     String arch = sa[ffcModArch];\r
                     ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);\r
-                    mv = mi.getVersion();\r
-                    pv = mi.getPackageId().getVersion();\r
-                    modelFpdModules.removeRow(selectedRow);\r
+                    if (mi != null) {\r
+                        mv = mi.getVersion();\r
+                        pv = mi.getPackageId().getVersion();\r
+                    }\r
+                    \r
+                    try {\r
+                        ffc.removeModuleSA(selectedRow);    \r
+                    }\r
+                    catch (Exception exp) {\r
+                        JOptionPane.showMessageDialog(frame, exp.getCause() + exp.getMessage());\r
+                        return;\r
+                    }\r
+                    \r
                     if (arch == null) {\r
                         // if no arch specified in ModuleSA\r
                         fpdMsa.remove(mg + mv + pg + pv);\r
                         \r
                     } else {\r
                         ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);\r
-                        al.remove(arch);\r
-                        if (al.size() == 0) {\r
-                            fpdMsa.remove(mg + mv + pg + pv);\r
+                        if (al != null) {\r
+                            al.remove(arch);\r
+                            if (al.size() == 0) {\r
+                                fpdMsa.remove(mg + mv + pg + pv);\r
+                            }\r
                         }\r
                     }\r
-\r
-                    ffc.removeModuleSA(selectedRow);\r
+                    \r
+                    modelFpdModules.removeRow(selectedRow);\r
+                    docConsole.setSaved(false);\r
                 }\r
             });\r
         }\r