diff 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
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Mon Nov 21 21:00:03 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/ExternalWMSWindow.java	Tue Nov 22 13:04:46 2011 +0000
@@ -1,5 +1,8 @@
 package de.intevation.flys.client.client.ui.map;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.google.gwt.user.client.ui.TextBox;
@@ -10,11 +13,13 @@
 import com.smartgwt.client.widgets.Window;
 import com.smartgwt.client.widgets.events.ClickEvent;
 import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.Layout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 import de.intevation.flys.client.shared.model.Capabilities;
+import de.intevation.flys.client.shared.model.WMSLayer;
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.services.GCService;
 import de.intevation.flys.client.client.services.GCServiceAsync;
@@ -22,6 +27,11 @@
 
 public class ExternalWMSWindow extends Window {
 
+    public interface LayerLoader {
+        void load(List<WMSLayer> toLoad);
+    } // end of interface WMSLayerLoader
+
+
     protected GCServiceAsync gcService = GWT.create(GCService.class);
     protected FLYSConstants  MSG       = GWT.create(FLYSConstants.class);
 
@@ -33,9 +43,12 @@
 
     protected String url;
 
+    protected LayerLoader loader;
 
-    public ExternalWMSWindow() {
+
+    public ExternalWMSWindow(LayerLoader loader) {
         super();
+        this.loader = loader;
     }
 
 
@@ -212,6 +225,8 @@
     protected Layout createLayersPanel() {
         setTitle(MSG.addwmsLayerTitle());
 
+        final WMSLayersTree tree = new WMSLayersTree(capabilites);
+
         ClickHandler backHandler = new ClickHandler() {
             @Override
             public void onClick(ClickEvent e) {
@@ -222,7 +237,21 @@
         ClickHandler goHandler = new ClickHandler() {
             @Override
             public void onClick(ClickEvent e) {
-                goToLayersPanel();
+                ListGridRecord[] selection = tree.getSelectedRecords();
+
+                if (selection == null || selection.length == 0) {
+                    return;
+                }
+
+                List<WMSLayer> toLoad = new ArrayList<WMSLayer>();
+
+                for (ListGridRecord record: selection) {
+                    toLoad.add(
+                        ((WMSLayersTree.WMSLayerNode) record).getWMSLayer());
+
+                }
+
+                finish(toLoad);
             }
         };
 
@@ -233,8 +262,7 @@
             }
         };
 
-        VLayout       root = new VLayout();
-        WMSLayersTree tree = new WMSLayersTree(capabilites);
+        VLayout root = new VLayout();
 
         root.setLayoutMargin(10);
         tree.setHeight(420);
@@ -301,6 +329,13 @@
     }
 
 
+    protected void finish(List<WMSLayer> toLoad) {
+        loader.load(toLoad);
+
+        quit();
+    }
+
+
     protected void quit() {
         destroy();
     }

http://dive4elements.wald.intevation.org