Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
2454:99bd77501188 | 2455:0b7535e2e9aa |
---|---|
1 package de.intevation.flys.client.client.ui.map; | 1 package de.intevation.flys.client.client.ui.map; |
2 | 2 |
3 import java.util.ArrayList; | 3 import java.util.ArrayList; |
4 import java.util.List; | 4 import java.util.List; |
5 import java.util.Map; | |
6 import java.util.LinkedHashMap; | |
5 | 7 |
6 import com.google.gwt.core.client.GWT; | 8 import com.google.gwt.core.client.GWT; |
7 import com.google.gwt.user.client.rpc.AsyncCallback; | 9 import com.google.gwt.user.client.rpc.AsyncCallback; |
8 import com.google.gwt.user.client.ui.TextBox; | |
9 | 10 |
10 import com.smartgwt.client.util.SC; | 11 import com.smartgwt.client.util.SC; |
11 import com.smartgwt.client.widgets.Button; | 12 import com.smartgwt.client.widgets.Button; |
12 import com.smartgwt.client.widgets.Canvas; | 13 import com.smartgwt.client.widgets.Canvas; |
13 import com.smartgwt.client.widgets.Window; | 14 import com.smartgwt.client.widgets.Window; |
15 import com.smartgwt.client.widgets.form.DynamicForm; | |
16 import com.smartgwt.client.widgets.form.fields.ComboBoxItem; | |
14 import com.smartgwt.client.widgets.events.ClickEvent; | 17 import com.smartgwt.client.widgets.events.ClickEvent; |
15 import com.smartgwt.client.widgets.events.ClickHandler; | 18 import com.smartgwt.client.widgets.events.ClickHandler; |
16 import com.smartgwt.client.widgets.grid.ListGridRecord; | 19 import com.smartgwt.client.widgets.grid.ListGridRecord; |
17 import com.smartgwt.client.widgets.layout.HLayout; | 20 import com.smartgwt.client.widgets.layout.HLayout; |
18 import com.smartgwt.client.widgets.layout.Layout; | 21 import com.smartgwt.client.widgets.layout.Layout; |
21 import de.intevation.flys.client.shared.model.Capabilities; | 24 import de.intevation.flys.client.shared.model.Capabilities; |
22 import de.intevation.flys.client.shared.model.WMSLayer; | 25 import de.intevation.flys.client.shared.model.WMSLayer; |
23 import de.intevation.flys.client.client.FLYSConstants; | 26 import de.intevation.flys.client.client.FLYSConstants; |
24 import de.intevation.flys.client.client.services.GCService; | 27 import de.intevation.flys.client.client.services.GCService; |
25 import de.intevation.flys.client.client.services.GCServiceAsync; | 28 import de.intevation.flys.client.client.services.GCServiceAsync; |
29 import de.intevation.flys.client.client.services.MapUrlService; | |
30 import de.intevation.flys.client.client.services.MapUrlServiceAsync; | |
31 import de.intevation.flys.client.client.Config; | |
26 | 32 |
27 | 33 |
28 public class ExternalWMSWindow extends Window { | 34 public class ExternalWMSWindow extends Window { |
29 | 35 |
30 public interface LayerLoader { | 36 public interface LayerLoader { |
31 void load(List<WMSLayer> toLoad); | 37 void load(List<WMSLayer> toLoad); |
32 } // end of interface WMSLayerLoader | 38 } // end of interface WMSLayerLoader |
33 | 39 |
34 | 40 |
35 protected GCServiceAsync gcService = GWT.create(GCService.class); | 41 protected GCServiceAsync gcService = GWT.create(GCService.class); |
42 protected MapUrlServiceAsync muService = GWT.create(MapUrlService.class); | |
36 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 43 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
37 | 44 |
38 protected Layout inputPanel; | 45 protected Layout inputPanel; |
39 protected Layout infoPanel; | 46 protected Layout infoPanel; |
40 protected Layout layersPanel; | 47 protected Layout layersPanel; |
41 | 48 |
42 protected Capabilities capabilites; | 49 protected Capabilities capabilites; |
43 | 50 |
44 protected String srs; | 51 protected String srs; |
45 | 52 |
53 protected LinkedHashMap<String, String> urls; | |
46 protected String url; | 54 protected String url; |
47 | 55 |
48 protected LayerLoader loader; | 56 protected LayerLoader loader; |
49 | 57 |
50 | 58 |
51 public ExternalWMSWindow(LayerLoader loader) { | 59 public ExternalWMSWindow(LayerLoader loader) { |
52 super(); | 60 super(); |
61 this.urls = new LinkedHashMap<String, String>(); | |
53 this.loader = loader; | 62 this.loader = loader; |
54 } | 63 } |
55 | 64 |
56 | 65 |
57 public ExternalWMSWindow(LayerLoader loader, String srs) { | 66 public ExternalWMSWindow(LayerLoader loader, String srs) { |
144 } | 153 } |
145 } | 154 } |
146 } | 155 } |
147 | 156 |
148 | 157 |
158 protected void setUrls(Map<String, String> urls) { | |
159 this.urls.putAll(urls); | |
160 } | |
161 | |
162 protected void readUrls() { | |
163 } | |
164 | |
165 | |
149 protected Layout createInputPanel() { | 166 protected Layout createInputPanel() { |
150 setTitle(MSG.addwmsInputTitle()); | 167 setTitle(MSG.addwmsInputTitle()); |
151 | 168 |
152 final TextBox url = new TextBox(); | 169 readUrls(); |
153 url.setHeight("25px"); | 170 |
154 url.setWidth("326px"); | 171 DynamicForm form = new DynamicForm(); |
172 final ComboBoxItem url = new ComboBoxItem("Url:"); | |
173 url.setRedrawOnChange(true); | |
174 muService.getUrls(new AsyncCallback<Map<String, String> >() { | |
175 public void onFailure(Throwable caught) { | |
176 GWT.log("Error reading WMS-Services" + caught.getMessage()); | |
177 } | |
178 public void onSuccess(Map<String, String> wms) { | |
179 urls.putAll(wms); | |
180 url.setValueMap(urls); | |
181 | |
182 } | |
183 }); | |
155 | 184 |
156 String oldUrl = getUrl(); | 185 String oldUrl = getUrl(); |
157 if (oldUrl != null && oldUrl.length() > 0) { | 186 if (oldUrl != null && oldUrl.length() > 0) { |
158 url.setValue(oldUrl); | 187 url.setValue(oldUrl); |
159 } | 188 } |
160 | 189 |
161 ClickHandler goHandler = new ClickHandler() { | 190 ClickHandler goHandler = new ClickHandler() { |
162 @Override | 191 @Override |
163 public void onClick(ClickEvent e) { | 192 public void onClick(ClickEvent e) { |
164 String newUrl = url.getValue(); | 193 String newUrl = url.getValue().toString(); |
165 | 194 |
166 if (!isUrlValid(newUrl)) { | 195 if (!isUrlValid(newUrl)) { |
167 SC.warn(MSG.addwmsInvalidURL()); | 196 SC.warn(MSG.addwmsInvalidURL()); |
168 return; | 197 return; |
169 } | 198 } |
170 | 199 |
171 setUrl(url.getValue()); | 200 setUrl(newUrl); |
172 | 201 |
173 doCapabilitesRequest(); | 202 doCapabilitesRequest(); |
174 } | 203 } |
175 }; | 204 }; |
176 | 205 |
184 VLayout root = new VLayout(); | 213 VLayout root = new VLayout(); |
185 root.setHeight(75); | 214 root.setHeight(75); |
186 root.setMargin(10); | 215 root.setMargin(10); |
187 root.setLayoutMargin(10); | 216 root.setLayoutMargin(10); |
188 | 217 |
189 root.addMember(url); | 218 form.setFields(url); |
219 root.addMember(form); | |
190 root.addMember(createButtonPanel(null, goHandler, cancelHandler)); | 220 root.addMember(createButtonPanel(null, goHandler, cancelHandler)); |
191 | 221 |
192 return root; | 222 return root; |
193 } | 223 } |
194 | 224 |