remove comments before ModuleSA and library instance , if any, in xml file when deleting a module or instance from FPD file.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1545 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
		| @@ -70,6 +70,7 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification; | ||||
| public class FpdFileContents { | ||||
|  | ||||
|     static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0"; | ||||
|     static final String regNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*"; | ||||
|      | ||||
|     private PlatformSurfaceAreaDocument fpdd = null; | ||||
|      | ||||
| @@ -345,10 +346,21 @@ public class FpdFileContents { | ||||
|             } | ||||
|              | ||||
|             cursor.push(); | ||||
|             while (cursor.hasPrevToken()) { | ||||
|                 cursor.toPrevToken(); | ||||
|                 if (!cursor.isText()) { | ||||
|                     break; | ||||
|                 } | ||||
|                 String s = cursor.getTextValue(); | ||||
|                 if (s.matches(regNewLineAndSpaces)) { | ||||
|                     continue; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             if (cursor.isComment()) { | ||||
|                 cursor.removeXml(); | ||||
|             } | ||||
|              | ||||
|             cursor.pop(); | ||||
|             cursor.removeXml(); | ||||
|             if (getFrameworkModulesCount() == 0) { | ||||
| @@ -655,6 +667,7 @@ public class FpdFileContents { | ||||
|                 ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey); | ||||
|                 if (moduleSA.getPcdBuildDefinition() != null) { | ||||
|                     XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor(); | ||||
|                     cursor.push(); | ||||
|                     if (cursor.toFirstChild()) { | ||||
|                         do { | ||||
|                             PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor | ||||
| @@ -669,6 +682,11 @@ public class FpdFileContents { | ||||
|                             } | ||||
|                         } while (cursor.toNextSibling()); | ||||
|                     } | ||||
|                      | ||||
|                     cursor.pop(); | ||||
|                     if (moduleSA.getPcdBuildDefinition().getPcdDataList().size() == 0) { | ||||
|                         cursor.removeXml(); | ||||
|                     } | ||||
|                     cursor.dispose(); | ||||
|                 } | ||||
|             } | ||||
| @@ -718,7 +736,17 @@ public class FpdFileContents { | ||||
|                 cursor.toNextSibling(); | ||||
|             } | ||||
|             cursor.push(); | ||||
|             while (cursor.hasPrevToken()) { | ||||
|                 cursor.toPrevToken(); | ||||
|                 if (!cursor.isText()) { | ||||
|                     break; | ||||
|                 } | ||||
|                 String s = cursor.getTextValue(); | ||||
|                 if (s.matches(regNewLineAndSpaces)) { | ||||
|                     continue; | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|             if (cursor.isComment()) { | ||||
|                 cursor.removeXml(); | ||||
|             } | ||||
|   | ||||
| @@ -614,7 +614,7 @@ public class FpdFrameworkModules extends IInternalFrame { | ||||
|                     if (selectedRow < 0) { | ||||
|                         return; | ||||
|                     } | ||||
|                     docConsole.setSaved(false); | ||||
|                      | ||||
|  | ||||
|                     TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); | ||||
|                     selectedRow = sorter.getModelRowIndex(selectedRow); | ||||
| @@ -627,22 +627,35 @@ public class FpdFrameworkModules extends IInternalFrame { | ||||
|                     String pv = sa[ffcPkgVer]; | ||||
|                     String arch = sa[ffcModArch]; | ||||
|                     ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch); | ||||
|                     if (mi != null) { | ||||
|                         mv = mi.getVersion(); | ||||
|                         pv = mi.getPackageId().getVersion(); | ||||
|                     modelFpdModules.removeRow(selectedRow); | ||||
|                     } | ||||
|                      | ||||
|                     try { | ||||
|                         ffc.removeModuleSA(selectedRow);     | ||||
|                     } | ||||
|                     catch (Exception exp) { | ||||
|                         JOptionPane.showMessageDialog(frame, exp.getCause() + exp.getMessage()); | ||||
|                         return; | ||||
|                     } | ||||
|                      | ||||
|                     if (arch == null) { | ||||
|                         // if no arch specified in ModuleSA | ||||
|                         fpdMsa.remove(mg + mv + pg + pv); | ||||
|                          | ||||
|                     } else { | ||||
|                         ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv); | ||||
|                         if (al != null) { | ||||
|                             al.remove(arch); | ||||
|                             if (al.size() == 0) { | ||||
|                                 fpdMsa.remove(mg + mv + pg + pv); | ||||
|                             } | ||||
|                         } | ||||
|                     } | ||||
|                      | ||||
|                     ffc.removeModuleSA(selectedRow); | ||||
|                     modelFpdModules.removeRow(selectedRow); | ||||
|                     docConsole.setSaved(false); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user