[Dive4elements-commits] [PATCH] Work (in progress) on a print settings dialog

Wald Commits scm-commit at wald.intevation.org
Sat Nov 10 00:53:34 CET 2012


# HG changeset patch
# User Christian Lins <christian.lins at intevation.de>
# Date 1352505208 -3600
# Node ID dc7e41efd5baa289f525965f5b716f36bf9285d7
# Parent  4e4226d99b49c5c0bf0ae645c7aafb176a0ed1f5
Work (in progress) on a print settings dialog.

Add Wheregroups WMS to printing whitelist.

diff -r 4e4226d99b49 -r dc7e41efd5ba flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java	Sat Nov 10 00:53:28 2012 +0100
@@ -0,0 +1,126 @@
+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 {
+
+    /** 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();
+
+    public MapPrintSettingsPanel(Collection collection) {
+        this.collection = collection;
+        initLayout();
+
+        this.settings = collection.getSettings("print-settings");
+        if (settings == null) {
+            settings = new OutputSettings();
+        }
+        else {
+            List<Property> properties = settings.getSettings("default");
+            for (Property prop : properties) {
+                PropertySetting props = (PropertySetting)prop;
+                if (props.getName().equals("page-format")) {
+
+                }
+                else if (props.getName().equals("page-title")) {
+                    this.pageTitle.setValue(props.getValue());
+                    GWT.log(props.getName() + "=" + props.getValue());
+                }
+            }
+        }
+    }
+
+    protected void initLayout() {
+        this.pageTitle.setTitle("Seitentitel:");
+
+        DynamicForm df = new DynamicForm();
+        df.setFields(
+               createPageFormatSelectItem(),
+               this.pageTitle,
+               createSaveSettingsButtonItem()
+               );
+        addChild(df);
+    }
+
+    protected SelectItem createPageFormatSelectItem() {
+        LinkedHashMap values = new LinkedHashMap();
+        values.put("din_a4", "DIN A4");
+        values.put("din_a0", "DIN A0");
+
+        SelectItem selItem = new SelectItem();
+        selItem.setTitle("Seitenformat:");
+        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();
+            }
+        });
+        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("page-title", this.pageTitle.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 4e4226d99b49 -r dc7e41efd5ba flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsWindow.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsWindow.java	Sat Nov 10 00:53:28 2012 +0100
@@ -0,0 +1,21 @@
+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) {
+        setWidth(300);
+        setHeight(400);
+
+        setTitle("PDF-Druckeinstellungen");
+
+        this.panel = new MapPrintSettingsPanel(collection);
+        this.panel.setPadding(20);
+        addItem(this.panel);
+    }
+}
diff -r 4e4226d99b49 -r dc7e41efd5ba 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	Fri Nov 09 16:55:19 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapToolbar.java	Sat Nov 10 00:53:28 2012 +0100
@@ -1,6 +1,7 @@
 package de.intevation.flys.client.client.ui.map;
 
 import com.google.gwt.core.client.GWT;
+
 import com.smartgwt.client.types.Alignment;
 import com.smartgwt.client.types.SelectionType;
 import com.smartgwt.client.util.SC;
@@ -650,7 +651,9 @@
         ImgButton btn = createButton(MSG.printMapSettings(), new ClickHandler() {
             @Override
             public void onClick(ClickEvent event) {
-
+                MapPrintSettingsWindow mpsw =
+                        new MapPrintSettingsWindow(outputTab.getCollection());
+                outputTab.getCollectionView().addChild(mpsw);
             }
         });
         return btn;
diff -r 4e4226d99b49 -r dc7e41efd5ba 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	Fri Nov 09 16:55:19 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/MapPrintServiceImpl.java	Sat Nov 10 00:53:28 2012 +0100
@@ -136,16 +136,15 @@
         String ns = ArtifactNamespaceContext.NAMESPACE_URI;
 
         List<Layer> ls = new ArrayList<Layer>();
-        {   Layer l = new Layer();
+        Layer l = new Layer();
 
-            NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet");
+        NodeList facets = descDocument.getElementsByTagNameNS(ns, "facet");
 
-            for (int i = 0, N = facets.getLength(); i < N; ++i) {
-                Element element = (Element)facets.item(i);
-                if (l.setup(element)) {
-                    ls.add(l);
-                    l = new Layer();
-                }
+        for (int i = 0, N = facets.getLength(); i < N; ++i) {
+            Element element = (Element)facets.item(i);
+            if (l.setup(element)) {
+                ls.add(l);
+                l = new Layer();
             }
         }
 
diff -r 4e4226d99b49 -r dc7e41efd5ba flys-client/src/main/webapp/WEB-INF/config.yaml
--- a/flys-client/src/main/webapp/WEB-INF/config.yaml	Fri Nov 09 16:55:19 2012 +0100
+++ b/flys-client/src/main/webapp/WEB-INF/config.yaml	Sat Nov 10 00:53:28 2012 +0100
@@ -42,6 +42,9 @@
   - !dnsMatch
     host: www.pegelonline.wsv.de
     port: 80
+  - !dnsMatch
+    host: osm.wheregroup.com
+    port: 80
 
 layouts:
   #===========================================================================
diff -r 4e4226d99b49 -r dc7e41efd5ba flys-client/src/main/webapp/images/print_map_settings.png
Binary file flys-client/src/main/webapp/images/print_map_settings.png has changed


More information about the Dive4elements-commits mailing list