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:
jlin16 2006-09-15 09:13:04 +00:00
parent 7838808993
commit ac66fadf6f
2 changed files with 52 additions and 11 deletions

View File

@ -70,6 +70,7 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification;
public class FpdFileContents { public class FpdFileContents {
static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0"; 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; private PlatformSurfaceAreaDocument fpdd = null;
@ -345,10 +346,21 @@ public class FpdFileContents {
} }
cursor.push(); 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()) { if (cursor.isComment()) {
cursor.removeXml(); cursor.removeXml();
} }
cursor.pop(); cursor.pop();
cursor.removeXml(); cursor.removeXml();
if (getFrameworkModulesCount() == 0) { if (getFrameworkModulesCount() == 0) {
@ -655,6 +667,7 @@ public class FpdFileContents {
ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey); ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);
if (moduleSA.getPcdBuildDefinition() != null) { if (moduleSA.getPcdBuildDefinition() != null) {
XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor(); XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();
cursor.push();
if (cursor.toFirstChild()) { if (cursor.toFirstChild()) {
do { do {
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor
@ -669,6 +682,11 @@ public class FpdFileContents {
} }
} while (cursor.toNextSibling()); } while (cursor.toNextSibling());
} }
cursor.pop();
if (moduleSA.getPcdBuildDefinition().getPcdDataList().size() == 0) {
cursor.removeXml();
}
cursor.dispose(); cursor.dispose();
} }
} }
@ -718,7 +736,17 @@ public class FpdFileContents {
cursor.toNextSibling(); cursor.toNextSibling();
} }
cursor.push(); 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()) { if (cursor.isComment()) {
cursor.removeXml(); cursor.removeXml();
} }

View File

@ -614,7 +614,7 @@ public class FpdFrameworkModules extends IInternalFrame {
if (selectedRow < 0) { if (selectedRow < 0) {
return; return;
} }
docConsole.setSaved(false);
TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); TableSorter sorter = (TableSorter) jTableFpdModules.getModel();
selectedRow = sorter.getModelRowIndex(selectedRow); selectedRow = sorter.getModelRowIndex(selectedRow);
@ -627,22 +627,35 @@ public class FpdFrameworkModules extends IInternalFrame {
String pv = sa[ffcPkgVer]; String pv = sa[ffcPkgVer];
String arch = sa[ffcModArch]; String arch = sa[ffcModArch];
ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch); ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);
mv = mi.getVersion(); if (mi != null) {
pv = mi.getPackageId().getVersion(); mv = mi.getVersion();
modelFpdModules.removeRow(selectedRow); pv = mi.getPackageId().getVersion();
}
try {
ffc.removeModuleSA(selectedRow);
}
catch (Exception exp) {
JOptionPane.showMessageDialog(frame, exp.getCause() + exp.getMessage());
return;
}
if (arch == null) { if (arch == null) {
// if no arch specified in ModuleSA // if no arch specified in ModuleSA
fpdMsa.remove(mg + mv + pg + pv); fpdMsa.remove(mg + mv + pg + pv);
} else { } else {
ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv); ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);
al.remove(arch); if (al != null) {
if (al.size() == 0) { al.remove(arch);
fpdMsa.remove(mg + mv + pg + pv); if (al.size() == 0) {
fpdMsa.remove(mg + mv + pg + pv);
}
} }
} }
ffc.removeModuleSA(selectedRow); modelFpdModules.removeRow(selectedRow);
docConsole.setSaved(false);
} }
}); });
} }