[PATCH 1 of 2] Client side fix for flys/issue1549
Wald Commits
scm-commit at wald.intevation.org
Mon Jan 20 14:54:42 CET 2014
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1390218256 -3600
# Node ID 91a57b66c7ed5f0498eef662c3e90527774b4948
# Parent 3d772f52080a62fb011da1e70df3177f63fdff24
Client side fix for flys/issue1549
diff -r 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Mon Jan 20 12:44:16 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 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Mon Jan 20 12:44:16 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 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Mon Jan 20 12:44:16 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 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Mon Jan 20 12:44:16 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 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/event/RangeFilterEvent.java Mon Jan 20 12:44:16 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 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java Mon Jan 20 12:44:16 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 3d772f52080a -r 91a57b66c7ed 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 13 11:52:22 2014 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/WaterlevelGroundPanel.java Mon Jan 20 12:44:16 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<String> 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 :
More information about the Dive4elements-commits
mailing list