diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java @ 1408:5b5a20e4c4e5

Added a service that loads the Capabilities of a specified WMS - display those information in the ExternalWMSWindow. flys-client/trunk@3295 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 21 Nov 2011 12:00:48 +0000
parents 6c8a29abbe30
children ec6e4dad1279
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 21 09:29:57 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 21 12:00:48 2011 +0000
@@ -1,5 +1,7 @@
 package de.intevation.flys.client.client.ui.map;
 
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.TextBox;
 
 import com.smartgwt.client.util.SC;
@@ -13,13 +15,23 @@
 import com.smartgwt.client.widgets.layout.Layout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
+import de.intevation.flys.client.shared.model.Capabilities;
+import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.services.GCService;
+import de.intevation.flys.client.client.services.GCServiceAsync;
+
 
 public class ExternalWMSWindow extends Window {
 
+    protected GCServiceAsync gcService = GWT.create(GCService.class);
+    protected FLYSConstants  MSG       = GWT.create(FLYSConstants.class);
+
     protected Layout inputPanel;
     protected Layout infoPanel;
     protected Layout layersPanel;
 
+    protected Capabilities capabilites;
+
     protected String url;
 
 
@@ -38,6 +50,25 @@
     }
 
 
+    protected String getCapabilitiesUrl() {
+        String cUrl = url;
+
+        if (url.indexOf("?") >= 0) {
+            cUrl += "&SERVICE=WMS&REQUEST=GetCapabilities";
+        }
+        else {
+            cUrl += "?SERVICE=WMS&REQUEST=GetCapabilities";
+        }
+
+        return cUrl;
+    }
+
+
+    protected void setCapabilites(Capabilities capabilites) {
+        this.capabilites = capabilites;
+    }
+
+
     public void start() {
         show();
         centerInPage();
@@ -118,7 +149,8 @@
                 }
 
                 setUrl(url.getValue());
-                goToInfoPanel();
+
+                doCapabilitesRequest();
             }
         };
 
@@ -166,12 +198,13 @@
             }
         };
 
-        VLayout root = new VLayout();
+        VLayout root  = new VLayout();
+        VLayout panel = new CapabilitiesPanel(capabilites);
 
-        root.addMember(new Label("STEP 2: " + getUrl()));
+        root.setLayoutMargin(10);
+        panel.setHeight(420);
 
-        // TODO IMPLEMENT ME
-
+        root.addMember(panel);
         root.addMember(createButtonPanel(backHandler, goHandler, cancelHandler));
 
         return root;
@@ -273,5 +306,19 @@
     protected void quit() {
         destroy();
     }
+
+
+    protected void doCapabilitesRequest() {
+        gcService.query(getCapabilitiesUrl(),new AsyncCallback<Capabilities>() {
+            public void onFailure(Throwable e) {
+                SC.warn(MSG.getString(e.getMessage()));
+            }
+
+            public void onSuccess(Capabilities capabilites) {
+                setCapabilites(capabilites);
+                goToInfoPanel();
+            }
+        });
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org