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
}\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
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
}\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
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
if (selectedRow < 0) {\r
return;\r
}\r
- docConsole.setSaved(false);\r
+ \r
\r
TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
selectedRow = sorter.getModelRowIndex(selectedRow);\r
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