changeset 2455:0b7535e2e9aa

Issue 508. Added a list of WMS services to the external WMS dialog. flys-client/trunk@4142 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 14 Mar 2012 15:34:02 +0000
parents 99bd77501188
children 60ab1054069d
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/services/MapUrlService.java flys-client/src/main/java/de/intevation/flys/client/client/services/MapUrlServiceAsync.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java flys-client/src/main/java/de/intevation/flys/client/server/MapUrlServiceImpl.java flys-client/src/main/webapp/WEB-INF/web.xml flys-client/src/main/webapp/WEB-INF/wms-services.xml
diffstat 7 files changed, 162 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Mar 13 17:24:52 2012 +0000
+++ b/flys-client/ChangeLog	Wed Mar 14 15:34:02 2012 +0000
@@ -1,3 +1,22 @@
+2012-03-14  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Issue 508.
+
+	* src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java:
+	  Added service to load a list of WMS services and show this list in a
+	  combobox.
+
+	* src/main/java/de/intevation/flys/client/server/MapUrlServiceImpl.java,
+	  src/main/java/de/intevation/flys/client/client/services/MapUrlService.java,
+	  src/main/java/de/intevation/flys/client/client/services/MapUrlServiceAsync.java:
+	  New. Service to load a list of WMS services.
+
+	* src/main/webapp/WEB-INF/wms-services.xml:
+	  New. Config file containing the list of WMS services.
+
+	* src/main/webapp/WEB-INF/web.xml:
+	  Added new service.
+
 2012-03-13  Raimund Renkert <raimund.renkert@intevation.de>
 
 	Issue 514.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MapUrlService.java	Wed Mar 14 15:34:02 2012 +0000
@@ -0,0 +1,20 @@
+package de.intevation.flys.client.client.services;
+
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+
+/**
+ * This interface describes the service to get wms urls for UESK and new maps.
+ *
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+@RemoteServiceRelativePath("map-urls")
+public interface MapUrlService extends RemoteService {
+
+    Map<String, String> getUrls() throws ServerException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/MapUrlServiceAsync.java	Wed Mar 14 15:34:02 2012 +0000
@@ -0,0 +1,15 @@
+package de.intevation.flys.client.client.services;
+
+import java.util.Map;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+
+/**
+ * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
+ */
+public interface MapUrlServiceAsync {
+
+    public void getUrls(AsyncCallback<Map<String, String> > callback);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Tue Mar 13 17:24:52 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Wed Mar 14 15:34:02 2012 +0000
@@ -2,15 +2,18 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.LinkedHashMap;
 
 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;
 import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
 import com.smartgwt.client.widgets.events.ClickEvent;
 import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -23,6 +26,9 @@
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.services.GCService;
 import de.intevation.flys.client.client.services.GCServiceAsync;
+import de.intevation.flys.client.client.services.MapUrlService;
+import de.intevation.flys.client.client.services.MapUrlServiceAsync;
+import de.intevation.flys.client.client.Config;
 
 
 public class ExternalWMSWindow extends Window {
@@ -33,6 +39,7 @@
 
 
     protected GCServiceAsync gcService = GWT.create(GCService.class);
+    protected MapUrlServiceAsync muService = GWT.create(MapUrlService.class);
     protected FLYSConstants  MSG       = GWT.create(FLYSConstants.class);
 
     protected Layout inputPanel;
@@ -43,6 +50,7 @@
 
     protected String srs;
 
+    protected LinkedHashMap<String, String> urls;
     protected String url;
 
     protected LayerLoader loader;
@@ -50,6 +58,7 @@
 
     public ExternalWMSWindow(LayerLoader loader) {
         super();
+        this.urls = new LinkedHashMap<String, String>();
         this.loader = loader;
     }
 
@@ -146,12 +155,32 @@
     }
 
 
+    protected void setUrls(Map<String, String> urls) {
+        this.urls.putAll(urls);
+    }
+
+    protected void readUrls() {
+    }
+
+
     protected Layout createInputPanel() {
         setTitle(MSG.addwmsInputTitle());
 
-        final TextBox url = new TextBox();
-        url.setHeight("25px");
-        url.setWidth("326px");
+        readUrls();
+
+        DynamicForm form = new DynamicForm();
+        final ComboBoxItem url = new ComboBoxItem("Url:");
+        url.setRedrawOnChange(true);
+        muService.getUrls(new AsyncCallback<Map<String, String> >() {
+            public void onFailure(Throwable caught) {
+                GWT.log("Error reading WMS-Services" + caught.getMessage());
+            }
+            public void onSuccess(Map<String, String> wms) {
+                urls.putAll(wms);
+                url.setValueMap(urls);
+
+            }
+        });
 
         String oldUrl = getUrl();
         if (oldUrl != null && oldUrl.length() > 0) {
@@ -161,14 +190,14 @@
         ClickHandler goHandler = new ClickHandler() {
             @Override
             public void onClick(ClickEvent e) {
-                String newUrl = url.getValue();
+                String newUrl = url.getValue().toString();
 
                 if (!isUrlValid(newUrl)) {
                     SC.warn(MSG.addwmsInvalidURL());
                     return;
                 }
 
-                setUrl(url.getValue());
+                setUrl(newUrl);
 
                 doCapabilitesRequest();
             }
@@ -186,7 +215,8 @@
         root.setMargin(10);
         root.setLayoutMargin(10);
 
-        root.addMember(url);
+        form.setFields(url);
+        root.addMember(form);
         root.addMember(createButtonPanel(null, goHandler, cancelHandler));
 
         return root;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapUrlServiceImpl.java	Wed Mar 14 15:34:02 2012 +0000
@@ -0,0 +1,57 @@
+package de.intevation.flys.client.server;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Element;
+
+import org.apache.log4j.Logger;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import de.intevation.artifacts.common.utils.XMLUtils;
+
+import de.intevation.artifacts.httpclient.http.HttpClient;
+import de.intevation.artifacts.httpclient.http.HttpClientImpl;
+import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.client.services.MapUrlService;
+
+
+public class MapUrlServiceImpl
+extends      RemoteServiceServlet
+implements   MapUrlService
+{
+
+    private static final Logger logger =
+        Logger.getLogger(MapUrlServiceImpl.class);
+
+
+    public Map<String, String> getUrls()
+    throws ServerException
+    {
+        logger.info("MapUrlServiceImpl.getUrls");
+        Map<String, String> urls = new HashMap<String, String>();
+
+        InputStream in = getServletContext().getResourceAsStream("/WEB-INF/wms-services.xml");
+
+        Document doc = XMLUtils.parseDocument(in);
+
+        NodeList list = doc.getElementsByTagName("wms");
+        for (int i = 0; i < list.getLength(); i++) {
+            Element e = (Element) list.item(i);
+            urls.put(e.getAttribute("url"), e.getAttribute("name"));
+        }
+
+        return urls;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/webapp/WEB-INF/web.xml	Tue Mar 13 17:24:52 2012 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/web.xml	Wed Mar 14 15:34:02 2012 +0000
@@ -373,6 +373,16 @@
     <url-pattern>/flys/remove-artifact</url-pattern>
   </servlet-mapping>
 
+  <servlet>
+    <servlet-name>GetWMSUrls</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.MapUrlServiceImpl</servlet-class>
+  </servlet>
+  
+  <servlet-mapping>
+    <servlet-name>GetWMSUrls</servlet-name>
+    <url-pattern>/flys/map-urls</url-pattern>
+  </servlet-mapping>
+
   <!-- Default page to serve -->
   <welcome-file-list>
     <welcome-file>FLYS.html</welcome-file>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/webapp/WEB-INF/wms-services.xml	Wed Mar 14 15:34:02 2012 +0000
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wms-services>
+  <wms name="Luftbilder RLP" url="http://geo4.service24.rlp.de/wms/dop40_geo4.fcgi"/>
+</wms-services>

http://dive4elements.wald.intevation.org