annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java @ 6245:54f1f4d90c72

Limit PDF map title length to 20 characters (#767).
author Christian Lins <christian.lins@intevation.de>
date Mon, 10 Jun 2013 14:02:32 +0200
parents ea9eef426962
children 9d5f09698d81
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui.map;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
10
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
11 import org.dive4elements.river.client.client.Config;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
12 import org.dive4elements.river.client.client.FLYSConstants;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
13 import org.dive4elements.river.client.client.services.CollectionAttributeService;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
14 import org.dive4elements.river.client.client.services.CollectionAttributeServiceAsync;
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
15 import org.dive4elements.river.client.shared.model.Artifact;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
16 import org.dive4elements.river.client.shared.model.ArtifactDescription;
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
17 import org.dive4elements.river.client.shared.model.Collection;
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
18 import org.dive4elements.river.client.shared.model.Data;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
19 import org.dive4elements.river.client.shared.model.DataItem;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
20 import org.dive4elements.river.client.shared.model.DataList;
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
21 import org.dive4elements.river.client.shared.model.OutputSettings;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.river.client.shared.model.Property;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 import org.dive4elements.river.client.shared.model.PropertySetting;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
24 import org.dive4elements.river.client.shared.model.Settings;
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
25
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
26 import com.google.gwt.core.client.GWT;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
27 import com.google.gwt.user.client.Window;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
28 import com.google.gwt.user.client.rpc.AsyncCallback;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
29 import com.smartgwt.client.types.Alignment;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
30 import com.smartgwt.client.util.SC;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
31 import com.smartgwt.client.widgets.Canvas;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
32 import com.smartgwt.client.widgets.form.DynamicForm;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
33 import com.smartgwt.client.widgets.form.fields.ButtonItem;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
34 import com.smartgwt.client.widgets.form.fields.SelectItem;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
35 import com.smartgwt.client.widgets.form.fields.TextItem;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
36 import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
37 import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
38
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
39 import java.util.ArrayList;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
40 import java.util.LinkedHashMap;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
41 import java.util.List;
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
42 import java.util.MissingResourceException;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
43
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
44 import org.gwtopenmaps.openlayers.client.Bounds;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
45 import org.gwtopenmaps.openlayers.client.Map;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
46
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
47 public class MapPrintPanel extends Canvas {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
48
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
49 private static final String MAPFISH_MAPTITLE = "mapfish_mapTitle";
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
50 private static final String MAPFISH_RANGE = "mapfish_data_range";
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
51 private static final String MAPFISH_SUBTITLE = "mapfish_data_subtitle";
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
52 private static final String MAPFISH_STRETCH = "mapfish_data_strech";
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
53 private static final String MAPFISH_INSTITUTION = "mapfish_data_institution";
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
54 private static final String MAPFISH_SOURCE = "mapfish_data_source";
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
55 private static final String MAPFISH_CREATOR = "mapfish_data_creator";
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
56 private static final String MAPFISH_DATEPLACE = "mapfish_data_dateplace";
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
57 private static final String MAPFISH_RIVER = "mapfish_data_river";
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
58 private static final String MAPFISH_LOGO = "mapfish_logo";
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
59
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
60 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
61
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
62 /** CollectionAttribute Update Service. */
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
63 protected CollectionAttributeServiceAsync updater =
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
64 GWT.create(CollectionAttributeService.class);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
65
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
66
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
67 protected Collection collection;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
68 protected Settings settings;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
69 protected TextItem pageTitle = new TextItem();
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
70 protected TextItem pageRange = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
71 protected TextItem pageSubtitle = new TextItem();
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
72 protected TextItem pageStretch = new TextItem();
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
73 protected TextItem pageInstitution = new TextItem();
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
74 protected TextItem pageSource = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
75 protected TextItem pageCreator = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
76 protected TextItem pageDatePlace = new TextItem();
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
77 protected SelectItem pageLogo = createPageLogoSelectItem();
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
78 // protected SelectItem pageFormat = createPageFormatSelectItem();
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
79 protected MapToolbar mapToolbar;
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
80 protected MapPrintWindow parent;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
81
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
82 public MapPrintPanel(Collection collection, MapToolbar mapToolbar, MapPrintWindow parent) {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
83 this.collection = collection;
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
84 this.mapToolbar = mapToolbar;
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
85 this.parent = parent;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
86 initLayout();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
87
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
88 this.settings = collection.getSettings("print-settings");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
89 if (settings == null) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
90 settings = new OutputSettings();
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
91 GWT.log("settings are empty");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
92 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
93 else {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
94 List<Property> properties = settings.getSettings("default");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
95 for (Property prop : properties) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
96 PropertySetting props = (PropertySetting)prop;
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
97 GWT.log(props.getName() + "=" + props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
98 if (props.getName().equals(MAPFISH_MAPTITLE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
99 this.pageTitle.setValue(props.getValue());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
100 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
101 else if (props.getName().equals(MAPFISH_RANGE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
102 this.pageRange.setValue(props.getValue());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
103 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
104 else if (props.getName().equals(MAPFISH_SUBTITLE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
105 this.pageSubtitle.setValue(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
106 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
107 else if (props.getName().equals(MAPFISH_STRETCH)) {
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
108 this.pageStretch.setValue(props.getValue());
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
109 }
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
110 else if (props.getName().equals(MAPFISH_INSTITUTION)) {
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
111 this.pageInstitution.setValue(props.getValue());
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
112 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
113 else if (props.getName().equals(MAPFISH_SOURCE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
114 this.pageSource.setValue(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
115 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
116 else if (props.getName().equals(MAPFISH_CREATOR)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
117 this.pageCreator.setValue(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
118 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
119 else if (props.getName().equals(MAPFISH_DATEPLACE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
120 this.pageDatePlace.setValue(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
121 } else {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
122 GWT.log("Unknown Print property: " + prop.getName());
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
123 }
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
124 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
125 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
126 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
127
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
128 protected void initLayout() {
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
129 // TODO: i18n
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
130 this.pageTitle.setTitle(MSG.mapTitle());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
131 this.pageSubtitle.setTitle(MSG.mapSubtitle());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
132 this.pageRange.setTitle(MSG.mapRange());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
133 this.pageStretch.setTitle(MSG.mapStretch());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
134 this.pageInstitution.setTitle(MSG.mapInstitution());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
135 this.pageSource.setTitle(MSG.mapSource());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
136 this.pageCreator.setTitle(MSG.mapCreator());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
137 this.pageDatePlace.setTitle(MSG.mapDate());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
138
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
139 pageTitle.setLength(20);
5755
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
140 pageSubtitle.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
141 pageRange.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
142 pageStretch.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
143 pageInstitution.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
144 pageSource.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
145 pageCreator.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
146 pageDatePlace.setLength(30);
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
147 ButtonItem printButton = createPrintButtonItem();
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
148
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
149 printButton.setAlign(Alignment.RIGHT);
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
150
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
151 DynamicForm df = new DynamicForm();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
152 df.setFields(
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
153 // this.pageFormat,
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
154 this.pageTitle,
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
155 this.pageSubtitle,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
156 this.pageRange,
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
157 this.pageStretch,
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
158 this.pageInstitution,
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
159 this.pageSource,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
160 this.pageCreator,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
161 this.pageDatePlace,
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
162 this.pageLogo,
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
163 printButton);
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
164 addChild(df);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
165 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
166
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
167 protected SelectItem createPageLogoSelectItem() {
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
168 LinkedHashMap values = new LinkedHashMap();
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
169 // TODO: this should be configurable
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
170 values.put(MSG.bfgLogo(), "BfG Logo");
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
171
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
172 SelectItem selItem = new SelectItem();
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
173 selItem.setTitle(MSG.mapLogo());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
174 selItem.setValueMap(values);
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
175 selItem.setDefaultToFirstOption(true);
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
176
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
177 return selItem;
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
178 }
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
179
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
180 /*
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
181 * Commented out because we only provide a layout for A4 Landscape atm
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
182
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
183 protected SelectItem createPageFormatSelectItem() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
184 LinkedHashMap values = new LinkedHashMap();
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
185 // TODO: i18n
4965
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
186 values.put("A4 landscape", "DIN A4 (Querformat)");
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
187 //values.put("A4 portrait", "DIN A4 (Hochformat)");
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
188 //values.put("A0 portrait", "DIN A0 (Hochformat)");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
189
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
190 SelectItem selItem = new SelectItem();
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
191 selItem.setTitle("Seitengröße:"); // TODO: i18n
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
192 selItem.setValueMap(values);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
193 selItem.setDefaultToFirstOption(true);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
194
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
195 return selItem;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
196 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
197 */
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
198 protected ButtonItem createPrintButtonItem() {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
199 ButtonItem btn = new ButtonItem();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
200 btn.addClickHandler(new ClickHandler() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
201
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
202 @Override
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
203 public void onClick(ClickEvent event) {
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
204 updateCollection();
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
205 Window.open(createPrintUrl(), "_blank", "");
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
206 parent.destroy();
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
207 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
208 });
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
209 btn.setTitle(MSG.print());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
210 return btn;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
211 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
212
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
213 private String createPrintUrl() {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
214 MapOutputTab ot = (MapOutputTab)mapToolbar.getOutputTab();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
215 Collection collection = ot.getCollection();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
216 String uuid = collection.identifier();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
217
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
218 String mapType = collection.getOutputModes().containsKey("floodmap")
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
219 ? "floodmap"
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
220 : "map";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
221
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
222 StringBuilder url = new StringBuilder();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
223 url.append(GWT.getModuleBaseURL());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
224 url.append("map-print?");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
225
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
226 Map map = mapToolbar.getMap();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
227 Bounds bounds = map.getExtent();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
228
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
229 if (bounds != null) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
230 try {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
231 url.append("minx=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
232 url.append(bounds.getLowerLeftX());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
233 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
234
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
235 url.append("maxx=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
236 url.append(bounds.getUpperRightX());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
237 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
238
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
239 url.append("miny=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
240 url.append(bounds.getLowerLeftY());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
241 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
242
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
243 url.append("maxy=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
244 url.append(bounds.getUpperRightY());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
245 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
246 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
247 catch (Exception e) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
248 // XXX: Ignore it. bounds.getXXX() throw
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
249 // exceptions when bound is invalid. :-/
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
250 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
251 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
252
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
253 url.append("uuid=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
254 url.append(uuid);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
255 url.append("&maptype=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
256 url.append(mapType);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
257
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
258 appendPrintToUrl(collection, url);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
259
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
260 return url.toString();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
261 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
262
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
263 private void appendPrintToUrl(Collection collection, StringBuilder url) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
264 Settings settings = collection.getSettings("print-settings");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
265 if (settings != null) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
266 List<Property> properties = settings.getSettings("default");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
267 for (Property prop : properties) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
268 PropertySetting props = (PropertySetting)prop;
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
269 url.append("&");
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
270 String localized;
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
271 try {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
272 localized = MSG.getString(props.getName());
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
273 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
274 catch (MissingResourceException mre) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
275 localized = props.getName();
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
276 }
5721
280093510e1d Also java encode the info side of the data table
Andre Heinecke <aheinecke@intevation.de>
parents: 5718
diff changeset
277 url.append(toJavaEncodedString(localized));
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
278 url.append("=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
279 url.append(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
280 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
281 }
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
282 // O.o
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
283 String river = findRiver(((MapOutputTab)mapToolbar.getOutputTab()
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
284 ).getCollectionView().getArtifact());
5721
280093510e1d Also java encode the info side of the data table
Andre Heinecke <aheinecke@intevation.de>
parents: 5718
diff changeset
285 url.append("&" + toJavaEncodedString(MSG.getString(MAPFISH_RIVER)) + "=" + river);
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
286 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
287
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
288 // Copy of DatacageWindow's findRiver
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
289 protected String findRiver(Artifact artifact) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
290 ArtifactDescription adescr = artifact.getArtifactDescription();
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
291 DataList [] data = adescr.getOldData();
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
292
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
293 if (data != null && data.length > 0) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
294 for (int i = 0; i < data.length; i++) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
295 DataList dl = data[i];
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
296 if (dl.getState().equals("state.winfo.river")) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
297 for (int j = dl.size()-1; j >= 0; --j) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
298 Data d = dl.get(j);
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
299 DataItem [] di = d.getItems();
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
300 if (di != null && di.length == 1) {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
301 return d.getItems()[0].getStringValue();
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
302 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
303 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
304 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
305 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
306 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
307
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
308 return "";
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
309 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
310
5714
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
311 public static String toJavaEncodedString(String str) {
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
312 if (str == null) {
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
313 return null;
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
314 }
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
315 StringBuilder sb = new StringBuilder();
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
316 for (int i = 0, len = str.length(); i < len; i++) {
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
317 int unipoint = Character.codePointAt(str, i);
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
318 if ((unipoint < 32) || (unipoint > 127)) {
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
319 sb.append("\\u");
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
320 sb.append(Integer.toHexString((unipoint >> 3*4) & 0xf));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
321 sb.append(Integer.toHexString((unipoint >> 2*4) & 0xf));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
322 sb.append(Integer.toHexString((unipoint >> 1*4) & 0xf));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
323 sb.append(Integer.toHexString((unipoint >> 0*4) & 0xf));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
324 } else {
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
325 sb.append(str.charAt(i));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
326 }
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
327 }
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
328 return sb.toString();
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
329 }
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
330
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
331 protected void updateCollection() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
332 final Config config = Config.getInstance();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
333 final String loc = config.getLocale();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
334
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
335 GWT.log("MapPrintPanel.updateCollection via RPC now");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
336
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
337 List<Property> properties = new ArrayList<Property>();
5714
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
338 properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString())));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
339 // properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString())));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
340 properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString())));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
341 properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString())));
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
342 properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStretch.getValueAsString())));
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
343 properties.add(new PropertySetting(MAPFISH_INSTITUTION, toJavaEncodedString(pageInstitution.getValueAsString())));
5714
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
344 properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString())));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
345 properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString())));
1103308b19ca Add toJavaEncodedString function to encode strings in utf-16 notation
Andre Heinecke <aheinecke@intevation.de>
parents: 5675
diff changeset
346 properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString())));
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
347 properties.add(new PropertySetting(MAPFISH_LOGO, toJavaEncodedString(pageLogo.getValueAsString())));
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
348 settings.setSettings("default", properties);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
349
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
350 collection.addSettings("print-settings", settings);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
351 updater.update(collection, loc, new AsyncCallback<Collection>() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
352 @Override
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
353 public void onFailure(Throwable caught) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
354 GWT.log("Could not update collection attributes.");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
355 SC.warn(MSG.getString(caught.getMessage()));
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
356 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
357 @Override
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
358 public void onSuccess(Collection collection) {
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
359 GWT.log("MapPrint: collection attributes updated");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
360 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
361 });
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
362 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
363 }

http://dive4elements.wald.intevation.org