branch feature/1122-Type_Champ_Egal_T_Metier created (now 31d783f)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1122-Type_Champ_Egal_T_Metier in repository lima. See http://git.chorem.org/lima.git at 31d783f fixes #1122 gestion du cas ou la saisie ne peut être convertis en BigDecimal This branch includes the following new commits: new 31d783f fixes #1122 gestion du cas ou la saisie ne peut être convertis en BigDecimal The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: 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 -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
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>.
participants (1)
-
chorem.org scm