comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java @ 5717:22e03ca8c39d

Add configurable logo for map print and rename/reorder fields
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 15 Apr 2013 18:23:42 +0200
parents 1103308b19ca
children 891ad06e80e5
comparison
equal deleted inserted replaced
5716:df330602b1a2 5717:22e03ca8c39d
7 import com.smartgwt.client.util.SC; 7 import com.smartgwt.client.util.SC;
8 import com.smartgwt.client.widgets.Canvas; 8 import com.smartgwt.client.widgets.Canvas;
9 import com.smartgwt.client.widgets.form.DynamicForm; 9 import com.smartgwt.client.widgets.form.DynamicForm;
10 import com.smartgwt.client.widgets.form.fields.TextItem; 10 import com.smartgwt.client.widgets.form.fields.TextItem;
11 import com.smartgwt.client.widgets.form.fields.ButtonItem; 11 import com.smartgwt.client.widgets.form.fields.ButtonItem;
12 import com.smartgwt.client.widgets.form.fields.SelectItem;
12 import com.smartgwt.client.widgets.form.fields.events.ClickEvent; 13 import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
13 import com.smartgwt.client.widgets.form.fields.events.ClickHandler; 14 import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
14 import com.smartgwt.client.types.Alignment; 15 import com.smartgwt.client.types.Alignment;
15 16
16 import org.gwtopenmaps.openlayers.client.Bounds; 17 import org.gwtopenmaps.openlayers.client.Bounds;
41 42
42 private static final String MAPFISH_MAPTITLE = "mapfish_mapTitle"; 43 private static final String MAPFISH_MAPTITLE = "mapfish_mapTitle";
43 private static final String MAPFISH_RANGE = "mapfish_data_range"; 44 private static final String MAPFISH_RANGE = "mapfish_data_range";
44 private static final String MAPFISH_SUBTITLE = "mapfish_data_subtitle"; 45 private static final String MAPFISH_SUBTITLE = "mapfish_data_subtitle";
45 private static final String MAPFISH_STRETCH = "mapfish_data_strech"; 46 private static final String MAPFISH_STRETCH = "mapfish_data_strech";
46 private static final String MAPFISH_CREATED = "mapfish_data_created"; 47 private static final String MAPFISH_INSTITUTION = "mapfish_data_institution";
47 private static final String MAPFISH_SOURCE = "mapfish_data_source"; 48 private static final String MAPFISH_SOURCE = "mapfish_data_source";
48 private static final String MAPFISH_CREATOR = "mapfish_data_creator"; 49 private static final String MAPFISH_CREATOR = "mapfish_data_creator";
49 private static final String MAPFISH_DATEPLACE = "mapfish_data_dateplace"; 50 private static final String MAPFISH_DATEPLACE = "mapfish_data_dateplace";
50 private static final String MAPFISH_RIVER = "mapfish_data_river"; 51 private static final String MAPFISH_RIVER = "mapfish_data_river";
52 private static final String MAPFISH_LOGO = "mapfish_logo";
51 53
52 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 54 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
53 55
54 /** CollectionAttribute Update Service. */ 56 /** CollectionAttribute Update Service. */
55 protected CollectionAttributeServiceAsync updater = 57 protected CollectionAttributeServiceAsync updater =
59 protected Collection collection; 61 protected Collection collection;
60 protected Settings settings; 62 protected Settings settings;
61 protected TextItem pageTitle = new TextItem(); 63 protected TextItem pageTitle = new TextItem();
62 protected TextItem pageRange = new TextItem(); 64 protected TextItem pageRange = new TextItem();
63 protected TextItem pageSubtitle = new TextItem(); 65 protected TextItem pageSubtitle = new TextItem();
64 protected TextItem pageStrech = new TextItem(); 66 protected TextItem pageStretch = new TextItem();
65 protected TextItem pageCreated = new TextItem(); 67 protected TextItem pageInstitution = new TextItem();
66 protected TextItem pageSource = new TextItem(); 68 protected TextItem pageSource = new TextItem();
67 protected TextItem pageCreator = new TextItem(); 69 protected TextItem pageCreator = new TextItem();
68 protected TextItem pageDatePlace = new TextItem(); 70 protected TextItem pageDatePlace = new TextItem();
71 protected SelectItem pageLogo = createPageLogoSelectItem();
69 // protected SelectItem pageFormat = createPageFormatSelectItem(); 72 // protected SelectItem pageFormat = createPageFormatSelectItem();
70 protected MapToolbar mapToolbar; 73 protected MapToolbar mapToolbar;
71 protected MapPrintWindow parent; 74 protected MapPrintWindow parent;
72 75
73 public MapPrintPanel(Collection collection, MapToolbar mapToolbar, MapPrintWindow parent) { 76 public MapPrintPanel(Collection collection, MapToolbar mapToolbar, MapPrintWindow parent) {
94 } 97 }
95 else if (props.getName().equals(MAPFISH_SUBTITLE)) { 98 else if (props.getName().equals(MAPFISH_SUBTITLE)) {
96 this.pageSubtitle.setValue(props.getValue()); 99 this.pageSubtitle.setValue(props.getValue());
97 } 100 }
98 else if (props.getName().equals(MAPFISH_STRETCH)) { 101 else if (props.getName().equals(MAPFISH_STRETCH)) {
99 this.pageStrech.setValue(props.getValue()); 102 this.pageStretch.setValue(props.getValue());
100 } 103 }
101 else if (props.getName().equals(MAPFISH_CREATED)) { 104 else if (props.getName().equals(MAPFISH_INSTITUTION)) {
102 this.pageCreated.setValue(props.getValue()); 105 this.pageInstitution.setValue(props.getValue());
103 } 106 }
104 else if (props.getName().equals(MAPFISH_SOURCE)) { 107 else if (props.getName().equals(MAPFISH_SOURCE)) {
105 this.pageSource.setValue(props.getValue()); 108 this.pageSource.setValue(props.getValue());
106 } 109 }
107 else if (props.getName().equals(MAPFISH_CREATOR)) { 110 else if (props.getName().equals(MAPFISH_CREATOR)) {
116 } 119 }
117 } 120 }
118 121
119 protected void initLayout() { 122 protected void initLayout() {
120 // TODO: i18n 123 // TODO: i18n
121 this.pageTitle.setTitle("Titel"); 124 this.pageTitle.setTitle(MSG.mapTitle());
122 this.pageSubtitle.setTitle("Untertitel"); 125 this.pageSubtitle.setTitle(MSG.mapSubtitle());
123 this.pageRange.setTitle("Bereich"); 126 this.pageRange.setTitle(MSG.mapRange());
124 this.pageStrech.setTitle("Strecke"); 127 this.pageStretch.setTitle(MSG.mapStretch());
125 this.pageCreated.setTitle("Aufgestellt"); 128 this.pageInstitution.setTitle(MSG.mapInstitution());
126 this.pageSource.setTitle("Datenquelle"); 129 this.pageSource.setTitle(MSG.mapSource());
127 this.pageCreator.setTitle("Ersteller"); 130 this.pageCreator.setTitle(MSG.mapCreator());
128 this.pageDatePlace.setTitle("Ort, Datum"); 131 this.pageDatePlace.setTitle(MSG.mapDate());
129 132
130 pageTitle.setLength(21); 133 pageTitle.setLength(21);
131 pageSubtitle.setLength(21); 134 pageSubtitle.setLength(21);
132 pageRange.setLength(21); 135 pageRange.setLength(21);
133 pageStrech.setLength(21); 136 pageStretch.setLength(21);
134 pageCreated.setLength(21); 137 pageInstitution.setLength(21);
135 pageSource.setLength(21); 138 pageSource.setLength(21);
136 pageCreator.setLength(21); 139 pageCreator.setLength(21);
137 pageDatePlace.setLength(21); 140 pageDatePlace.setLength(21);
138 ButtonItem printButton = createPrintButtonItem(); 141 ButtonItem printButton = createPrintButtonItem();
139 142
143 df.setFields( 146 df.setFields(
144 // this.pageFormat, 147 // this.pageFormat,
145 this.pageTitle, 148 this.pageTitle,
146 this.pageSubtitle, 149 this.pageSubtitle,
147 this.pageRange, 150 this.pageRange,
148 this.pageStrech, 151 this.pageStretch,
149 this.pageCreated, 152 this.pageInstitution,
150 this.pageSource, 153 this.pageSource,
151 this.pageCreator, 154 this.pageCreator,
152 this.pageDatePlace, 155 this.pageDatePlace,
156 this.pageLogo,
153 printButton); 157 printButton);
154 addChild(df); 158 addChild(df);
159 }
160
161 protected SelectItem createPageLogoSelectItem() {
162 LinkedHashMap values = new LinkedHashMap();
163 // TODO: this should be configurable
164 values.put(MSG.bfgLogo(), "BfG Logo");
165
166 SelectItem selItem = new SelectItem();
167 selItem.setTitle(MSG.mapLogo());
168 selItem.setValueMap(values);
169 selItem.setDefaultToFirstOption(true);
170
171 return selItem;
155 } 172 }
156 173
157 /* 174 /*
158 * Commented out because we only provide a layout for A4 Landscape atm 175 * Commented out because we only provide a layout for A4 Landscape atm
159 176
315 List<Property> properties = new ArrayList<Property>(); 332 List<Property> properties = new ArrayList<Property>();
316 properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString()))); 333 properties.add(new PropertySetting(MAPFISH_MAPTITLE, toJavaEncodedString(pageTitle.getValueAsString())));
317 // properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString()))); 334 // properties.add(new PropertySetting(MAPFISH_LAYOUT, toJavaEncodedString(pageFormat.getValueAsString())));
318 properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString()))); 335 properties.add(new PropertySetting(MAPFISH_SUBTITLE, toJavaEncodedString(pageSubtitle.getValueAsString())));
319 properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString()))); 336 properties.add(new PropertySetting(MAPFISH_RANGE, toJavaEncodedString(pageRange.getValueAsString())));
320 properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStrech.getValueAsString()))); 337 properties.add(new PropertySetting(MAPFISH_STRETCH, toJavaEncodedString(pageStretch.getValueAsString())));
321 properties.add(new PropertySetting(MAPFISH_CREATED, toJavaEncodedString(pageCreated.getValueAsString()))); 338 properties.add(new PropertySetting(MAPFISH_INSTITUTION, toJavaEncodedString(pageInstitution.getValueAsString())));
322 properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString()))); 339 properties.add(new PropertySetting(MAPFISH_SOURCE, toJavaEncodedString(pageSource.getValueAsString())));
323 properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString()))); 340 properties.add(new PropertySetting(MAPFISH_CREATOR, toJavaEncodedString(pageCreator.getValueAsString())));
324 properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString()))); 341 properties.add(new PropertySetting(MAPFISH_DATEPLACE, toJavaEncodedString(pageDatePlace.getValueAsString())));
342 properties.add(new PropertySetting(MAPFISH_LOGO, toJavaEncodedString(pageLogo.getValueAsString())));
325 settings.setSettings("default", properties); 343 settings.setSettings("default", properties);
326 344
327 collection.addSettings("print-settings", settings); 345 collection.addSettings("print-settings", settings);
328 updater.update(collection, loc, new AsyncCallback<Collection>() { 346 updater.update(collection, loc, new AsyncCallback<Collection>() {
329 @Override 347 @Override

http://dive4elements.wald.intevation.org