This is an automated email from the git hooks/post-receive script. New commit to branch feature/1122-Type_Champ_Egal_T_Metier in repository lima. See http://git.chorem.org/lima.git commit 31d783f713be95389a3457e2d79ffe78b0201a1e Author: dcosse <japbiw74> Date: Fri Feb 20 11:02:52 2015 +0100 fixes #1122 gestion du cas ou la saisie ne peut être convertis en BigDecimal --- .../ui/celleditor/BigDecimalTableCellEditor.java | 42 ++++++++++++---------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java index e41b39a..121c695 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java @@ -70,29 +70,33 @@ public class BigDecimalTableCellEditor extends StringTableCellEditor { * */ @Override public BigDecimal getCellEditorValue() { - String stringValue = super.getCellEditorValue().toString(); - if (StringUtils.isBlank(stringValue)) { - stringValue = "0"; - } - stringValue=stringValue.replaceAll(",","."); - BigDecimal cellEditorValue; - int pointIndex = stringValue.indexOf("."); - if (pointIndex != -1) { - LimaSwingConfig config = LimaSwingApplicationContext.getContext().getConfig(); - String actualDecimals = stringValue.substring(pointIndex, stringValue.length()-1); - if (config.getScale() > actualDecimals.length()) { - cellEditorValue = new BigDecimal(stringValue); + try { + String stringValue = super.getCellEditorValue().toString(); + if (StringUtils.isBlank(stringValue)) { + stringValue = "0"; + } + stringValue=stringValue.replaceAll(",","."); + + int pointIndex = stringValue.indexOf("."); + if (pointIndex != -1) { + LimaSwingConfig config = LimaSwingApplicationContext.getContext().getConfig(); + String actualDecimals = stringValue.substring(pointIndex, stringValue.length()-1); + if (config.getScale() > actualDecimals.length()) { + cellEditorValue = new BigDecimal(stringValue); + } else { + int decimalLength = config.getScale() + pointIndex + 1; + String roundedStringValue = stringValue.substring(0, pointIndex) + + stringValue.substring(pointIndex, decimalLength); + cellEditorValue = new BigDecimal(roundedStringValue); + } } else { - int decimalLength = config.getScale() + pointIndex + 1; - String roundedStringValue = stringValue.substring(0, pointIndex) + - stringValue.substring(pointIndex, decimalLength); - cellEditorValue = new BigDecimal(roundedStringValue); + cellEditorValue = new BigDecimal(stringValue); } - } else { - cellEditorValue = new BigDecimal(stringValue); + } catch (NumberFormatException e) { + // it cancel current cell value + cellEditorValue = BigDecimal.ZERO; } - return cellEditorValue; } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.