Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java @ 4472:dc7e41efd5ba
Work (in progress) on a print settings dialog.
Add Wheregroups WMS to printing whitelist.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sat, 10 Nov 2012 00:53:28 +0100 |
parents | |
children | 6db783627137 |
comparison
equal
deleted
inserted
replaced
4471:4e4226d99b49 | 4472:dc7e41efd5ba |
---|---|
1 package de.intevation.flys.client.client.ui.map; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 import com.google.gwt.user.client.rpc.AsyncCallback; | |
5 | |
6 import com.smartgwt.client.util.SC; | |
7 import com.smartgwt.client.widgets.Canvas; | |
8 import com.smartgwt.client.widgets.form.DynamicForm; | |
9 import com.smartgwt.client.widgets.form.fields.ButtonItem; | |
10 import com.smartgwt.client.widgets.form.fields.SelectItem; | |
11 import com.smartgwt.client.widgets.form.fields.TextItem; | |
12 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; | |
13 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; | |
14 | |
15 import de.intevation.flys.client.client.Config; | |
16 import de.intevation.flys.client.client.FLYSConstants; | |
17 import de.intevation.flys.client.client.services.CollectionAttributeService; | |
18 import de.intevation.flys.client.client.services.CollectionAttributeServiceAsync; | |
19 import de.intevation.flys.client.shared.model.Collection; | |
20 import de.intevation.flys.client.shared.model.OutputSettings; | |
21 import de.intevation.flys.client.shared.model.Property; | |
22 import de.intevation.flys.client.shared.model.PropertySetting; | |
23 import de.intevation.flys.client.shared.model.Settings; | |
24 | |
25 import java.util.ArrayList; | |
26 import java.util.LinkedHashMap; | |
27 import java.util.List; | |
28 | |
29 public class MapPrintSettingsPanel extends Canvas { | |
30 | |
31 /** The interface that provides i18n messages. */ | |
32 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
33 | |
34 /** CollectionAttribute Update Service. */ | |
35 protected CollectionAttributeServiceAsync updater = | |
36 GWT.create(CollectionAttributeService.class); | |
37 | |
38 protected Collection collection; | |
39 protected Settings settings; | |
40 protected TextItem pageTitle = new TextItem(); | |
41 | |
42 public MapPrintSettingsPanel(Collection collection) { | |
43 this.collection = collection; | |
44 initLayout(); | |
45 | |
46 this.settings = collection.getSettings("print-settings"); | |
47 if (settings == null) { | |
48 settings = new OutputSettings(); | |
49 } | |
50 else { | |
51 List<Property> properties = settings.getSettings("default"); | |
52 for (Property prop : properties) { | |
53 PropertySetting props = (PropertySetting)prop; | |
54 if (props.getName().equals("page-format")) { | |
55 | |
56 } | |
57 else if (props.getName().equals("page-title")) { | |
58 this.pageTitle.setValue(props.getValue()); | |
59 GWT.log(props.getName() + "=" + props.getValue()); | |
60 } | |
61 } | |
62 } | |
63 } | |
64 | |
65 protected void initLayout() { | |
66 this.pageTitle.setTitle("Seitentitel:"); | |
67 | |
68 DynamicForm df = new DynamicForm(); | |
69 df.setFields( | |
70 createPageFormatSelectItem(), | |
71 this.pageTitle, | |
72 createSaveSettingsButtonItem() | |
73 ); | |
74 addChild(df); | |
75 } | |
76 | |
77 protected SelectItem createPageFormatSelectItem() { | |
78 LinkedHashMap values = new LinkedHashMap(); | |
79 values.put("din_a4", "DIN A4"); | |
80 values.put("din_a0", "DIN A0"); | |
81 | |
82 SelectItem selItem = new SelectItem(); | |
83 selItem.setTitle("Seitenformat:"); | |
84 selItem.setValueMap(values); | |
85 selItem.setDefaultToFirstOption(true); | |
86 | |
87 return selItem; | |
88 } | |
89 | |
90 protected ButtonItem createSaveSettingsButtonItem() { | |
91 ButtonItem btn = new ButtonItem(); | |
92 btn.addClickHandler(new ClickHandler() { | |
93 | |
94 @Override | |
95 public void onClick(ClickEvent event) { | |
96 updateCollection(); | |
97 } | |
98 }); | |
99 btn.setTitle("Speichern"); | |
100 return btn; | |
101 } | |
102 | |
103 protected void updateCollection() { | |
104 final Config config = Config.getInstance(); | |
105 final String loc = config.getLocale(); | |
106 | |
107 GWT.log("MapPrintSettingsPanel.updateCollection via RPC now"); | |
108 | |
109 List<Property> properties = new ArrayList<Property>(); | |
110 properties.add(new PropertySetting("page-title", this.pageTitle.getValueAsString())); | |
111 settings.setSettings("default", properties); | |
112 | |
113 collection.addSettings("print-settings", settings); | |
114 updater.update(collection, loc, new AsyncCallback<Collection>() { | |
115 @Override | |
116 public void onFailure(Throwable caught) { | |
117 GWT.log("Could not update collection attributes."); | |
118 SC.warn(MSG.getString(caught.getMessage())); | |
119 } | |
120 @Override | |
121 public void onSuccess(Collection collection) { | |
122 GWT.log("MapPrintSettings: collection attributes updated"); | |
123 } | |
124 }); | |
125 } | |
126 } |