diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java @ 5818:a4ff4167be1e

Request feature info on all layers and show it as html if the server does not return valid gml. Non queryable layers produce an error message when the request fails. This is good enough
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 24 Apr 2013 17:33:27 +0200
parents e0ab5a566688
children
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java	Wed Apr 24 15:20:50 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java	Wed Apr 24 17:33:27 2013 +0200
@@ -21,6 +21,7 @@
 import de.intevation.flys.client.shared.model.FacetRecord;
 import de.intevation.flys.client.shared.model.Theme;
 import de.intevation.flys.client.shared.model.AttributedTheme;
+import de.intevation.flys.client.shared.model.FeatureInfoResponse;
 import de.intevation.flys.client.client.ui.ThemePanel;
 
 
@@ -69,6 +70,14 @@
         gfiWindow.show();
     }
 
+    protected void newGetFeatureInfoWindow(String response, String title) {
+        if (gfiWindow != null) {
+            gfiWindow.destroy();
+        }
+
+        gfiWindow = new GetFeatureInfoWindow(response, title);
+        gfiWindow.show();
+    }
 
     @Override
     public void onClick(MapClickListener.MapClickEvent e) {
@@ -90,16 +99,23 @@
                 (int) map.getSize().getHeight(),
                 (int) map.getSize().getWidth(),
                 pixel.x(), pixel.y(),
-                new AsyncCallback<List<FeatureInfo>>() {
+                new AsyncCallback<FeatureInfoResponse>() {
                     @Override
                     public void onFailure(Throwable e) {
                         SC.warn(MSG.getString(e.getMessage()));
                     }
 
                     @Override
-                    public void onSuccess(List<FeatureInfo> features) {
-                        if (features != null && !features.isEmpty())
+                    public void onSuccess(FeatureInfoResponse response) {
+                        List<FeatureInfo> features = response.getFeatures();
+                        if (features != null && !features.isEmpty()) {
                             newGetFeatureInfoWindow(features, at.getAttr("description"));
+                        } else if (response.getFeatureInfoHTML() != null) {
+                            newGetFeatureInfoWindow(response.getFeatureInfoHTML(),
+                                at.getAttr("description"));
+                        } else {
+                            GWT.log("GetFeatureInfo returned neither a list of features nor a string");
+                        }
                     }
                 }
             );

http://dive4elements.wald.intevation.org