diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java @ 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 c8481debff70
children 8d27d2d33d70
line wrap: on
line diff
--- 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;

http://dive4elements.wald.intevation.org