# HG changeset patch # User Raimund Renkert # Date 1331739242 0 # Node ID 0b7535e2e9aa34f7d4ac0ea64fffbeee431151ba # Parent 99bd7750118815f999d17c99791b511e2e6f405e Issue 508. Added a list of WMS services to the external WMS dialog. flys-client/trunk@4142 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/ChangeLog --- 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 + + 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 Issue 514. diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/src/main/java/de/intevation/flys/client/client/services/MapUrlService.java --- /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 Raimund Renkert + */ +@RemoteServiceRelativePath("map-urls") +public interface MapUrlService extends RemoteService { + + Map getUrls() throws ServerException; +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/src/main/java/de/intevation/flys/client/client/services/MapUrlServiceAsync.java --- /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 Raimund Renkert + */ +public interface MapUrlServiceAsync { + + public void getUrls(AsyncCallback > callback); +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java --- 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 urls; protected String url; protected LayerLoader loader; @@ -50,6 +58,7 @@ public ExternalWMSWindow(LayerLoader loader) { super(); + this.urls = new LinkedHashMap(); this.loader = loader; } @@ -146,12 +155,32 @@ } + protected void setUrls(Map 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 >() { + public void onFailure(Throwable caught) { + GWT.log("Error reading WMS-Services" + caught.getMessage()); + } + public void onSuccess(Map 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; diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/src/main/java/de/intevation/flys/client/server/MapUrlServiceImpl.java --- /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 getUrls() + throws ServerException + { + logger.info("MapUrlServiceImpl.getUrls"); + Map urls = new HashMap(); + + 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 : diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/src/main/webapp/WEB-INF/web.xml --- 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 @@ /flys/remove-artifact + + GetWMSUrls + de.intevation.flys.client.server.MapUrlServiceImpl + + + + GetWMSUrls + /flys/map-urls + + FLYS.html diff -r 99bd77501188 -r 0b7535e2e9aa flys-client/src/main/webapp/WEB-INF/wms-services.xml --- /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 @@ + + + +