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 {
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();
}

View File

@ -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<String> 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);
}
});
}