changeset 1538:92f81eac034a

Added filter implementation for input helper tables in single location and distance panel. flys-client/trunk@3756 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 24 Jan 2012 12:43:06 +0000
parents 2b104fa094e2
children 28e514c968d6
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java
diffstat 3 files changed, 85 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Jan 24 11:48:46 2012 +0000
+++ b/flys-client/ChangeLog	Tue Jan 24 12:43:06 2012 +0000
@@ -1,3 +1,9 @@
+2012-01-24  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java:
+	  Added filter implementation for input helper tables.
+
 2012-01-24  Raimund Renkert <raimund.renkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java	Tue Jan 24 11:48:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java	Tue Jan 24 12:43:06 2012 +0000
@@ -8,6 +8,10 @@
 import com.google.gwt.i18n.client.NumberFormat;
 
 import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Criterion;
+import com.smartgwt.client.data.AdvancedCriteria;
+import com.smartgwt.client.types.OperatorId;
+
 import com.smartgwt.client.data.Record;
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
@@ -531,6 +535,7 @@
         tabs.addTabSelectedHandler(new TabSelectedHandler() {
             public void onTabSelected(TabSelectedEvent evt) {
                 filterDescription.clear();
+                filterRange.clear();
             }
         });
 
@@ -555,7 +560,53 @@
 
 
     public void onFilterCriteriaChanged(RangeFilterEvent event) {
-        GWT.log("filter range");
+        Float from = event.getFrom() - 0.001f;
+        Float to = event.getTo() + 0.001f;
+
+        Criterion combinedFilter = null;
+        Criterion locationFilter = null;
+        if (from.equals(Float.NaN) && to.equals(Float.NaN)) {
+            locationsTable.clearCriteria();
+            distancesTable.clearCriteria();
+        }
+        else 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);
+            return;
+        }
+        else if (to.equals(Float.NaN)) {
+            combinedFilter =
+                new Criterion("from", OperatorId.GREATER_OR_EQUAL, from);
+        }
+        else {
+            AdvancedCriteria c1 =
+                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
+                    new Criterion("from", OperatorId.GREATER_OR_EQUAL, from),
+                    new Criterion("from", OperatorId.LESS_OR_EQUAL, to)
+                });
+
+            AdvancedCriteria c2 =
+                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
+                    new Criterion("to", OperatorId.GREATER_OR_EQUAL, from),
+                    new Criterion("to", OperatorId.LESS_OR_EQUAL, to)
+                });
+
+            AdvancedCriteria c3 =
+                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
+                    new Criterion("from", OperatorId.LESS_OR_EQUAL, to),
+                    new Criterion("to", OperatorId.GREATER_OR_EQUAL, from)
+                });
+
+            combinedFilter =
+                new AdvancedCriteria(OperatorId.OR, new Criterion[] {
+                    c1, c2, c3
+                });
+        }
+        locationsTable.filterData(combinedFilter);
+        distancesTable.filterData(combinedFilter);
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java	Tue Jan 24 11:48:46 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java	Tue Jan 24 12:43:06 2012 +0000
@@ -29,6 +29,10 @@
 import com.smartgwt.client.widgets.grid.CellFormatter;
 
 import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Criterion;
+import com.smartgwt.client.data.AdvancedCriteria;
+import com.smartgwt.client.types.OperatorId;
+
 import com.smartgwt.client.data.Record;
 import com.smartgwt.client.types.ListGridFieldType;
 
@@ -373,7 +377,29 @@
 
 
     public void onFilterCriteriaChanged(RangeFilterEvent event) {
-        GWT.log("filter range");
+        Float from = event.getFrom() - 0.001f;
+        Float to = event.getTo() + 0.001f;
+
+        Criterion combinedFilter = null;
+        if (from.equals(Float.NaN) && to.equals(Float.NaN)) {
+            locationTable.clearCriteria();
+        }
+        else if (from.equals(Float.NaN)) {
+            combinedFilter =
+                new Criterion("from", OperatorId.LESS_OR_EQUAL, to);
+        }
+        else if (to.equals(Float.NaN)) {
+            combinedFilter =
+                new Criterion("from", OperatorId.GREATER_OR_EQUAL, from);
+        }
+        else {
+            combinedFilter =
+                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
+                    new Criterion("from", OperatorId.GREATER_OR_EQUAL, from),
+                    new Criterion("from", OperatorId.LESS_OR_EQUAL, to)
+                });
+        }
+        locationTable.filterData(combinedFilter);
     }
 
 

http://dive4elements.wald.intevation.org