comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java @ 1412:659a488243da

Added code to trigger loading selected WMS layers from ExternalWMSWindow. Note: no code for loading/adding layers to the current map existing yet. flys-client/trunk@3299 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 22 Nov 2011 13:04:46 +0000
parents 63be3137abac
children 750a53950e9f
comparison
equal deleted inserted replaced
1411:63be3137abac 1412:659a488243da
1 package de.intevation.flys.client.client.ui.map; 1 package de.intevation.flys.client.client.ui.map;
2
3 import java.util.ArrayList;
4 import java.util.List;
2 5
3 import com.google.gwt.core.client.GWT; 6 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.user.client.rpc.AsyncCallback; 7 import com.google.gwt.user.client.rpc.AsyncCallback;
5 import com.google.gwt.user.client.ui.TextBox; 8 import com.google.gwt.user.client.ui.TextBox;
6 9
8 import com.smartgwt.client.widgets.Button; 11 import com.smartgwt.client.widgets.Button;
9 import com.smartgwt.client.widgets.Canvas; 12 import com.smartgwt.client.widgets.Canvas;
10 import com.smartgwt.client.widgets.Window; 13 import com.smartgwt.client.widgets.Window;
11 import com.smartgwt.client.widgets.events.ClickEvent; 14 import com.smartgwt.client.widgets.events.ClickEvent;
12 import com.smartgwt.client.widgets.events.ClickHandler; 15 import com.smartgwt.client.widgets.events.ClickHandler;
16 import com.smartgwt.client.widgets.grid.ListGridRecord;
13 import com.smartgwt.client.widgets.layout.HLayout; 17 import com.smartgwt.client.widgets.layout.HLayout;
14 import com.smartgwt.client.widgets.layout.Layout; 18 import com.smartgwt.client.widgets.layout.Layout;
15 import com.smartgwt.client.widgets.layout.VLayout; 19 import com.smartgwt.client.widgets.layout.VLayout;
16 20
17 import de.intevation.flys.client.shared.model.Capabilities; 21 import de.intevation.flys.client.shared.model.Capabilities;
22 import de.intevation.flys.client.shared.model.WMSLayer;
18 import de.intevation.flys.client.client.FLYSConstants; 23 import de.intevation.flys.client.client.FLYSConstants;
19 import de.intevation.flys.client.client.services.GCService; 24 import de.intevation.flys.client.client.services.GCService;
20 import de.intevation.flys.client.client.services.GCServiceAsync; 25 import de.intevation.flys.client.client.services.GCServiceAsync;
21 26
22 27
23 public class ExternalWMSWindow extends Window { 28 public class ExternalWMSWindow extends Window {
24 29
30 public interface LayerLoader {
31 void load(List<WMSLayer> toLoad);
32 } // end of interface WMSLayerLoader
33
34
25 protected GCServiceAsync gcService = GWT.create(GCService.class); 35 protected GCServiceAsync gcService = GWT.create(GCService.class);
26 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 36 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
27 37
28 protected Layout inputPanel; 38 protected Layout inputPanel;
29 protected Layout infoPanel; 39 protected Layout infoPanel;
31 41
32 protected Capabilities capabilites; 42 protected Capabilities capabilites;
33 43
34 protected String url; 44 protected String url;
35 45
36 46 protected LayerLoader loader;
37 public ExternalWMSWindow() { 47
48
49 public ExternalWMSWindow(LayerLoader loader) {
38 super(); 50 super();
51 this.loader = loader;
39 } 52 }
40 53
41 54
42 protected void setUrl(String url) { 55 protected void setUrl(String url) {
43 this.url = url; 56 this.url = url;
210 223
211 224
212 protected Layout createLayersPanel() { 225 protected Layout createLayersPanel() {
213 setTitle(MSG.addwmsLayerTitle()); 226 setTitle(MSG.addwmsLayerTitle());
214 227
228 final WMSLayersTree tree = new WMSLayersTree(capabilites);
229
215 ClickHandler backHandler = new ClickHandler() { 230 ClickHandler backHandler = new ClickHandler() {
216 @Override 231 @Override
217 public void onClick(ClickEvent e) { 232 public void onClick(ClickEvent e) {
218 goToInfoPanel(); 233 goToInfoPanel();
219 } 234 }
220 }; 235 };
221 236
222 ClickHandler goHandler = new ClickHandler() { 237 ClickHandler goHandler = new ClickHandler() {
223 @Override 238 @Override
224 public void onClick(ClickEvent e) { 239 public void onClick(ClickEvent e) {
225 goToLayersPanel(); 240 ListGridRecord[] selection = tree.getSelectedRecords();
241
242 if (selection == null || selection.length == 0) {
243 return;
244 }
245
246 List<WMSLayer> toLoad = new ArrayList<WMSLayer>();
247
248 for (ListGridRecord record: selection) {
249 toLoad.add(
250 ((WMSLayersTree.WMSLayerNode) record).getWMSLayer());
251
252 }
253
254 finish(toLoad);
226 } 255 }
227 }; 256 };
228 257
229 ClickHandler cancelHandler = new ClickHandler() { 258 ClickHandler cancelHandler = new ClickHandler() {
230 @Override 259 @Override
231 public void onClick(ClickEvent e) { 260 public void onClick(ClickEvent e) {
232 quit(); 261 quit();
233 } 262 }
234 }; 263 };
235 264
236 VLayout root = new VLayout(); 265 VLayout root = new VLayout();
237 WMSLayersTree tree = new WMSLayersTree(capabilites);
238 266
239 root.setLayoutMargin(10); 267 root.setLayoutMargin(10);
240 tree.setHeight(420); 268 tree.setHeight(420);
241 269
242 root.addMember(tree); 270 root.addMember(tree);
299 // TODO Improve URL validation 327 // TODO Improve URL validation
300 return !(url == null || url.length() == 0); 328 return !(url == null || url.length() == 0);
301 } 329 }
302 330
303 331
332 protected void finish(List<WMSLayer> toLoad) {
333 loader.load(toLoad);
334
335 quit();
336 }
337
338
304 protected void quit() { 339 protected void quit() {
305 destroy(); 340 destroy();
306 } 341 }
307 342
308 343

http://dive4elements.wald.intevation.org