From 39e3af1870abb8b0fdb8b609fda96758ab37818c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Gonz=C3=A1lez=20Fern=C3=A1ndez?= Date: Mon, 28 Feb 2011 16:22:47 +0100 Subject: [PATCH] [Bug #897] Fix bug Change message. FEA: ItEr71S04BugFixing --- .../streches/StretchesFunctionController.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java index 85c386036..a6d9ebfad 100644 --- a/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java +++ b/navalplanner-webapp/src/main/java/org/navalplanner/web/planner/allocation/streches/StretchesFunctionController.java @@ -311,7 +311,7 @@ public class StretchesFunctionController extends GenericForwardComposer { private void appendLengthPercentage(Listitem item, final Stretch stretch) { final Decimalbox tempDecimalbox = new Decimalbox(); - Decimalbox decimalbox = Util.bind(tempDecimalbox, + final Decimalbox decimalbox = Util.bind(tempDecimalbox, new Util.Getter() { @Override public BigDecimal get() { @@ -324,18 +324,18 @@ public class StretchesFunctionController extends GenericForwardComposer { if (value == null) { value = BigDecimal.ZERO; } + if (value.toBigInteger().intValue() > 100 + || value.toBigInteger().intValue() < 0) { + throw new WrongValueException( + tempDecimalbox, + _("Length percentage should be between 0 and 100")); + } value = value.setScale(2).divide( new BigDecimal(100), RoundingMode.DOWN); - try { - stretchesFunctionModel - .setStretchLengthPercentage(stretch, - value); - focusState.focusOn(stretch, Field.LENGTH); - reloadStretchesListAndCharts(); - } catch (IllegalArgumentException e) { - throw new WrongValueException(tempDecimalbox, e - .getMessage()); - } + stretchesFunctionModel.setStretchLengthPercentage( + stretch, value); + focusState.focusOn(stretch, Field.LENGTH); + reloadStretchesListAndCharts(); } }); appendChild(item, decimalbox);