Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintSettingsPanel.java @ 4474:bd78d2b0e309
Map print settings can now be configured via settings window.
Configurable for now are page layout (A0 or A4), caption text and
comment text.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Sun, 11 Nov 2012 14:44:12 +0100 |
parents | 6db783627137 |
children | 8af500d62098 |
comparison
equal
deleted
inserted
replaced
4473:6db783627137 | 4474:bd78d2b0e309 |
---|---|
26 import java.util.LinkedHashMap; | 26 import java.util.LinkedHashMap; |
27 import java.util.List; | 27 import java.util.List; |
28 | 28 |
29 public class MapPrintSettingsPanel extends Canvas { | 29 public class MapPrintSettingsPanel extends Canvas { |
30 | 30 |
31 public static final String MAPFISH_COMMENT = "mapfish-comment"; | |
32 public static final String MAPFISH_LAYOUT = "mapfish-layout"; | |
33 public static final String MAPFISH_MAPTITLE = "mapfish-mapTitle"; | |
34 public static final String MAPFISH_PAGESIZE = "mapfish-pageSize"; | |
35 | |
31 /** The interface that provides i18n messages. */ | 36 /** The interface that provides i18n messages. */ |
32 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | 37 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); |
33 | 38 |
34 /** CollectionAttribute Update Service. */ | 39 /** CollectionAttribute Update Service. */ |
35 protected CollectionAttributeServiceAsync updater = | 40 protected CollectionAttributeServiceAsync updater = |
36 GWT.create(CollectionAttributeService.class); | 41 GWT.create(CollectionAttributeService.class); |
37 | 42 |
38 protected Collection collection; | 43 protected Collection collection; |
39 protected Settings settings; | 44 protected Settings settings; |
40 protected TextItem pageTitle = new TextItem(); | 45 protected TextItem pageTitle = new TextItem(); |
46 protected SelectItem pageFormat = createPageFormatSelectItem(); | |
47 protected TextItem pageComment = new TextItem(); | |
48 protected MapToolbar mapToolbar; | |
49 protected MapPrintSettingsWindow parent; | |
41 | 50 |
42 public MapPrintSettingsPanel(Collection collection) { | 51 public MapPrintSettingsPanel(Collection collection, MapToolbar mapToolbar, MapPrintSettingsWindow parent) { |
43 this.collection = collection; | 52 this.collection = collection; |
53 this.mapToolbar = mapToolbar; | |
54 this.parent = parent; | |
44 initLayout(); | 55 initLayout(); |
45 | 56 |
46 this.settings = collection.getSettings("print-settings"); | 57 this.settings = collection.getSettings("print-settings"); |
47 if (settings == null) { | 58 if (settings == null) { |
48 settings = new OutputSettings(); | 59 settings = new OutputSettings(); |
51 else { | 62 else { |
52 List<Property> properties = settings.getSettings("default"); | 63 List<Property> properties = settings.getSettings("default"); |
53 for (Property prop : properties) { | 64 for (Property prop : properties) { |
54 GWT.log("prop=" + prop.getName()); | 65 GWT.log("prop=" + prop.getName()); |
55 PropertySetting props = (PropertySetting)prop; | 66 PropertySetting props = (PropertySetting)prop; |
56 if (props.getName().equals("page-format")) { | 67 if (props.getName().equals(MAPFISH_PAGESIZE)) { |
57 | 68 this.pageFormat.setValue(props.getValue()); |
58 } | 69 } |
59 else if (props.getName().equals("page-title")) { | 70 else if (props.getName().equals(MAPFISH_MAPTITLE)) { |
60 this.pageTitle.setValue(props.getValue()); | 71 this.pageTitle.setValue(props.getValue()); |
61 GWT.log(props.getName() + "=" + props.getValue()); | 72 GWT.log(props.getName() + "=" + props.getValue()); |
73 } | |
74 else if (props.getName().equals(MAPFISH_COMMENT)) { | |
75 this.pageComment.setValue(props.getValue()); | |
62 } | 76 } |
63 } | 77 } |
64 } | 78 } |
65 } | 79 } |
66 | 80 |
67 protected void initLayout() { | 81 protected void initLayout() { |
82 // TODO: i18n | |
68 this.pageTitle.setTitle("Seitentitel:"); | 83 this.pageTitle.setTitle("Seitentitel:"); |
84 this.pageComment.setTitle("Kommentar:"); | |
69 | 85 |
70 DynamicForm df = new DynamicForm(); | 86 DynamicForm df = new DynamicForm(); |
71 df.setFields( | 87 df.setFields( |
72 createPageFormatSelectItem(), | 88 this.pageFormat, |
73 this.pageTitle, | 89 this.pageTitle, |
90 this.pageComment, | |
74 createSaveSettingsButtonItem() | 91 createSaveSettingsButtonItem() |
75 ); | 92 ); |
76 addChild(df); | 93 addChild(df); |
77 } | 94 } |
78 | 95 |
79 protected SelectItem createPageFormatSelectItem() { | 96 protected SelectItem createPageFormatSelectItem() { |
80 LinkedHashMap values = new LinkedHashMap(); | 97 LinkedHashMap values = new LinkedHashMap(); |
81 values.put("din_a4", "DIN A4"); | 98 // TODO: i18n |
82 values.put("din_a0", "DIN A0"); | 99 values.put("A4 portrait", "DIN A4 (Hochformat)"); |
100 values.put("A0 portrait", "DIN A0 (Hochformat)"); | |
83 | 101 |
84 SelectItem selItem = new SelectItem(); | 102 SelectItem selItem = new SelectItem(); |
85 selItem.setTitle("Seitenformat:"); | 103 selItem.setTitle("Seitengröße:"); // TODO: i18n |
86 selItem.setValueMap(values); | 104 selItem.setValueMap(values); |
87 selItem.setDefaultToFirstOption(true); | 105 selItem.setDefaultToFirstOption(true); |
88 | 106 |
89 return selItem; | 107 return selItem; |
90 } | 108 } |
94 btn.addClickHandler(new ClickHandler() { | 112 btn.addClickHandler(new ClickHandler() { |
95 | 113 |
96 @Override | 114 @Override |
97 public void onClick(ClickEvent event) { | 115 public void onClick(ClickEvent event) { |
98 updateCollection(); | 116 updateCollection(); |
117 mapToolbar.updatePrintUrl(); | |
118 parent.destroy(); | |
99 } | 119 } |
100 }); | 120 }); |
101 btn.setTitle("Speichern"); | 121 btn.setTitle("Speichern"); |
102 return btn; | 122 return btn; |
103 } | 123 } |
107 final String loc = config.getLocale(); | 127 final String loc = config.getLocale(); |
108 | 128 |
109 GWT.log("MapPrintSettingsPanel.updateCollection via RPC now"); | 129 GWT.log("MapPrintSettingsPanel.updateCollection via RPC now"); |
110 | 130 |
111 List<Property> properties = new ArrayList<Property>(); | 131 List<Property> properties = new ArrayList<Property>(); |
112 properties.add(new PropertySetting("page-title", this.pageTitle.getValueAsString())); | 132 properties.add(new PropertySetting(MAPFISH_MAPTITLE, this.pageTitle.getValueAsString())); |
133 properties.add(new PropertySetting(MAPFISH_COMMENT, this.pageComment.getValueAsString())); | |
134 properties.add(new PropertySetting(MAPFISH_LAYOUT, this.pageFormat.getValueAsString())); | |
113 settings.setSettings("default", properties); | 135 settings.setSettings("default", properties); |
114 | 136 |
115 collection.addSettings("print-settings", settings); | 137 collection.addSettings("print-settings", settings); |
116 updater.update(collection, loc, new AsyncCallback<Collection>() { | 138 updater.update(collection, loc, new AsyncCallback<Collection>() { |
117 @Override | 139 @Override |