changeset 2962:f14d4c668ec5

Bugfix: #698 Fix-Analysis is working in Tomcat again. flys-client/trunk@4949 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 12 Jul 2012 12:26:14 +0000
parents 579e33a24a4c
children f362e54b7e80
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java flys-client/src/main/java/de/intevation/flys/client/shared/model/FixFilter.java
diffstat 4 files changed, 226 insertions(+), 182 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Jul 12 11:29:05 2012 +0000
+++ b/flys-client/ChangeLog	Thu Jul 12 12:26:14 2012 +0000
@@ -1,3 +1,17 @@
+2012-07-12  Ingo Weinzierl <ingo@intevation.de>
+
+	flys/issue698 (FLYS-Client: Release-Version verschluckt Clicks auf Stepback)
+
+	* src/main/java/de/intevation/flys/client/shared/model/FixFilter.java:
+	  New. The code of this class was moved from FixationPanel to FixFilter.
+
+	* src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java:
+	  Adapted the reference to FixFilter which had been an inner class of
+	  FixationPanel before.
+
+	* src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java:
+	  Moved the FixFilter code to an own top level class in the 'shared' part.
+
 2012-07-11	Christian Lins <christian.lins@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java	Thu Jul 12 11:29:05 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java	Thu Jul 12 12:26:14 2012 +0000
@@ -42,6 +42,7 @@
 
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataList;
+import de.intevation.flys.client.shared.model.FixFilter;
 import de.intevation.flys.client.shared.model.FixingsOverviewInfo;
 import de.intevation.flys.client.shared.model.FixAnalysisArtifact;
 
@@ -76,6 +77,9 @@
     protected Img chartImg;
     protected TextItem kmText;
 
+    public static final DateTimeFormat DTF = DateTimeFormat.getFormat("dd.MM.yyyy");
+
+
     public FixationPanel() {
         chartImg = new Img();
         htmlOverview = "";
@@ -86,7 +90,6 @@
     }
 
     protected void init() {
-
     }
 
     public Data[] getData() {
@@ -140,7 +143,7 @@
         overviewService.generateOverview(
             locale,
             artifact.getUuid(),
-            art.getFilter().getOverviewFilter(),
+            getOverviewFilter(art.getFilter()),
             renderCheckboxes(),
             callBack,
             new AsyncCallback<FixingsOverviewInfo>() {
@@ -177,7 +180,6 @@
 
 
     protected Canvas createChartHelper() {
-
         DynamicForm form = new DynamicForm();
         Button lower = new Button("<<");
         lower.setWidth(30);
@@ -262,7 +264,7 @@
         String imgUrl = GWT.getModuleBaseURL();
         imgUrl += "fixings-km-chart";
         imgUrl += "?locale=" + locale;
-        imgUrl += "&filter=" + filter.getChartFilter(hWidth, hHeight);
+        imgUrl += "&filter=" + getChartFilter(filter, hWidth, hHeight);
 
         if (chartContainer.hasMember(chartImg)) {
             chartImg.setWidth(hWidth);
@@ -321,6 +323,7 @@
         String[] parts = name.split(":");
         String uuid = parts[0];
         String cid = parts[1];
+
         FixationPanel p = FixationPanel.getInstance(uuid);
         if (p != null) {
             p.setValues(cid, checked);
@@ -336,195 +339,118 @@
     public abstract boolean renderCheckboxes();
     public abstract void success();
 
-    public static class FixFilter implements Serializable{
-        protected String river;
-        protected double fromKm;
-        protected double toKm;
-        protected double currentKm;
-        protected int fromClass;
-        protected int toClass;
-        protected long fromDate;
-        protected long toDate;
-        protected boolean hasDate;
-        protected int[] events;
-
-        public FixFilter() {
-            this.river = "";
-            this.fromKm = -Double.MAX_VALUE;
-            this.toKm = -1;
-            this.currentKm = -1;
-            this.fromClass = -1;
-            this.toClass = -1;
-            this.fromDate = -1;
-            this.toDate = -1;
-            this.hasDate = false;
-            this.events = new int[0];
-        }
-
-        public void setRiver(String river) {
-            this.river = river;
-        }
-
-        public void setFromKm(double from) {
-            this.fromKm = from;
-        }
-
-        public void setToKm(double to) {
-            this.toKm = to;
-        }
-
-        public void setCurrentKm(double km) {
-            this.currentKm = km;
-        }
-
-        public void setFromClass(int from) {
-            this.fromClass = from;
-        }
 
-        public void setToClass(int to) {
-            this.toClass = to;
-        }
-
-        public void setFromDate(long from) {
-            this.hasDate = true;
-            this.fromDate = from;
-        }
-
-        public void setToDate(long to) {
-            this.hasDate = true;
-            this.toDate = to;
-        }
-
-        public void setEvents(int[] ev) {
-            this.events = ev;
-        }
-
-        public String getRiver() {
-            return this.river;
-        }
+    public static String getOverviewFilter(FixFilter filter) {
+        String river = filter.getRiver();
 
-        public double getFromKm() {
-            return this.fromKm;
+        if (river != null && river.length() > 0) {
+            JSONObject jfix = new JSONObject();
+            JSONObject jfilter = new JSONObject();
+            JSONObject jrName = new JSONObject();
+            JSONString jrValue = new JSONString(river);
+            jrName.put("name", jrValue);
+            jfilter.put("river", jrName);
+            jfix.put("fixings", createFilter(filter, jfilter));
+            return jfix.toString();
         }
-
-        public double getToKm() {
-            return this.toKm;
-        }
-
-        public double getCurrentKm() {
-            return this.currentKm;
-        }
+        return "";
+    }
 
-        public int getFromClass() {
-            return this.fromClass;
-        }
+    public String getChartFilter(FixFilter filter, int width, int height) {
+        String river     = filter.getRiver();
+        double currentKm = filter.getCurrentKm();
+        double fromKm    = filter.getFromKm();
+        double toKm      = filter.getToKm();
 
-        public int getToClass() {
-            return this.toClass;
+        if (river != null && river.length() > 0 &&
+            currentKm >= fromKm && currentKm <= toKm)
+        {
+            JSONObject jfix = new JSONObject();
+            JSONObject jfilter = new JSONObject();
+            JSONObject jrName = new JSONObject();
+            JSONString jrValue = new JSONString(river);
+            JSONObject jkm = new JSONObject();
+            JSONNumber jkmValue = new JSONNumber(currentKm);
+            JSONObject jextent = new JSONObject();
+            JSONNumber jwidth = new JSONNumber(width);
+            JSONNumber jheight = new JSONNumber(height);
+
+            jkm.put("value", jkmValue);
+            jrName.put("name", jrValue);
+            jfilter.put("river", jrName);
+            jfilter.put("km", jkm);
+            jextent.put("width", jwidth);
+            jextent.put("height", jheight);
+            jfilter.put("extent", jextent);
+            jfix.put("fixings", createFilter(filter, jfilter));
+            return jfix.toString();
         }
+        return "";
+    }
 
-        public long getFromDate() {
-            return this.fromDate;
-        }
+    protected static JSONObject createFilter(FixFilter filter, JSONObject root) {
+        double fromKm = filter.getFromKm();
+        double toKm   = filter.getToKm();
+        boolean hasDate = filter.getFromDate() > 0 && filter.getToDate() > 0;
 
-        public long getToDate() {
-            return this.toDate;
+        if (fromKm >= 0 && toKm >= 0 && fromKm <= toKm) {
+            JSONObject range = new JSONObject();
+            JSONObject fromtokm = new JSONObject();
+            JSONNumber f = new JSONNumber(fromKm);
+            JSONNumber t = new JSONNumber(toKm);
+            fromtokm.put("from", f);
+            fromtokm.put("to", t);
+            root.put("range", fromtokm);
         }
 
-        public int[] getEvents() {
-            return this.events;
-        }
-
-        public String getOverviewFilter() {
-            if (river != null && river.length() > 0) {
-                JSONObject jfix = new JSONObject();
-                JSONObject jfilter = new JSONObject();
-                JSONObject jrName = new JSONObject();
-                JSONString jrValue = new JSONString(river);
-                jrName.put("name", jrValue);
-                jfilter.put("river", jrName);
-                jfix.put("fixings", createFilter(jfilter));
-                return jfix.toString();
-            }
-            return "";
-        }
+        JSONObject and = new JSONObject();
+        if (hasDate) {
+            long fromDate = filter.getFromDate();
+            long toDate   = filter.getToDate();
 
-        public String getChartFilter(int width, int height) {
-            if (river != null && river.length() > 0 &&
-                currentKm >= fromKm && currentKm <= toKm)
-            {
-                JSONObject jfix = new JSONObject();
-                JSONObject jfilter = new JSONObject();
-                JSONObject jrName = new JSONObject();
-                JSONString jrValue = new JSONString(river);
-                JSONObject jkm = new JSONObject();
-                JSONNumber jkmValue = new JSONNumber(currentKm);
-                JSONObject jextent = new JSONObject();
-                JSONNumber jwidth = new JSONNumber(width);
-                JSONNumber jheight = new JSONNumber(height);
+            Date df = new Date(fromDate);
+            Date dt = new Date(toDate);
 
-                jkm.put("value", jkmValue);
-                jrName.put("name", jrValue);
-                jfilter.put("river", jrName);
-                jfilter.put("km", jkm);
-                jextent.put("width", jwidth);
-                jextent.put("height", jheight);
-                jfilter.put("extent", jextent);
-                jfix.put("fixings", createFilter(jfilter));
-                return jfix.toString();
-            }
-            return "";
+            JSONObject daterange = new JSONObject();
+            JSONString f = new JSONString(DTF.format(df));
+            JSONString t = new JSONString(DTF.format(dt));
+
+            daterange.put("from", f);
+            daterange.put("to", t);
+            and.put("date-range", daterange);
         }
 
-        protected JSONObject createFilter(JSONObject root) {
-            if (this.fromKm >= 0 && this.toKm >= 0 && this.fromKm <=this.toKm) {
-                JSONObject range = new JSONObject();
-                JSONObject fromtokm = new JSONObject();
-                JSONNumber f = new JSONNumber(this.fromKm);
-                JSONNumber t = new JSONNumber(this.toKm);
-                fromtokm.put("from", f);
-                fromtokm.put("to", t);
-                root.put("range", fromtokm);
-            }
-            JSONObject and = new JSONObject();
-            if (this.hasDate) {
-                JSONObject daterange = new JSONObject();
-                Date df = new Date(this.fromDate);
-                Date dt = new Date(this.toDate);
-                DateTimeFormat dtf = DateTimeFormat.getFormat("dd.MM.yyyy");
-                JSONString f = new JSONString(dtf.format(df));
-                JSONString t = new JSONString(dtf.format(dt));
-                daterange.put("from", f);
-                daterange.put("to", t);
-                and.put("date-range", daterange);
+        int fromClass = filter.getFromClass();
+        int toClass   = filter.getToClass();
+
+        if (fromClass >= 0 && toClass >= 0 && fromClass <= toClass) {
+            JSONObject classrange = new JSONObject();
+            JSONNumber f = new JSONNumber(fromClass);
+            JSONNumber t = new JSONNumber(toClass);
+
+            classrange.put("from", f);
+            classrange.put("to", t);
+            and.put("sector-range", classrange);
+        }
+
+        int[] events = filter.getEvents();
+
+        if (events.length > 0) {
+            StringBuilder cids = new StringBuilder();
+
+            for (int i = 0; i < events.length; i++) {
+                if (i > 0) cids.append(' ');
+                cids.append(events[i]);
             }
-            if (this.fromClass >= 0 &&
-                this.toClass >= 0 &&
-                this.fromClass <= this.toClass) {
-                JSONObject classrange = new JSONObject();
-                JSONNumber f = new JSONNumber(this.fromClass);
-                JSONNumber t = new JSONNumber(this.toClass);
-                classrange.put("from", f);
-                classrange.put("to", t);
-                and.put("sector-range", classrange);
-            }
-            if (this.events.length > 0) {
-                StringBuilder cids = new StringBuilder();
-
-                for (int i = 0; i < events.length; i++) {
-                    if (i > 0) cids.append(' ');
-                    cids.append(events[i]);
-                }
-                JSONObject columns = new JSONObject();
-                columns.put("cids", new JSONString(cids.toString()));
-                and.put("columns", columns);
-            }
-            if (and.size() > 0) {
-                JSONObject filter = new JSONObject();
-                filter.put("and", and);
-                root.put("filter", filter);
-            }
-            return root;
+            JSONObject columns = new JSONObject();
+            columns.put("cids", new JSONString(cids.toString()));
+            and.put("columns", columns);
         }
+        if (and.size() > 0) {
+            JSONObject jFilter = new JSONObject();
+            jFilter.put("and", and);
+            root.put("filter", jFilter);
+        }
+        return root;
     }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java	Thu Jul 12 11:29:05 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/FixAnalysisArtifact.java	Thu Jul 12 12:26:14 2012 +0000
@@ -4,8 +4,6 @@
 
 import com.google.gwt.core.client.GWT;
 
-import de.intevation.flys.client.client.ui.fixation.FixationPanel;
-import de.intevation.flys.client.client.ui.fixation.FixationPanel.FixFilter;
 
 /**
  * The Fixanalysis implementation of an Artifact.
@@ -17,7 +15,7 @@
     /** The name of this artifact: 'minfo'.*/
     public static final String NAME = "fixanalysis";
 
-    protected FixationPanel.FixFilter filter;
+    protected FixFilter filter;
 
     public FixAnalysisArtifact() {
         this.filter = null;
@@ -45,7 +43,7 @@
     }
 
 
-    public FixationPanel.FixFilter getFilter () {
+    public FixFilter getFilter () {
         return createFilter();
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/FixFilter.java	Thu Jul 12 12:26:14 2012 +0000
@@ -0,0 +1,106 @@
+package de.intevation.flys.client.shared.model;
+
+import java.io.Serializable;
+
+
+public class FixFilter implements Serializable{
+
+    protected String river;
+    protected double fromKm;
+    protected double toKm;
+    protected double currentKm;
+    protected int fromClass;
+    protected int toClass;
+    protected long fromDate;
+    protected long toDate;
+    protected boolean hasDate;
+    protected int[] events;
+
+    public FixFilter() {
+        this.river = "";
+        this.fromKm = -Double.MAX_VALUE;
+        this.toKm = -1;
+        this.currentKm = -1;
+        this.fromClass = -1;
+        this.toClass = -1;
+        this.fromDate = -1;
+        this.toDate = -1;
+        this.hasDate = false;
+        this.events = new int[0];
+    }
+
+    public void setRiver(String river) {
+        this.river = river;
+    }
+
+    public void setFromKm(double from) {
+        this.fromKm = from;
+    }
+
+    public void setToKm(double to) {
+        this.toKm = to;
+    }
+
+    public void setCurrentKm(double km) {
+        this.currentKm = km;
+    }
+
+    public void setFromClass(int from) {
+        this.fromClass = from;
+    }
+
+    public void setToClass(int to) {
+        this.toClass = to;
+    }
+
+    public void setFromDate(long from) {
+        this.hasDate = true;
+        this.fromDate = from;
+    }
+
+    public void setToDate(long to) {
+        this.hasDate = true;
+        this.toDate = to;
+    }
+
+    public void setEvents(int[] ev) {
+        this.events = ev;
+    }
+
+    public String getRiver() {
+        return this.river;
+    }
+
+    public double getFromKm() {
+        return this.fromKm;
+    }
+
+    public double getToKm() {
+        return this.toKm;
+    }
+
+    public double getCurrentKm() {
+        return this.currentKm;
+    }
+
+    public int getFromClass() {
+        return this.fromClass;
+    }
+
+    public int getToClass() {
+        return this.toClass;
+    }
+
+    public long getFromDate() {
+        return this.fromDate;
+    }
+
+    public long getToDate() {
+        return this.toDate;
+    }
+
+    public int[] getEvents() {
+        return this.events;
+    }
+}
+

http://dive4elements.wald.intevation.org