Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/map/MapPrintPanel.java @ 6384:2987d81ea719
Further fix encoding handling in the print service
- Strings are now html escaped additionaly to java encoding
- Escaping / encoding moved into maputils
- The legend url is urlencoded
- Properties are no longer stored in an encoded manner but
rather encoded on demand
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 21 Jun 2013 12:15:30 +0200 |
parents | 9d5f09698d81 |
children | 3823b8bd6bfd |
comparison
equal
deleted
inserted
replaced
6383:e26655a8f98d | 6384:2987d81ea719 |
---|---|
20 import org.dive4elements.river.client.shared.model.DataList; | 20 import org.dive4elements.river.client.shared.model.DataList; |
21 import org.dive4elements.river.client.shared.model.OutputSettings; | 21 import org.dive4elements.river.client.shared.model.OutputSettings; |
22 import org.dive4elements.river.client.shared.model.Property; | 22 import org.dive4elements.river.client.shared.model.Property; |
23 import org.dive4elements.river.client.shared.model.PropertySetting; | 23 import org.dive4elements.river.client.shared.model.PropertySetting; |
24 import org.dive4elements.river.client.shared.model.Settings; | 24 import org.dive4elements.river.client.shared.model.Settings; |
25 import org.dive4elements.river.client.shared.MapUtils; | |
25 | 26 |
26 import com.google.gwt.core.client.GWT; | 27 import com.google.gwt.core.client.GWT; |
27 import com.google.gwt.user.client.Window; | 28 import com.google.gwt.user.client.Window; |
28 import com.google.gwt.user.client.rpc.AsyncCallback; | 29 import com.google.gwt.user.client.rpc.AsyncCallback; |
29 import com.smartgwt.client.types.Alignment; | 30 import com.smartgwt.client.types.Alignment; |
272 localized = MSG.getString(props.getName()); | 273 localized = MSG.getString(props.getName()); |
273 } | 274 } |
274 catch (MissingResourceException mre) { | 275 catch (MissingResourceException mre) { |
275 localized = props.getName(); | 276 localized = props.getName(); |
276 } | 277 } |
277 url.append(toJavaEncodedString(localized)); | 278 url.append(MapUtils.toSaveHTMLJavaString(localized)); |
278 url.append("="); | 279 url.append("="); |
279 url.append(props.getValue()); | 280 url.append(MapUtils.toSaveHTMLJavaString((String)props.getValue())); |
280 } | 281 } |
281 } | 282 } |
282 // O.o | 283 // O.o |
283 String river = findRiver(((MapOutputTab)mapToolbar.getOutputTab() | 284 String river = findRiver(((MapOutputTab)mapToolbar.getOutputTab() |
284 ).getCollectionView().getArtifact()); | 285 ).getCollectionView().getArtifact()); |
285 url.append("&" + toJavaEncodedString(MSG.getString(MAPFISH_RIVER)) + "=" + river); | 286 url.append("&" + MapUtils.toSaveHTMLJavaString(MSG.getString(MAPFISH_RIVER)) + "=" + |
287 MapUtils.toSaveHTMLJavaString(river)); | |
286 } | 288 } |
287 | 289 |
288 // Copy of DatacageWindow's findRiver with added state for map.river | 290 // Copy of DatacageWindow's findRiver with added state for map.river |
289 protected String findRiver(Artifact artifact) { | 291 protected String findRiver(Artifact artifact) { |
290 ArtifactDescription adescr = artifact.getArtifactDescription(); | 292 ArtifactDescription adescr = artifact.getArtifactDescription(); |
307 } | 309 } |
308 | 310 |
309 return ""; | 311 return ""; |
310 } | 312 } |
311 | 313 |
312 public static String toJavaEncodedString(String str) { | |
313 if (str == null) { | |
314 return null; | |
315 } | |
316 StringBuilder sb = new StringBuilder(); | |
317 for (int i = 0, len = str.length(); i < len; i++) { | |
318 int unipoint = Character.codePointAt(str, i); | |
319 if ((unipoint < 32) || (unipoint > 127)) { | |
320 sb.append("\\u"); | |
321 sb.append(Integer.toHexString((unipoint >> 3*4) & 0xf)); | |
322 sb.append(Integer.toHexString((unipoint >> 2*4) & 0xf)); | |
323 sb.append(Integer.toHexString((unipoint >> 1*4) & 0xf)); | |
324 sb.append(Integer.toHexString((unipoint >> 0*4) & 0xf)); | |
325 } else { | |
326 sb.append(str.charAt(i)); | |
327 } | |
328 } | |
329 return sb.toString(); | |
330 } | |
331 | |
332 protected void updateCollection() { | 314 protected void updateCollection() { |
333 final Config config = Config.getInstance(); | 315 final Config config = Config.getInstance(); |
334 final String loc = config.getLocale(); | 316 final String loc = config.getLocale(); |
335 | 317 |
336 GWT.log("MapPrintPanel.updateCollection via RPC now"); | 318 GWT.log("MapPrintPanel.updateCollection via RPC now"); |
337 | 319 |
338 List<Property> properties = new ArrayList<Property>(); | 320 List<Property> properties = new ArrayList<Property>(); |
339 properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString()))); | 321 properties.add(new PropertySetting(MAPFISH_MAPTITLE, pageTitle.getValueAsString())); |
340 // properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString()))); | 322 // properties.add(new PropertySetting(MAPFISH_LAYOUT, pageFormat.getValueAsString())); |
341 properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString()))); | 323 properties.add(new PropertySetting(MAPFISH_SUBTITLE, pageSubtitle.getValueAsString())); |
342 properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString()))); | 324 properties.add(new PropertySetting(MAPFISH_RANGE, pageRange.getValueAsString())); |
343 properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStretch.getValueAsString()))); | 325 properties.add(new PropertySetting(MAPFISH_STRETCH, pageStretch.getValueAsString())); |
344 properties.add(new PropertySetting(MAPFISH_INSTITUTION, toJavaEncodedString(pageInstitution.getValueAsString()))); | 326 properties.add(new PropertySetting(MAPFISH_INSTITUTION, pageInstitution.getValueAsString())); |
345 properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString()))); | 327 properties.add(new PropertySetting(MAPFISH_SOURCE, pageSource.getValueAsString())); |
346 properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString()))); | 328 properties.add(new PropertySetting(MAPFISH_CREATOR, pageCreator.getValueAsString())); |
347 properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString()))); | 329 properties.add(new PropertySetting(MAPFISH_DATEPLACE, pageDatePlace.getValueAsString())); |
348 properties.add(new PropertySetting(MAPFISH_LOGO, toJavaEncodedString(pageLogo.getValueAsString()))); | 330 properties.add(new PropertySetting(MAPFISH_LOGO, pageLogo.getValueAsString())); |
349 settings.setSettings("default", properties); | 331 settings.setSettings("default", properties); |
350 | 332 |
351 collection.addSettings("print-settings", settings); | 333 collection.addSettings("print-settings", settings); |
352 updater.update(collection, loc, new AsyncCallback<Collection>() { | 334 updater.update(collection, loc, new AsyncCallback<Collection>() { |
353 @Override | 335 @Override |