annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java @ 5611:17e2324c760e

Renable map print button
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 09 Apr 2013 15:14:15 +0200
parents 0d8564196d73
children b28a6d05e969
rev   line source
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.map;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
2
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
3 import com.google.gwt.core.client.GWT;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
4 import com.google.gwt.user.client.rpc.AsyncCallback;
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
5 import com.google.gwt.user.client.Window;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
6
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
7 import com.smartgwt.client.util.SC;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
8 import com.smartgwt.client.widgets.Canvas;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
9 import com.smartgwt.client.widgets.form.DynamicForm;
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
10 import com.smartgwt.client.widgets.form.fields.TextItem;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.form.fields.ButtonItem;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
14 import com.smartgwt.client.types.Alignment;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
15
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
16 import org.gwtopenmaps.openlayers.client.Bounds;
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
17 import org.gwtopenmaps.openlayers.client.Map;
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
18
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.client.client.Config;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.client.client.FLYSConstants;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.client.client.services.CollectionAttributeService;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
23 import de.intevation.flys.client.shared.model.Collection;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.client.shared.model.OutputSettings;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
25 import de.intevation.flys.client.shared.model.Property;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.client.shared.model.PropertySetting;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.client.shared.model.Settings;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
28
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
29 import java.util.ArrayList;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
30 import java.util.LinkedHashMap;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
31 import java.util.List;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
32
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
33 public class MapPrintPanel extends Canvas {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
34
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
35 private static final String MAPFISH_MAPTITLE = "mapfish-mapTitle";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
36 private static final String MAPFISH_RANGE = "mapfish-range";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
37 private static final String MAPFISH_SUBTITLE = "mapfish-subtitle";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
38 private static final String MAPFISH_STRETCH = "mapfish-strech";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
39 private static final String MAPFISH_CREATED = "mapfish-created";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
40 private static final String MAPFISH_SOURCE = "mapfish-source";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
41 private static final String MAPFISH_CREATOR = "mapfish-creator";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
42 private static final String MAPFISH_DATEPLACE = "mapfish-dateplace";
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
43
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
44 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
45
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
46 /** CollectionAttribute Update Service. */
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
47 protected CollectionAttributeServiceAsync updater =
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
48 GWT.create(CollectionAttributeService.class);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
49
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
50
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
51 protected Collection collection;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
52 protected Settings settings;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
53 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
54 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
55 protected TextItem pageSubtitle = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
56 protected TextItem pageStrech = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
57 protected TextItem pageCreated = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
58 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
59 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
60 protected TextItem pageDatePlace = new TextItem();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
61 // 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
62 protected MapToolbar mapToolbar;
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
63 protected MapPrintWindow parent;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
64
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
65 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
66 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
67 this.mapToolbar = mapToolbar;
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
68 this.parent = parent;
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
69 initLayout();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
70
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
71 this.settings = collection.getSettings("print-settings");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
72 if (settings == null) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
73 settings = new OutputSettings();
4473
6db783627137 Map print does now submit additional parameters to MapPrintServiceImpl.
Christian Lins <christian.lins@intevation.de>
parents: 4472
diff changeset
74 GWT.log("settings are empty");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
75 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
76 else {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
77 List<Property> properties = settings.getSettings("default");
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
78 for (Property prop : properties) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
79 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
80 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
81 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
82 this.pageTitle.setValue(props.getValue());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
83 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
84 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
85 this.pageRange.setValue(props.getValue());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
86 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
87 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
88 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
89 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
90 else if (props.getName().equals(MAPFISH_STRETCH)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
91 this.pageStrech.setValue(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
92 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
93 else if (props.getName().equals(MAPFISH_CREATED)) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
94 this.pageCreated.setValue(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
95 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
96 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
97 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
98 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
99 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
100 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
101 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
102 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
103 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
104 } else {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
105 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
106 }
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
107 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
108 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
109 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
110
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
111 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
112 // TODO: i18n
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
113 this.pageTitle.setTitle("Titel");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
114 this.pageSubtitle.setTitle("Untertitel");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
115 this.pageRange.setTitle("Bereich");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
116 this.pageStrech.setTitle("Strecke");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
117 this.pageCreated.setTitle("Aufgestellt");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
118 this.pageSource.setTitle("Datenquelle");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
119 this.pageCreator.setTitle("Ersteller");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
120 this.pageDatePlace.setTitle("Ort, Datum");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
121
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
122 ButtonItem printButton = createPrintButtonItem();
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
123
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
124 printButton.setAlign(Alignment.RIGHT);
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
125
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
126 DynamicForm df = new DynamicForm();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
127 df.setFields(
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
128 // this.pageFormat,
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
129 this.pageTitle,
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
130 this.pageSubtitle,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
131 this.pageRange,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
132 this.pageStrech,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
133 this.pageCreated,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
134 this.pageSource,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
135 this.pageCreator,
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
136 this.pageDatePlace,
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
137 printButton);
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
138 addChild(df);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
139 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
140
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
141 /*
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
142 * 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
143
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
144 protected SelectItem createPageFormatSelectItem() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
145 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
146 // TODO: i18n
4965
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
147 values.put("A4 landscape", "DIN A4 (Querformat)");
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
148 //values.put("A4 portrait", "DIN A4 (Hochformat)");
8af500d62098 Editing Map print config.
Christian Lins <christian.lins@intevation.de>
parents: 4474
diff changeset
149 //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
150
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
151 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
152 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
153 selItem.setValueMap(values);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
154 selItem.setDefaultToFirstOption(true);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
155
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
156 return selItem;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
157 }
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
158 */
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
159 protected ButtonItem createPrintButtonItem() {
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
160 ButtonItem btn = new ButtonItem();
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
161 GWT.log("Button created");
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
162 btn.addClickHandler(new ClickHandler() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
163
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
164 public void onClick(ClickEvent event) {
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
165 GWT.log("Print Button Click");
5611
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
166 updateCollection();
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
167 Window.open(createPrintUrl(), "_blank", "");
17e2324c760e Renable map print button
Andre Heinecke <aheinecke@intevation.de>
parents: 5606
diff changeset
168 parent.destroy();
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
169 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
170 });
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
171 btn.setTitle(MSG.print());
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
172 return btn;
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
173 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
174
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
175 private String createPrintUrl() {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
176 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
177 Collection collection = ot.getCollection();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
178 String uuid = collection.identifier();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
179
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
180 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
181 ? "floodmap"
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
182 : "map";
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
183
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
184 StringBuilder url = new StringBuilder();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
185 url.append(GWT.getModuleBaseURL());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
186 url.append("map-print?");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
187
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
188 Map map = mapToolbar.getMap();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
189 Bounds bounds = map.getExtent();
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
190
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
191 if (bounds != null) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
192 try {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
193 url.append("minx=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
194 url.append(bounds.getLowerLeftX());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
195 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
196
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
197 url.append("maxx=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
198 url.append(bounds.getUpperRightX());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
199 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
200
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
201 url.append("miny=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
202 url.append(bounds.getLowerLeftY());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
203 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
204
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
205 url.append("maxy=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
206 url.append(bounds.getUpperRightY());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
207 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
208 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
209 catch (Exception e) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
210 // 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
211 // 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
212 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
213 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
214
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
215 url.append("uuid=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
216 url.append(uuid);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
217 url.append("&maptype=");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
218 url.append(mapType);
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
219
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
220 appendPrintToUrl(collection, url);
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 return url.toString();
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
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
225 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
226 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
227 if (settings != null) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
228 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
229 for (Property prop : properties) {
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
230 PropertySetting props = (PropertySetting)prop;
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
231 url.append("&");
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
232 url.append(props.getName());
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 url.append(props.getValue());
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
235 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
236 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
237 }
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
238
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
239 protected void updateCollection() {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
240 final Config config = Config.getInstance();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
241 final String loc = config.getLocale();
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
242
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
243 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
244
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
245 List<Property> properties = new ArrayList<Property>();
4474
bd78d2b0e309 Map print settings can now be configured via settings window.
Christian Lins <christian.lins@intevation.de>
parents: 4473
diff changeset
246 properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString()));
5606
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
247 // properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
248 properties.add(new PropertySetting(MAPFISH_SUBTITLE, this.pageSubtitle.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
249 properties.add(new PropertySetting(MAPFISH_RANGE, this.pageRange.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
250 properties.add(new PropertySetting(MAPFISH_STRETCH, this.pageStrech.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
251 properties.add(new PropertySetting(MAPFISH_CREATED, this.pageCreated.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
252 properties.add(new PropertySetting(MAPFISH_SOURCE, this.pageSource.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
253 properties.add(new PropertySetting(MAPFISH_CREATOR, this.pageCreator.getValueAsString()));
0d8564196d73 Break printing to rework the parametrization of the print job
Andre Heinecke <aheinecke@intevation.de>
parents: 4965
diff changeset
254 properties.add(new PropertySetting(MAPFISH_DATEPLACE, this.pageDatePlace.getValueAsString()));
4472
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
255 settings.setSettings("default", properties);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
256
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
257 collection.addSettings("print-settings", settings);
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
258 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
259 @Override
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
260 public void onFailure(Throwable caught) {
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
261 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
262 SC.warn(MSG.getString(caught.getMessage()));
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
263 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
264 @Override
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
265 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
266 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
267 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
268 });
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
269 }
dc7e41efd5ba Work (in progress) on a print settings dialog.
Christian Lins <christian.lins@intevation.de>
parents:
diff changeset
270 }

http://dive4elements.wald.intevation.org