# HG changeset patch # User Sascha L. Teichmann # Date 1390226075 -3600 # Node ID 772c22b0ea12188a28cfbf807b3ad4070f6ff564 # Parent 91a57b66c7ed5f0498eef662c3e90527774b4948# Parent e1c30527c10486328a097436c29e00c883da7971 Merged diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jan 20 14:54:35 2014 +0100 @@ -1367,5 +1367,7 @@ String current_gauge(); String suggested_label(); + + String negative_values_not_allowed_for_to(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jan 20 14:54:35 2014 +0100 @@ -715,3 +715,4 @@ FEDSTATE_KM = Station (Federal State) official_regulation = official Regulation +negative_values_not_allowed_for_to=Keine negativen Werte bei 'bis' erlaubt. diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jan 20 14:54:35 2014 +0100 @@ -713,3 +713,4 @@ WATERBODY = Gewässer FEDSTATE_KM = Landes-Stationierung official_regulation = amtl. Festlegung +negative_values_not_allowed_for_to=Keine negativen Werte bei 'bis' erlaubt. diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Mon Jan 20 14:54:35 2014 +0100 @@ -654,3 +654,4 @@ # Get Feature Info Window PATH = Path official_regulation = Official Regulation +negative_values_not_allowed_for_to=Negative are not allowed for 'to'. diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/event/RangeFilterEvent.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/event/RangeFilterEvent.java Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/event/RangeFilterEvent.java Mon Jan 20 14:54:35 2014 +0100 @@ -18,25 +18,21 @@ protected Float from; protected Float to; + private static Float asFloat(NumberFormat nf, String x) { + try { + return Float.valueOf((float)nf.parse(x)); + } + catch (NumberFormatException nfe) { + return Float.NaN; + } + } + public RangeFilterEvent(String from, String to) { NumberFormat nf = NumberFormat.getDecimalFormat(); - double d; - try { - d = nf.parse(from); - this.from = Float.valueOf(String.valueOf(d)); - } - catch(NumberFormatException nfe) { - this.from = Float.NaN; - } - try { - d = nf.parse(to); - this.to = Float.valueOf(String.valueOf(d)); - } - catch(NumberFormatException nfe) { - this.to = Float.NaN; - } + this.from = asFloat(nf, from); + this.to = asFloat(nf, to); } diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java Mon Jan 20 14:54:35 2014 +0100 @@ -598,22 +598,28 @@ Criterion combinedFilter = null; Criterion locationFilter = null; + if (from.equals(Float.NaN) && to.equals(Float.NaN)) { locationsTable.clearCriteria(); distancesTable.clearCriteria(); filterResultCount.setValue(""); return; } - else if (from.equals(Float.NaN)) { - combinedFilter = new Criterion("to", OperatorId.LESS_OR_EQUAL, to); + + if (from.equals(Float.NaN)) { + combinedFilter = + new Criterion("to", OperatorId.LESS_OR_EQUAL, to); + locationFilter = new Criterion("from", OperatorId.LESS_OR_EQUAL, to); + locationsTable.filterData(locationFilter); distancesTable.filterData(combinedFilter); filterResultCount.setValue(currentFiltered.getRecords().length); return; } - else if (to.equals(Float.NaN)) { + + if (to.equals(Float.NaN)) { combinedFilter = new Criterion("from", OperatorId.GREATER_OR_EQUAL, from); } diff -r e1c30527c104 -r 772c22b0ea12 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java --- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java Mon Jan 20 13:01:02 2014 +0100 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java Mon Jan 20 14:54:35 2014 +0100 @@ -8,6 +8,8 @@ package org.dive4elements.river.client.client.ui; +import java.util.List; + public class WaterlevelGroundPanel extends DistancePanel { private static final long serialVersionUID = 6598703468619862469L; @@ -123,5 +125,16 @@ // We don't need a helper panel here. But we have to override this // method to avoid the table creation in the parent class. } + + @Override + protected void validateTo(List errors) { + double to = distancePanel.getTo(); + + if (to < 0d) { + distancePanel.setTo(max); + errors.add(MSG.negative_values_not_allowed_for_to()); + } + super.validateTo(errors); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :