changeset 4473:6db783627137

Map print does now submit additional parameters to MapPrintServiceImpl.
author Christian Lins <christian.lins@intevation.de>
date Sat, 10 Nov 2012 23:47:38 +0100
parents dc7e41efd5ba
children bd78d2b0e309
files flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
diffstat 3 files changed, 67 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java	Sat Nov 10 00:53:28 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java	Sat Nov 10 23:47:38 2012 +0100
@@ -46,10 +46,12 @@
         this.settings = collection.getSettings("print-settings");
         if (settings == null) {
             settings = new OutputSettings();
+            GWT.log("settings are empty");
         }
         else {
             List<Property> properties = settings.getSettings("default");
             for (Property prop : properties) {
+                GWT.log("prop=" + prop.getName());
                 PropertySetting props = (PropertySetting)prop;
                 if (props.getName().equals("page-format")) {
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Sat Nov 10 00:53:28 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Sat Nov 10 23:47:38 2012 +0100
@@ -18,8 +18,13 @@
 import de.intevation.flys.client.client.ui.Toolbar;
 import de.intevation.flys.client.client.utils.EnableDisableCmd;
 import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.Property;
+import de.intevation.flys.client.shared.model.PropertySetting;
+import de.intevation.flys.client.shared.model.Settings;
 import de.intevation.flys.client.shared.model.ThemeList;
 
+import java.util.List;
+
 import org.gwtopenmaps.openlayers.client.Bounds;
 import org.gwtopenmaps.openlayers.client.Map;
 import org.gwtopenmaps.openlayers.client.control.DragPan;
@@ -288,7 +293,7 @@
 
         return new ImgLink(
             baseUrl + MSG.downloadPDF(),
-            getPrintUrl(),
+            createPrintUrl(),
             20, 20,
             true);
     }
@@ -688,10 +693,29 @@
 
     @Override
     public void onMapZoom(MapZoomListener.MapZoomEvent e) {
-        printMapLink.setSource(getPrintUrl());
+        printMapLink.setSource(createPrintUrl());
     }
 
-    public String getPrintUrl() {
+    protected void appendPrintSettingsToUrl(Collection collection, StringBuilder url) {
+        Settings settings = collection.getSettings("print-settings");
+        if (settings != null) {
+            List<Property> properties = settings.getSettings("default");
+            for (Property prop : properties) {
+                GWT.log("prop=" + prop.getName());
+                PropertySetting props = (PropertySetting)prop;
+                if (props.getName().equals("page-format")) {
+
+                }
+                else if (props.getName().equals("page-title")) {
+                    url.append("&page-title=");
+                    url.append(props.getValue());
+                    GWT.log(props.getName() + "=" + props.getValue());
+                }
+            }
+        }
+    }
+
+    public String createPrintUrl() {
         MapOutputTab ot = (MapOutputTab)getOutputTab();
         Collection collection = ot.getCollection();
         String uuid = collection.identifier();
@@ -700,21 +724,30 @@
             ? "floodmap"
             : "map";
 
-        String url = GWT.getModuleBaseURL() + "map-print?";
+        StringBuilder url = new StringBuilder();
+        url.append(GWT.getModuleBaseURL());
+        url.append("map-print?");
 
         Map map = getMap();
         Bounds bounds = map.getExtent();
 
         if (bounds != null) {
             try {
-                double minX = bounds.getLowerLeftX();
-                double maxX = bounds.getUpperRightX();
-                double minY = bounds.getLowerLeftY();
-                double maxY = bounds.getUpperRightY();
-                url += "minx=" + minX + "&";
-                url += "maxx=" + maxX + "&";
-                url += "miny=" + minY + "&";
-                url += "maxy=" + maxY + "&";
+                url.append("minx=");
+                url.append(bounds.getLowerLeftX());
+                url.append("&");
+
+                url.append("maxx=");
+                url.append(bounds.getUpperRightX());
+                url.append("&");
+
+                url.append("miny=");
+                url.append(bounds.getLowerLeftY());
+                url.append("&");
+
+                url.append("maxy=");
+                url.append(bounds.getUpperRightY());
+                url.append("&");
             }
             catch (Exception e) {
                 // XXX: Ignore it. bounds.getXXX() throw
@@ -722,9 +755,14 @@
             }
         }
 
-        url += "uuid=" + uuid + "&maptype=" + mapType;
+        url.append("uuid=");
+        url.append(uuid);
+        url.append("&maptype=");
+        url.append(mapType);
 
-        return url;
+        appendPrintSettingsToUrl(collection, url);
+
+        return url.toString();
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Sat Nov 10 00:53:28 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Sat Nov 10 23:47:38 2012 +0100
@@ -19,6 +19,7 @@
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -122,7 +123,8 @@
         Document descDocument,
         MapConfig mapConfig,
         Double minX, Double minY,
-        Double maxX, Double maxY
+        Double maxX, Double maxY,
+        Map<String, Object> settings
     ) {
         Map<String, Object> spec = new LinkedHashMap<String, Object>();
         spec.put("layout",       "A4 portrait");
@@ -184,6 +186,9 @@
         page.put("comment", "Eine mit FLYS gedruckte Karte.");
         page.put("rotation", Integer.valueOf(0));
 
+        // This may overwrite default settings above
+        page.putAll(settings);
+
         pages.add(page);
         spec.put("pages", pages);
 
@@ -250,6 +255,11 @@
             mapType = "map";
         }
 
+        // Retrieve print settings from request
+        Map<String, Object> settings = new HashMap<String, Object>();
+        String pageTitle = req.getParameter("page-title");
+        settings.put("mapTitle", pageTitle);
+
         String url = getURL();
 
         Document requestOut =
@@ -314,7 +324,8 @@
             descDocument,
             mapConfig,
             minX, minY,
-            maxX, maxY);
+            maxX, maxY,
+            settings);
 
         if (log.isDebugEnabled()) {
             log.debug("Generated spec:");

http://dive4elements.wald.intevation.org