update ModuleSA PCD editor.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@811 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16
2006-07-07 03:20:53 +00:00
parent a84091c4be
commit 82961247e6
3 changed files with 82 additions and 16 deletions

View File

@@ -347,10 +347,11 @@ public class FpdFileContents {
PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next(); PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();
saa[i][0] = pcdData.getCName(); saa[i][0] = pcdData.getCName();
saa[i][1] = pcdData.getTokenSpaceGuidCName(); saa[i][1] = pcdData.getTokenSpaceGuidCName();
saa[i][2] = pcdData.getItemType().toString(); saa[i][2] = pcdData.getItemType()+"";
saa[i][3] = pcdData.getToken().toString(); saa[i][3] = pcdData.getToken().toString();
saa[i][4] = pcdData.getDatumType().toString(); saa[i][4] = pcdData.getMaxDatumSize()+"";
saa[i][5] = pcdData.getValue(); saa[i][5] = pcdData.getDatumType()+"";
saa[i][6] = pcdData.getValue();
} }
} }
@@ -556,7 +557,7 @@ public class FpdFileContents {
* @param mi * @param mi
* @param moduleSa if null, generate a new ModuleSA. * @param moduleSa if null, generate a new ModuleSA.
*/ */
public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa){ public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, ModuleSADocument.ModuleSA moduleSa) throws Exception {
//ToDo add Arch filter //ToDo add Arch filter
try { try {
@@ -583,7 +584,7 @@ public class FpdFileContents {
// //
// ToDo Error // ToDo Error
// //
break; throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());
} }
// //
// AddItem to ModuleSA PcdBuildDefinitions // AddItem to ModuleSA PcdBuildDefinitions
@@ -595,6 +596,7 @@ public class FpdFileContents {
} }
catch (Exception e){ catch (Exception e){
e.printStackTrace(); e.printStackTrace();
throw e;
} }
} }
@@ -640,7 +642,8 @@ public class FpdFileContents {
return msa; return msa;
} }
private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) { private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa)
throws PcdItemTypeConflictException, PcdValueMalFormed{
if (moduleSa.getPcdBuildDefinition() == null){ if (moduleSa.getPcdBuildDefinition() == null){
moduleSa.addNewPcdBuildDefinition(); moduleSa.addNewPcdBuildDefinition();
} }
@@ -669,7 +672,7 @@ public class FpdFileContents {
if (!valuePart[4].equals("DYNAMIC")) { if (!valuePart[4].equals("DYNAMIC")) {
//ToDo error for same pcd, other type than dynamic //ToDo error for same pcd, other type than dynamic
pcdConsumer.remove(listValue); pcdConsumer.remove(listValue);
return; throw new PcdItemTypeConflictException(value);
} }
} }
} }
@@ -681,7 +684,7 @@ public class FpdFileContents {
if (valuePart[4].equals("DYNAMIC")) { if (valuePart[4].equals("DYNAMIC")) {
//ToDo error for same pcd, other type than non-dynamic //ToDo error for same pcd, other type than non-dynamic
pcdConsumer.remove(listValue); pcdConsumer.remove(listValue);
return; throw new PcdItemTypeConflictException(value);
} }
} }
} }
@@ -740,7 +743,7 @@ public class FpdFileContents {
} }
} }
private int setMaxSizeForPointer(String datum) { private int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{
if (datum == null) { if (datum == null) {
return 0; return 0;
} }
@@ -760,6 +763,7 @@ public class FpdFileContents {
(end > datum.length())|| (end > datum.length())||
((start == end) && (datum.length() > 0))) { ((start == end) && (datum.length() > 0))) {
//ToDo Error handling here //ToDo Error handling here
throw new PcdValueMalFormed (datum);
} }
strValue = datum.substring(start + 1, end); strValue = datum.substring(start + 1, end);
@@ -770,7 +774,7 @@ public class FpdFileContents {
if ((start > end) || if ((start > end) ||
(end > datum.length())|| (end > datum.length())||
((start == end) && (datum.length() > 0))) { ((start == end) && (datum.length() > 0))) {
throw new PcdValueMalFormed (datum);
} }
strValue = datum.substring(start + 1, end); strValue = datum.substring(start + 1, end);
return strValue.length(); return strValue.length();
@@ -791,7 +795,7 @@ public class FpdFileContents {
if (value > 0xFF) { if (value > 0xFF) {
// "[FPD file error] The datum type of PCD %s in %s is VOID*, "+ // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
// "it is byte array in fact. But the element of %s exceed the byte range", // "it is byte array in fact. But the element of %s exceed the byte range",
throw new PcdValueMalFormed (datum);
} }
} }
return strValueArray.length; return strValueArray.length;
@@ -803,7 +807,7 @@ public class FpdFileContents {
// "2) ANSIC string: like \"xxx\";\r\n"+ // "2) ANSIC string: like \"xxx\";\r\n"+
// "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+ // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
// "but the datum in seems does not following above format!", // "but the datum in seems does not following above format!",
return -1; throw new PcdValueMalFormed (datum);
} }
} }
@@ -845,7 +849,8 @@ public class FpdFileContents {
} }
} }
private void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) { private void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal)
throws PcdValueMalFormed{
DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData(); DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();
dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));
dynPcdData.setCName(cName); dynPcdData.setCName(cName);
@@ -2173,3 +2178,54 @@ public class FpdFileContents {
return s.trim(); return s.trim();
} }
} }
class PcdItemTypeConflictException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
private String details = null;
PcdItemTypeConflictException(String info){
details = info;
}
public String getMessage() {
return details;
}
}
class PcdDeclNotFound extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
private String details = null;
PcdDeclNotFound(String info) {
details = info;
}
public String getMessage() {
return details;
}
}
class PcdValueMalFormed extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
private String details = null;
PcdValueMalFormed(String info) {
details = info;
}
public String getMessage() {
return details;
}
}

View File

@@ -200,8 +200,13 @@ public class FpdFrameworkModules extends IInternalFrame {
} }
model1.addRow(row); model1.addRow(row);
docConsole.setSaved(false); docConsole.setSaved(false);
try{
ffc.addFrameworkModulesPcdBuildDefs(miList.get(selectedRow), null); ffc.addFrameworkModulesPcdBuildDefs(miList.get(selectedRow), null);
} }
catch (Exception exception) {
JOptionPane.showMessageDialog(frame, "PCD Insertion Fail. " + exception.getMessage());
}
}
}); });
} }
return jButton; return jButton;

View File

@@ -130,7 +130,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
model.setRowCount(0); model.setRowCount(0);
int pcdCount = ffc.getPcdDataCount(key); int pcdCount = ffc.getPcdDataCount(key);
if (pcdCount != 0) { if (pcdCount != 0) {
String[][] saa = new String[pcdCount][6]; String[][] saa = new String[pcdCount][7];
ffc.getPcdData(key, saa); ffc.getPcdData(key, saa);
for (int i = 0; i < saa.length; ++i) { for (int i = 0; i < saa.length; ++i) {
model.addRow(saa[i]); model.addRow(saa[i]);
@@ -519,6 +519,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
model.addColumn("TokenSpaceGUID"); model.addColumn("TokenSpaceGUID");
model.addColumn("ItemType"); model.addColumn("ItemType");
model.addColumn("Token"); model.addColumn("Token");
model.addColumn("MaxDatumSize");
model.addColumn("DataType"); model.addColumn("DataType");
model.addColumn("DefaultValue"); model.addColumn("DefaultValue");
@@ -933,8 +934,12 @@ public class FpdModuleSA extends JDialog implements ActionListener {
// //
// Add pcd information of selected instance to current moduleSA // Add pcd information of selected instance to current moduleSA
// //
try{
ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), ffc.getModuleSA(moduleKey)); ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), ffc.getModuleSA(moduleKey));
}
catch (Exception exception) {
JOptionPane.showMessageDialog(frame, "PCD Insertion Fail. " + exception.getMessage());
}
resolveLibraryInstances(instanceValue); resolveLibraryInstances(instanceValue);
} }
}); });
@@ -1250,7 +1255,7 @@ class PartialEditableTableModel extends DefaultTableModel {
public boolean isCellEditable(int row, int col) { public boolean isCellEditable(int row, int col) {
switch (col){ switch (col){
case 2: case 2:
return true; return false;
default: default:
return false; return false;
} }