Add support for PCD token larger than 0x80000000 when declaring a PCD in package editor.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2122 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-12-20 08:30:04 +00:00
parent aadbf21b5f
commit fa67a8b221
2 changed files with 62 additions and 17 deletions

View File

@ -82,6 +82,40 @@ public class DataValidation {
return true; return true;
} }
/**
Check if the input data is long int and it is in the valid scope
The scope is provided by String
@param strNumber The input string which needs validation
@param BeginNumber The left boundary of the scope
@param EndNumber The right boundary of the scope
@retval true - The input is Int and in the scope;
@retval false - The input is not Int or not in the scope
**/
public static boolean isLongInt(String strNumber, long BeginNumber, long EndNumber) throws Exception{
//
//Check if the input data is int first
//
if (!isInt(strNumber)) {
return false;
}
//
//And then check if the data is between the scope
//
try {
Long intTemp = new Long(strNumber);
if ((intTemp.longValue() < BeginNumber) || (intTemp.longValue() > EndNumber)) {
return false;
}
}
catch (Exception e) {
throw e;
}
return true;
}
/** /**
Check if the input data is int and it is in the valid scope Check if the input data is int and it is in the valid scope
The scope is provided by String The scope is provided by String

View File

@ -524,6 +524,7 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
jCheckBoxFeatureFlag.isSelected(), jCheckBoxFixedAtBuild.isSelected(), jCheckBoxFeatureFlag.isSelected(), jCheckBoxFixedAtBuild.isSelected(),
jCheckBoxPatchInMod.isSelected(), jCheckBoxDyn.isSelected(), jCheckBoxDynEx.isSelected(), jCheckBoxPatchInMod.isSelected(), jCheckBoxDyn.isSelected(), jCheckBoxDynEx.isSelected(),
archList, modTypeList}; archList, modTypeList};
try {
if (!dataValidation(row)) { if (!dataValidation(row)) {
return; return;
} }
@ -531,6 +532,10 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
if (tokenCNameExisted(jTextFieldToken.getText(),jTextFieldC_Name.getText())) { if (tokenCNameExisted(jTextFieldToken.getText(),jTextFieldC_Name.getText())) {
return; return;
} }
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, "Illegal Token:"+ e.getCause());
return;
}
model.addRow(row); model.addRow(row);
jTable.changeSelection(model.getRowCount()-1, 0, false, false); jTable.changeSelection(model.getRowCount()-1, 0, false, false);
@ -900,9 +905,15 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
} }
Object[] o = {cName, token, ts, dataType, defaultVal, help}; Object[] o = {cName, token, ts, dataType, defaultVal, help};
try {
if (!dataValidation(o)){ if (!dataValidation(o)){
return; return;
} }
}
catch (Exception e) {
JOptionPane.showMessageDialog(frame, "Illegal Token:" + e.getCause());
return;
}
docConsole.setSaved(false); docConsole.setSaved(false);
sfc.updateSpdPcdDefinition(row, cName, token, dataType, usage, ts, defaultVal, help, archList, modTypeList); sfc.updateSpdPcdDefinition(row, cName, token, dataType, usage, ts, defaultVal, help, archList, modTypeList);
} }
@ -1049,19 +1060,19 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
return usage.trim(); return usage.trim();
} }
private boolean tokenCNameExisted(String token, String cName) { private boolean tokenCNameExisted(String token, String cName) throws Exception{
Integer inputToken = Integer.decode(token); Long inputToken = Long.decode(token);
for (int i = 0; i < jTable.getRowCount(); ++i) { for (int i = 0; i < model.getRowCount(); ++i) {
if (jTable.getValueAt(i, 0).equals(cName)) { if (model.getValueAt(i, 0).equals(cName)) {
JOptionPane.showMessageDialog(frame, "C_Name already existed in table."); JOptionPane.showMessageDialog(frame, "C_Name already existed in table.");
return true; return true;
} }
if (jTable.getValueAt(i, 1).equals(token)) { if (model.getValueAt(i, 1).equals(token)) {
JOptionPane.showMessageDialog(frame, "Token already existed in table."); JOptionPane.showMessageDialog(frame, "Token already existed in table.");
return true; return true;
} }
Integer tokenValue = Integer.decode(jTable.getValueAt(i, 1)+""); Long tokenValue = Long.decode(model.getValueAt(i, 1)+"");
if (tokenValue.equals(inputToken)) { if (tokenValue.equals(inputToken)) {
JOptionPane.showMessageDialog(frame, "Same token value already existed in table."); JOptionPane.showMessageDialog(frame, "Same token value already existed in table.");
return true; return true;
@ -1078,14 +1089,14 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{
} }
return true; return true;
} }
private boolean dataValidation(Object[] row) { private boolean dataValidation(Object[] row) throws Exception{
if (!DataValidation.isC_NameType(row[0].toString())) { if (!DataValidation.isC_NameType(row[0].toString())) {
JOptionPane.showMessageDialog(frame, "C_Name is NOT C_NameType."); JOptionPane.showMessageDialog(frame, "C_Name is NOT C_NameType.");
return false; return false;
} }
if (!DataValidation.isHexDoubleWordDataType(row[1].toString()) && if (!DataValidation.isHexDoubleWordDataType(row[1].toString()) &&
!DataValidation.isInt(row[1].toString(), Integer.MIN_VALUE, Integer.MAX_VALUE)) { !DataValidation.isLongInt(row[1].toString(), 1, Long.MAX_VALUE)) {
JOptionPane.showMessageDialog(frame, "Token is NOT correct."); JOptionPane.showMessageDialog(frame, "Token is NOT correct.");
return false; return false;
} }