[Dive4elements-commits] [PATCH 2 of 2] Break printing to rework the parametrization of the print job

Wald Commits scm-commit at wald.intevation.org
Tue Apr 9 11:52:43 CEST 2013


# HG changeset patch
# User Andre Heinecke <aheinecke at intevation.de>
# Date 1365501089 -7200
# Node ID 0d8564196d73780553d8e6af40a509d1139bf6f8
# Parent  6372fd8bfb00d11515ae8bbd139115f277318c4e
Break printing to rework the parametrization of the print job

    There is now only one print button that opens a dialog
    with input fields for additional attributes as specified by
    desktop flys.
    Currently the print button does not work and this commit
    is part of a WIP.

diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Apr 08 17:40:20 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Tue Apr 09 11:51:29 2013 +0200
@@ -1204,5 +1204,11 @@
 
     String gauge_tendency();
 
+    String printTooltip();
+
+    String print();
+
+    String printWindowTitle();
+
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Apr 08 17:40:20 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Tue Apr 09 11:51:29 2013 +0200
@@ -144,6 +144,7 @@
 panControlTooltip = Pan
 zoomboxTooltip = Zoombox
 chartPropertiesTooltip = Chartproperties
+printTooltip = Print
 
 description = Description
 from = From
@@ -189,6 +190,8 @@
 footerHome = Home
 footerContact = Contact
 footerImpressum = Legal info
+print = Print
+printWindowTitle = PDF-Print Settings
 
 projectListMin = format-indent-less.png
 projectListAdd = list-add.png
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Apr 08 17:40:20 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Tue Apr 09 11:51:29 2013 +0200
@@ -176,6 +176,8 @@
 footerHome = Home
 footerContact = Kontakt
 footerImpressum = Impressum
+print = Drucken
+printWindowTitle = PDF-Druckeinstellungen
 
 projectListMin = format-indent-less.png
 projectListAdd = list-add.png
@@ -206,6 +208,7 @@
 panControlTooltip = Verschieben
 zoomboxTooltip = Ausschnitt vergr\u00f6\u00dfern
 chartPropertiesTooltip = Diagrammeigenschaften
+printTooltip = Drucken
 
 static_sqrelation = Transport-Abfluss Beziehung
 discharge_curve = Abflusskurve am Pegel
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java	Tue Apr 09 11:51:29 2013 +0200
@@ -0,0 +1,268 @@
+package de.intevation.flys.client.client.ui.map;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.Window;
+
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.ButtonItem;
+import com.smartgwt.client.widgets.form.fields.SelectItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+
+import org.gwtopenmaps.openlayers.client.Bounds;
+import org.gwtopenmaps.openlayers.client.Map;
+
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.FLYSConstants;
+import de.intevation.flys.client.client.services.CollectionAttributeService;
+import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.OutputSettings;
+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 java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+public class MapPrintPanel extends Canvas {
+
+    private static final String MAPFISH_MAPTITLE = "mapfish-mapTitle";
+    private static final String MAPFISH_RANGE = "mapfish-range";
+    private static final String MAPFISH_SUBTITLE = "mapfish-subtitle";
+    private static final String MAPFISH_STRETCH = "mapfish-strech";
+    private static final String MAPFISH_CREATED = "mapfish-created";
+    private static final String MAPFISH_SOURCE = "mapfish-source";
+    private static final String MAPFISH_CREATOR = "mapfish-creator";
+    private static final String MAPFISH_DATEPLACE = "mapfish-dateplace";
+
+    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    /** CollectionAttribute Update Service. */
+    protected CollectionAttributeServiceAsync updater =
+        GWT.create(CollectionAttributeService.class);
+
+
+    protected Collection collection;
+    protected Settings settings;
+    protected TextItem pageTitle = new TextItem();
+    protected TextItem pageRange = new TextItem();
+    protected TextItem pageSubtitle = new TextItem();
+    protected TextItem pageStrech = new TextItem();
+    protected TextItem pageCreated = new TextItem();
+    protected TextItem pageSource = new TextItem();
+    protected TextItem pageCreator = new TextItem();
+    protected TextItem pageDatePlace = new TextItem();
+//    protected SelectItem pageFormat = createPageFormatSelectItem();
+    protected MapToolbar mapToolbar;
+    protected MapPrintWindow parent;
+
+    public MapPrintPanel(Collection collection, MapToolbar mapToolbar, MapPrintWindow parent) {
+        this.collection = collection;
+        this.mapToolbar = mapToolbar;
+        this.parent     = parent;
+        initLayout();
+
+        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) {
+                PropertySetting props = (PropertySetting)prop;
+                GWT.log(props.getName() + "=" + props.getValue());
+                if (props.getName().equals(MAPFISH_MAPTITLE)) {
+                    this.pageTitle.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_RANGE)) {
+                    this.pageRange.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_SUBTITLE)) {
+                    this.pageSubtitle.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_STRETCH)) {
+                    this.pageStrech.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_CREATED)) {
+                    this.pageCreated.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_SOURCE)) {
+                    this.pageSource.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_CREATOR)) {
+                    this.pageCreator.setValue(props.getValue());
+                }
+                else if (props.getName().equals(MAPFISH_DATEPLACE)) {
+                    this.pageDatePlace.setValue(props.getValue());
+                } else {
+                    GWT.log("Unknown Print property: " + prop.getName());
+                }
+            }
+        }
+    }
+
+    protected void initLayout() {
+        // TODO: i18n
+        this.pageTitle.setTitle("Titel");
+        this.pageSubtitle.setTitle("Untertitel");
+        this.pageRange.setTitle("Bereich");
+        this.pageStrech.setTitle("Strecke");
+        this.pageCreated.setTitle("Aufgestellt");
+        this.pageSource.setTitle("Datenquelle");
+        this.pageCreator.setTitle("Ersteller");
+        this.pageDatePlace.setTitle("Ort, Datum");
+
+        DynamicForm df = new DynamicForm();
+        df.setFields(
+//               this.pageFormat,
+               this.pageTitle,
+               this.pageSubtitle,
+               this.pageRange,
+               this.pageStrech,
+               this.pageCreated,
+               this.pageSource,
+               this.pageCreator,
+               this.pageDatePlace,
+               createPrintButtonItem()
+               );
+        addChild(df);
+    }
+
+/*
+ * Commented out because we only provide a layout for A4 Landscape atm
+
+    protected SelectItem createPageFormatSelectItem() {
+        LinkedHashMap values = new LinkedHashMap();
+        // TODO: i18n
+        values.put("A4 landscape", "DIN A4 (Querformat)");
+        //values.put("A4 portrait", "DIN A4 (Hochformat)");
+        //values.put("A0 portrait", "DIN A0 (Hochformat)");
+
+        SelectItem selItem = new SelectItem();
+        selItem.setTitle("Seitengröße:"); // TODO: i18n
+        selItem.setValueMap(values);
+        selItem.setDefaultToFirstOption(true);
+
+        return selItem;
+    }
+*/
+    protected ButtonItem createPrintButtonItem() {
+        ButtonItem btn = new ButtonItem();
+        GWT.log("Button created");
+        btn.addClickHandler(new ClickHandler() {
+
+            @Override
+            public void onClick(ClickEvent event) {
+                GWT.log("Print Button Click");
+//                updateCollection();
+                //Window.open(createPrintUrl(), "_blank", "");
+//                parent.destroy();
+            }
+        });
+        btn.setTitle(MSG.print());
+        return btn;
+    }
+
+    private String createPrintUrl() {
+        MapOutputTab ot = (MapOutputTab)mapToolbar.getOutputTab();
+        Collection collection = ot.getCollection();
+        String uuid = collection.identifier();
+
+        String mapType = collection.getOutputModes().containsKey("floodmap")
+            ? "floodmap"
+            : "map";
+
+        StringBuilder url = new StringBuilder();
+        url.append(GWT.getModuleBaseURL());
+        url.append("map-print?");
+
+        Map map = mapToolbar.getMap();
+        Bounds bounds = map.getExtent();
+
+        if (bounds != null) {
+            try {
+                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
+                // exceptions when bound is invalid. :-/
+            }
+        }
+
+        url.append("uuid=");
+        url.append(uuid);
+        url.append("&maptype=");
+        url.append(mapType);
+
+        appendPrintToUrl(collection, url);
+
+        return url.toString();
+    }
+
+    private void appendPrintToUrl(Collection collection, StringBuilder url) {
+        Settings settings = collection.getSettings("print-settings");
+        if (settings != null) {
+            List<Property> properties = settings.getSettings("default");
+            for (Property prop : properties) {
+                PropertySetting props = (PropertySetting)prop;
+                url.append("&");
+                url.append(props.getName());
+                url.append("=");
+                url.append(props.getValue());
+            }
+        }
+    }
+
+    protected void updateCollection() {
+        final Config config = Config.getInstance();
+        final String loc    = config.getLocale();
+
+        GWT.log("MapPrintPanel.updateCollection via RPC now");
+
+        List<Property> properties = new ArrayList<Property>();
+        properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString()));
+//        properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_SUBTITLE, this.pageSubtitle.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_RANGE, this.pageRange.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_STRETCH, this.pageStrech.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_CREATED, this.pageCreated.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_SOURCE, this.pageSource.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_CREATOR, this.pageCreator.getValueAsString()));
+        properties.add(new PropertySetting(MAPFISH_DATEPLACE, this.pageDatePlace.getValueAsString()));
+        settings.setSettings("default", properties);
+
+        collection.addSettings("print-settings", settings);
+        updater.update(collection, loc, new AsyncCallback<Collection>() {
+            @Override
+            public void onFailure(Throwable caught) {
+                GWT.log("Could not update collection attributes.");
+                SC.warn(MSG.getString(caught.getMessage()));
+            }
+            @Override
+            public void onSuccess(Collection collection) {
+                GWT.log("MapPrint: collection attributes updated");
+            }
+        });
+    }
+}
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java	Mon Apr 08 17:40:20 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-package de.intevation.flys.client.client.ui.map;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.ButtonItem;
-import com.smartgwt.client.widgets.form.fields.SelectItem;
-import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
-
-import de.intevation.flys.client.client.Config;
-import de.intevation.flys.client.client.FLYSConstants;
-import de.intevation.flys.client.client.services.CollectionAttributeService;
-import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync;
-import de.intevation.flys.client.shared.model.Collection;
-import de.intevation.flys.client.shared.model.OutputSettings;
-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 java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-public class MapPrintSettingsPanel extends Canvas {
-
-    public static final String MAPFISH_COMMENT  = "mapfish-comment";
-    public static final String MAPFISH_LAYOUT   = "mapfish-layout";
-    public static final String MAPFISH_MAPTITLE = "mapfish-mapTitle";
-    public static final String MAPFISH_PAGESIZE = "mapfish-pageSize";
-
-    /** The interface that provides i18n messages. */
-    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
-
-    /** CollectionAttribute Update Service. */
-    protected CollectionAttributeServiceAsync updater =
-        GWT.create(CollectionAttributeService.class);
-
-    protected Collection collection;
-    protected Settings settings;
-    protected TextItem pageTitle = new TextItem();
-    protected SelectItem pageFormat = createPageFormatSelectItem();
-    protected TextItem pageComment = new TextItem();
-    protected MapToolbar mapToolbar;
-    protected MapPrintSettingsWindow parent;
-
-    public MapPrintSettingsPanel(Collection collection, MapToolbar mapToolbar, MapPrintSettingsWindow parent) {
-        this.collection = collection;
-        this.mapToolbar = mapToolbar;
-        this.parent     = parent;
-        initLayout();
-
-        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(MAPFISH_PAGESIZE)) {
-                    this.pageFormat.setValue(props.getValue());
-                }
-                else if (props.getName().equals(MAPFISH_MAPTITLE)) {
-                    this.pageTitle.setValue(props.getValue());
-                    GWT.log(props.getName() + "=" + props.getValue());
-                }
-                else if (props.getName().equals(MAPFISH_COMMENT)) {
-                    this.pageComment.setValue(props.getValue());
-                }
-            }
-        }
-    }
-
-    protected void initLayout() {
-        // TODO: i18n
-        this.pageTitle.setTitle("Seitentitel:");
-        this.pageComment.setTitle("Kommentar:");
-
-        DynamicForm df = new DynamicForm();
-        df.setFields(
-               this.pageFormat,
-               this.pageTitle,
-               this.pageComment,
-               createSaveSettingsButtonItem()
-               );
-        addChild(df);
-    }
-
-    protected SelectItem createPageFormatSelectItem() {
-        LinkedHashMap values = new LinkedHashMap();
-        // TODO: i18n
-        values.put("A4 landscape", "DIN A4 (Querformat)");
-        //values.put("A4 portrait", "DIN A4 (Hochformat)");
-        //values.put("A0 portrait", "DIN A0 (Hochformat)");
-
-        SelectItem selItem = new SelectItem();
-        selItem.setTitle("Seitengröße:"); // TODO: i18n
-        selItem.setValueMap(values);
-        selItem.setDefaultToFirstOption(true);
-
-        return selItem;
-    }
-
-    protected ButtonItem createSaveSettingsButtonItem() {
-        ButtonItem btn = new ButtonItem();
-        btn.addClickHandler(new ClickHandler() {
-
-            @Override
-            public void onClick(ClickEvent event) {
-                updateCollection();
-                mapToolbar.updatePrintUrl();
-                parent.destroy();
-            }
-        });
-        btn.setTitle("Speichern");
-        return btn;
-    }
-
-    protected void updateCollection() {
-        final Config config = Config.getInstance();
-        final String loc    = config.getLocale();
-
-        GWT.log("MapPrintSettingsPanel.updateCollection via RPC now");
-
-        List<Property> properties = new ArrayList<Property>();
-        properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString()));
-        properties.add(new PropertySetting(MAPFISH_COMMENT, this.pageComment.getValueAsString()));
-        properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString()));
-        settings.setSettings("default", properties);
-
-        collection.addSettings("print-settings", settings);
-        updater.update(collection, loc, new AsyncCallback<Collection>() {
-            @Override
-            public void onFailure(Throwable caught) {
-                GWT.log("Could not update collection attributes.");
-                SC.warn(MSG.getString(caught.getMessage()));
-            }
-            @Override
-            public void onSuccess(Collection collection) {
-                GWT.log("MapPrintSettings: collection attributes updated");
-            }
-        });
-    }
-}
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsWindow.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsWindow.java	Mon Apr 08 17:40:20 2013 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-package de.intevation.flys.client.client.ui.map;
-
-import com.smartgwt.client.widgets.Window;
-
-import de.intevation.flys.client.shared.model.Collection;
-
-public class MapPrintSettingsWindow extends Window {
-
-    protected MapPrintSettingsPanel panel;
-
-    public MapPrintSettingsWindow(Collection collection, MapToolbar mapToolbar) {
-        setWidth(300);
-        setHeight(200);
-
-        // TODO: i18n
-        setTitle("PDF-Druckeinstellungen");
-
-        this.panel = new MapPrintSettingsPanel(collection, mapToolbar, this);
-        this.panel.setPadding(20);
-        addItem(this.panel);
-
-        setIsModal(true);
-        setShowModalMask(true);
-    }
-}
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintWindow.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintWindow.java	Tue Apr 09 11:51:29 2013 +0200
@@ -0,0 +1,26 @@
+package de.intevation.flys.client.client.ui.map;
+
+import com.smartgwt.client.widgets.Window;
+import com.google.gwt.core.client.GWT;
+
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.client.FLYSConstants;
+
+public class MapPrintWindow extends Window {
+    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
+
+    protected MapPrintPanel panel;
+
+    public MapPrintWindow(Collection collection, MapToolbar mapToolbar) {
+        setWidth(255);
+        setHeight(280);
+
+        setTitle(MSG.printWindowTitle());
+
+        this.panel = new MapPrintPanel(collection, mapToolbar, this);
+        this.panel.setPadding(20);
+        addItem(this.panel);
+
+        setShowModalMask(true);
+    }
+}
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Mon Apr 08 17:40:20 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Tue Apr 09 11:51:29 2013 +0200
@@ -25,7 +25,6 @@
 
 import java.util.List;
 
-import org.gwtopenmaps.openlayers.client.Bounds;
 import org.gwtopenmaps.openlayers.client.Map;
 import org.gwtopenmaps.openlayers.client.control.DragPan;
 import org.gwtopenmaps.openlayers.client.control.SelectFeature;
@@ -66,8 +65,7 @@
     protected ImgButton infoButton;
     protected ImgButton removeButton;
     protected ImgButton elevationButton;
-    protected ImgLink   printMapLink;
-    protected ImgButton printMapSettings;
+    protected ImgButton printMap;
 
     protected Label epsgLabel;
 
@@ -124,11 +122,8 @@
             addWMSButton = createWMSControl();
             addMember(addWMSButton);
 
-            printMapLink = createPrintMapLink();
-            addMember(printMapLink);
-
-            printMapSettings = createMapPrintSettingsControl();
-            addMember(printMapSettings);
+            printMap = createMapPrintControl();
+            addMember(printMap);
         }
 
         addMember(zoomToMaxButton);
@@ -281,18 +276,6 @@
         return btn;
     }
 
-    protected ImgLink createPrintMapLink() {
-        String baseUrl = GWT.getHostPageBaseURL();
-
-        getMap().addMapZoomListener(this);
-
-        return new ImgLink(
-            baseUrl + MSG.downloadPDF(),
-            createPrintUrl(),
-            20, 20,
-            true);
-    }
-
 
     protected ImgButton createMaxExtentControl() {
         ImgButton zoomToMax = createButton(MSG.zoom_all(), new ClickHandler() {
@@ -647,16 +630,18 @@
     }
 
 
-    protected ImgButton createMapPrintSettingsControl() {
+    protected ImgButton createMapPrintControl() {
         final MapToolbar mtb = this;
         ImgButton btn = createButton(MSG.printMapSettings(), new ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
-                MapPrintSettingsWindow mpsw =
-                        new MapPrintSettingsWindow(outputTab.getCollection(), mtb);
+                MapPrintWindow mpsw =
+                        new MapPrintWindow(outputTab.getCollection(), mtb);
                 outputTab.getCollectionView().addChild(mpsw);
             }
         });
+        btn.setTooltip(MSG.printTooltip());
+
         return btn;
     }
 
@@ -689,78 +674,9 @@
 
     @Override
     public void onMapZoom(MapZoomListener.MapZoomEvent e) {
-        updatePrintUrl();
+//        updatePrintUrl();
     }
 
-    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) {
-                PropertySetting props = (PropertySetting)prop;
-                url.append("&");
-                url.append(props.getName());
-                url.append("=");
-                url.append(props.getValue());
-            }
-        }
-    }
-
-    public void updatePrintUrl() {
-        printMapLink.setSource(createPrintUrl());
-    }
-
-    public String createPrintUrl() {
-        MapOutputTab ot = (MapOutputTab)getOutputTab();
-        Collection collection = ot.getCollection();
-        String uuid = collection.identifier();
-
-        String mapType = collection.getOutputModes().containsKey("floodmap")
-            ? "floodmap"
-            : "map";
-
-        StringBuilder url = new StringBuilder();
-        url.append(GWT.getModuleBaseURL());
-        url.append("map-print?");
-
-        Map map = getMap();
-        Bounds bounds = map.getExtent();
-
-        if (bounds != null) {
-            try {
-                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
-                // exceptions when bound is invalid. :-/
-            }
-        }
-
-        url.append("uuid=");
-        url.append(uuid);
-        url.append("&maptype=");
-        url.append(mapType);
-
-        appendPrintSettingsToUrl(collection, url);
-
-        return url.toString();
-    }
-
-
     public void updateThemes(ThemeList themeList) {
         if (legendWindow != null) {
             legendWindow.update(themeList);
diff -r 6372fd8bfb00 -r 0d8564196d73 flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java
--- a/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Mon Apr 08 17:40:20 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Tue Apr 09 11:51:29 2013 +0200
@@ -11,6 +11,7 @@
 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler;
 import de.intevation.flys.client.shared.MapUtils;
 import de.intevation.flys.client.shared.model.MapConfig;
+import de.intevation.flys.client.client.FLYSConstants;
 
 import java.io.IOException;
 import java.io.InputStream;


More information about the Dive4elements-commits mailing list