annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 890f708b18d6
children
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;
8844
890f708b18d6 Encode print URL with GWT-means.
Tom Gottfried <tom@intevation.de>
parents: 7251
diff changeset
27 import com.google.gwt.http.client.URL;
6245
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.Window;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
29 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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
40 import java.util.ArrayList;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
41 import java.util.LinkedHashMap;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
42 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
43 import java.util.MissingResourceException;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
44
6245
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.Bounds;
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
46 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
47
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
48 public class MapPrintPanel extends Canvas {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
49
5675
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_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
51 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
52 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
53 private static final String MAPFISH_STRETCH = "mapfish_data_strech";
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
54 private static final String MAPFISH_INSTITUTION =
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
55 "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
56 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
57 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
58 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
59 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
60 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
61
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
62 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
63
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
64 /** CollectionAttribute Update Service. */
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
65 protected CollectionAttributeServiceAsync updater =
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
66 GWT.create(CollectionAttributeService.class);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
67
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
68
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
69 protected Collection collection;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
70 protected Settings settings;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
71 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
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79 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
80 // 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
81 protected MapToolbar mapToolbar;
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
82 protected MapPrintWindow parent;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
83
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
84 public MapPrintPanel(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
85 Collection collection,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
86 MapToolbar mapToolbar,
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
87 MapPrintWindow parent
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
88 ) {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
89 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
90 this.mapToolbar = mapToolbar;
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
91 this.parent = parent;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
92 initLayout();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
93
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
94 this.settings = collection.getSettings("print-settings");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
95 if (settings == null) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
96 settings = new OutputSettings();
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
97 GWT.log("settings are empty");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
98 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
99 else {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
100 List<Property> properties = settings.getSettings("default");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
101 for (Property prop : properties) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
102 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
103 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
104 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
105 this.pageTitle.setValue(props.getValue());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
106 }
5606
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_RANGE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
108 this.pageRange.setValue(props.getValue());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
109 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
110 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
111 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
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_STRETCH)) {
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
114 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
115 }
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
116 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
117 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
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_SOURCE)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
120 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
121 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
122 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
123 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
124 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
125 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
126 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
127 } else {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
128 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
129 }
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
130 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
131 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
132 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
133
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
134 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
135 // TODO: i18n
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 this.pageDatePlace.setTitle(MSG.mapDate());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
144
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
145 pageTitle.setLength(20);
5755
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
146 pageSubtitle.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
147 pageRange.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
148 pageStretch.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
149 pageInstitution.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
150 pageSource.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
151 pageCreator.setLength(30);
3e2ab854d5c0 Increase acceptet print dialog input length to 30
Andre Heinecke <aheinecke@intevation.de>
parents: 5721
diff changeset
152 pageDatePlace.setLength(30);
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
153 ButtonItem printButton = createPrintButtonItem();
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
154
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
155 printButton.setAlign(Alignment.RIGHT);
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
156
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
157 DynamicForm df = new DynamicForm();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
158 df.setFields(
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
159 // this.pageFormat,
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
160 this.pageTitle,
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
161 this.pageSubtitle,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
162 this.pageRange,
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
163 this.pageStretch,
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
164 this.pageInstitution,
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
165 this.pageSource,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
166 this.pageCreator,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
167 this.pageDatePlace,
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
168 this.pageLogo,
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
169 printButton);
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
170 addChild(df);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
171 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
172
5717
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
173 protected SelectItem createPageLogoSelectItem() {
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
174 LinkedHashMap values = new LinkedHashMap();
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
175 // 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
176 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
177
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
178 SelectItem selItem = new SelectItem();
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
179 selItem.setTitle(MSG.mapLogo());
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
180 selItem.setValueMap(values);
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
181 selItem.setDefaultToFirstOption(true);
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
182
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
183 return selItem;
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
184 }
22e03ca8c39d Add configurable logo for map print and rename/reorder fields
Andre Heinecke <aheinecke@intevation.de>
parents: 5714
diff changeset
185
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
186 /*
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
187 * 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
188
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
189 protected SelectItem createPageFormatSelectItem() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
190 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
191 // TODO: i18n
4965
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
192 values.put("A4 landscape", "DIN A4 (Querformat)");
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
193 //values.put("A4 portrait", "DIN A4 (Hochformat)");
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
194 //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
195
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
196 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
197 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
198 selItem.setValueMap(values);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
199 selItem.setDefaultToFirstOption(true);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
200
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
201 return selItem;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
202 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
203 */
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
204 protected ButtonItem createPrintButtonItem() {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
205 ButtonItem btn = new ButtonItem();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
206 btn.addClickHandler(new ClickHandler() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
207
6245
54f1f4d90c72 Limit PDF map title length to 20 characters (#767).
Christian Lins <christian.lins@intevation.de>
parents: 5993
diff changeset
208 @Override
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
209 public void onClick(ClickEvent event) {
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
210 updateCollection();
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
211 Window.open(createPrintUrl(), "_blank", "");
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
212 parent.destroy();
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
213 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
214 });
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
215 btn.setTitle(MSG.print());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
216 return btn;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
217 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
218
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
219 private String createPrintUrl() {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
220 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
221 Collection collection = ot.getCollection();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
222 String uuid = collection.identifier();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
223
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
224 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
225 ? "floodmap"
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
226 : "map";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
227
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
228 StringBuilder url = new StringBuilder();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
229 url.append(GWT.getModuleBaseURL());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
230 url.append("map-print?");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
231
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
232 Map map = mapToolbar.getMap();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
233 Bounds bounds = map.getExtent();
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 if (bounds != null) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
236 try {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
237 url.append("minx=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
238 url.append(bounds.getLowerLeftX());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
239 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
240
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
241 url.append("maxx=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
242 url.append(bounds.getUpperRightX());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
243 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
244
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
245 url.append("miny=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
246 url.append(bounds.getLowerLeftY());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
247 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
248
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
249 url.append("maxy=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
250 url.append(bounds.getUpperRightY());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
251 url.append("&");
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 catch (Exception e) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
254 // 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
255 // 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
256 }
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
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
259 url.append("uuid=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
260 url.append(uuid);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
261 url.append("&maptype=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
262 url.append(mapType);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
263
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
264 appendPrintToUrl(collection, url);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
265
8844
890f708b18d6 Encode print URL with GWT-means.
Tom Gottfried <tom@intevation.de>
parents: 7251
diff changeset
266 return URL.encode(url.toString());
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
267 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
268
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
269 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
270 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
271 if (settings != null) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
272 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
273 for (Property prop : properties) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
274 PropertySetting props = (PropertySetting)prop;
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
275 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
276 String localized;
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
277 try {
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
278 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
279 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
280 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
281 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
282 }
8844
890f708b18d6 Encode print URL with GWT-means.
Tom Gottfried <tom@intevation.de>
parents: 7251
diff changeset
283 url.append(localized);
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
284 url.append("=");
8844
890f708b18d6 Encode print URL with GWT-means.
Tom Gottfried <tom@intevation.de>
parents: 7251
diff changeset
285 url.append((String)props.getValue());
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
286 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
287 }
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
288 // O.o
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
289 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
290 ).getCollectionView().getArtifact());
8844
890f708b18d6 Encode print URL with GWT-means.
Tom Gottfried <tom@intevation.de>
parents: 7251
diff changeset
291 url.append("&" + 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
292 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
293
6379
9d5f09698d81 Search the river name also in the map.river state
Andre Heinecke <aheinecke@intevation.de>
parents: 6245
diff changeset
294 // Copy of DatacageWindow's findRiver with added state for map.river
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
295 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
296 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
297 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
298
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
299 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
300 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
301 DataList dl = data[i];
6379
9d5f09698d81 Search the river name also in the map.river state
Andre Heinecke <aheinecke@intevation.de>
parents: 6245
diff changeset
302 if (dl.getState().equals("state.winfo.river") ||
9d5f09698d81 Search the river name also in the map.river state
Andre Heinecke <aheinecke@intevation.de>
parents: 6245
diff changeset
303 dl.getState().equals("state.map.river")) {
5675
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
304 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
305 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
306 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
307 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
308 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
309 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
310 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
311 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
312 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
313 }
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
314
10aac4ec2d76 Localize the _data strings, limit the input in the panel and Search
Andre Heinecke <aheinecke@intevation.de>
parents: 5622
diff changeset
315 return "";
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
316 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
317
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
318 protected void updateCollection() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
319 final Config config = Config.getInstance();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
320 final String loc = config.getLocale();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
321
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
322 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
323
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
324 List<Property> properties = new ArrayList<Property>();
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
325 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
326 MAPFISH_MAPTITLE, pageTitle.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
327 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
328 MAPFISH_SUBTITLE, pageSubtitle.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
329 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
330 MAPFISH_RANGE, pageRange.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
331 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
332 MAPFISH_STRETCH, pageStretch.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
333 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
334 MAPFISH_INSTITUTION, pageInstitution.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
335 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
336 MAPFISH_SOURCE, pageSource.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
337 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
338 MAPFISH_CREATOR, pageCreator.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
339 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
340 MAPFISH_DATEPLACE, pageDatePlace.getValueAsString()));
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
341 properties.add(new PropertySetting(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8844
diff changeset
342 MAPFISH_LOGO, pageLogo.getValueAsString()));
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
343 settings.setSettings("default", properties);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
344
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
345 collection.addSettings("print-settings", settings);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
346 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
347 @Override
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
348 public void onFailure(Throwable caught) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
349 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
350 SC.warn(MSG.getString(caught.getMessage()));
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
351 }
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 onSuccess(Collection collection) {
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
354 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
355 }
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 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
358 }

http://dive4elements.wald.intevation.org