From fa67a8b221e1312a1d1ac73416595e00c7f0b889 Mon Sep 17 00:00:00 2001 From: jlin16 Date: Wed, 20 Dec 2006 08:30:04 +0000 Subject: 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 --- .../frameworkwizard/common/DataValidation.java | 34 ++++++++++++++++ .../frameworkwizard/packaging/ui/SpdPcdDefs.java | 45 ++++++++++++++-------- 2 files changed, 62 insertions(+), 17 deletions(-) (limited to 'Tools') diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java index 2d9e75c..82724d4 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/DataValidation.java @@ -83,6 +83,40 @@ public class DataValidation { } /** + 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 The scope is provided by String diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java index 06a5d94..1ada302 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdPcdDefs.java @@ -524,13 +524,18 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{ jCheckBoxFeatureFlag.isSelected(), jCheckBoxFixedAtBuild.isSelected(), jCheckBoxPatchInMod.isSelected(), jCheckBoxDyn.isSelected(), jCheckBoxDynEx.isSelected(), archList, modTypeList}; - if (!dataValidation(row)) { - return; - } - - if (tokenCNameExisted(jTextFieldToken.getText(), jTextFieldC_Name.getText())) { - return; - } + try { + if (!dataValidation(row)) { + return; + } + + if (tokenCNameExisted(jTextFieldToken.getText(),jTextFieldC_Name.getText())) { + return; + } + } catch (Exception e) { + JOptionPane.showMessageDialog(frame, "Illegal Token:"+ e.getCause()); + return; + } model.addRow(row); jTable.changeSelection(model.getRowCount()-1, 0, false, false); @@ -900,8 +905,14 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{ } Object[] o = {cName, token, ts, dataType, defaultVal, help}; - if (!dataValidation(o)){ - return; + try { + if (!dataValidation(o)){ + return; + } + } + catch (Exception e) { + JOptionPane.showMessageDialog(frame, "Illegal Token:" + e.getCause()); + return; } docConsole.setSaved(false); 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(); } - private boolean tokenCNameExisted(String token, String cName) { - Integer inputToken = Integer.decode(token); + private boolean tokenCNameExisted(String token, String cName) throws Exception{ + Long inputToken = Long.decode(token); - for (int i = 0; i < jTable.getRowCount(); ++i) { - if (jTable.getValueAt(i, 0).equals(cName)) { + for (int i = 0; i < model.getRowCount(); ++i) { + if (model.getValueAt(i, 0).equals(cName)) { JOptionPane.showMessageDialog(frame, "C_Name already existed in table."); return true; } - if (jTable.getValueAt(i, 1).equals(token)) { + if (model.getValueAt(i, 1).equals(token)) { JOptionPane.showMessageDialog(frame, "Token already existed in table."); return true; } - Integer tokenValue = Integer.decode(jTable.getValueAt(i, 1)+""); + Long tokenValue = Long.decode(model.getValueAt(i, 1)+""); if (tokenValue.equals(inputToken)) { JOptionPane.showMessageDialog(frame, "Same token value already existed in table."); return true; @@ -1078,14 +1089,14 @@ public class SpdPcdDefs extends IInternalFrame implements TableModelListener{ } return true; } - private boolean dataValidation(Object[] row) { + private boolean dataValidation(Object[] row) throws Exception{ if (!DataValidation.isC_NameType(row[0].toString())) { JOptionPane.showMessageDialog(frame, "C_Name is NOT C_NameType."); return false; } 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."); return false; } -- cgit v1.1