diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2015-03-06 11:56:53 +0200 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2015-03-06 12:29:24 +0200 |
commit | 741e798633edd584e62bcb4e6a00911a86908cdf (patch) | |
tree | 22d3b4c625376ba7f79ec82488a64f1696539d5b /server/src/com/vaadin/ui/Slider.java | |
parent | 3c84a54591d792b69a4d6d736714941edb1d818a (diff) | |
parent | 4db0b55aefd83d149e62a7fad2b14fb232d976c8 (diff) | |
download | vaadin-framework-741e798633edd584e62bcb4e6a00911a86908cdf.tar.gz vaadin-framework-741e798633edd584e62bcb4e6a00911a86908cdf.zip |
Merge branch 'master' into grid-columnreorder
Conflicts:
uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeaturesTest.java
uitest/src/com/vaadin/tests/widgetset/client/grid/GridBasicClientFeaturesWidget.java
Change-Id: Ic77c717b9bbdcc38585382d4944ee4491aba3f7d
Diffstat (limited to 'server/src/com/vaadin/ui/Slider.java')
-rw-r--r-- | server/src/com/vaadin/ui/Slider.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index 66ed1a48f4..dad4d295bf 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -161,6 +161,11 @@ public class Slider extends AbstractField<Double> { */ public void setMax(double max) { getState().maxValue = max; + + if (getMin() > max) { + getState().minValue = max; + } + if (getValue() > max) { setValue(max); } @@ -179,11 +184,16 @@ public class Slider extends AbstractField<Double> { * Set the minimum slider value. If the current value of the slider is * smaller than this, the value is set to the new minimum. * - * @param max + * @param min * The new minimum slider value */ public void setMin(double min) { getState().minValue = min; + + if (getMax() < min) { + getState().maxValue = min; + } + if (getValue() < min) { setValue(min); } @@ -260,12 +270,12 @@ public class Slider extends AbstractField<Double> { newValue = (int) (v * Math.pow(10, resolution)); newValue = newValue / Math.pow(10, resolution); if (getMin() > newValue || getMax() < newValue) { - throw new ValueOutOfBoundsException(value); + throw new ValueOutOfBoundsException(newValue); } } else { newValue = (int) v; if (getMin() > newValue || getMax() < newValue) { - throw new ValueOutOfBoundsException(value); + throw new ValueOutOfBoundsException(newValue); } } @@ -313,6 +323,8 @@ public class Slider extends AbstractField<Double> { * @param valueOutOfBounds */ public ValueOutOfBoundsException(Double valueOutOfBounds) { + super(String.format("Value %s is out of bounds: [%s, %s]", + valueOutOfBounds, getMin(), getMax())); value = valueOutOfBounds; } |