From ac66fadf6fae5f54b17fb50728a82ffb32b829fa Mon Sep 17 00:00:00 2001 From: jlin16 Date: Fri, 15 Sep 2006 09:13:04 +0000 Subject: [PATCH] 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 --- .../platform/ui/FpdFileContents.java | 32 +++++++++++++++++-- .../platform/ui/FpdFrameworkModules.java | 31 ++++++++++++------ 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java index 946a6b64d9..b89f967fa3 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java @@ -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(); - cursor.toPrevToken(); + 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(); - cursor.toPrevToken(); + while (cursor.hasPrevToken()) { + cursor.toPrevToken(); + if (!cursor.isText()) { + break; + } + String s = cursor.getTextValue(); + if (s.matches(regNewLineAndSpaces)) { + continue; + } + } + if (cursor.isComment()) { cursor.removeXml(); } diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java index b831703235..57af40ea07 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -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); - mv = mi.getVersion(); - pv = mi.getPackageId().getVersion(); - modelFpdModules.removeRow(selectedRow); + if (mi != null) { + mv = mi.getVersion(); + pv = mi.getPackageId().getVersion(); + } + + 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 al = fpdMsa.get(mg + mv + pg + pv); - al.remove(arch); - if (al.size() == 0) { - fpdMsa.remove(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); } }); } -- 2.39.2