Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java @ 4133:c722c08cf502
Merged heads.
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 15 Oct 2012 09:31:50 +0200 |
parents | f6c73ee1b7f1 360e22afb98b |
children | 03de5c424f95 |
comparison
equal
deleted
inserted
replaced
4132:f6c73ee1b7f1 | 4133:c722c08cf502 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.Date; | |
5 import java.util.List; | |
6 | 2 |
7 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
8 import com.google.gwt.i18n.client.DateTimeFormat; | 4 import com.google.gwt.i18n.client.DateTimeFormat; |
5 | |
9 import com.smartgwt.client.data.Record; | 6 import com.smartgwt.client.data.Record; |
10 import com.smartgwt.client.types.ListGridFieldType; | 7 import com.smartgwt.client.types.ListGridFieldType; |
8 import com.smartgwt.client.util.SC; | |
11 import com.smartgwt.client.widgets.Canvas; | 9 import com.smartgwt.client.widgets.Canvas; |
12 import com.smartgwt.client.widgets.Label; | 10 import com.smartgwt.client.widgets.Label; |
13 import com.smartgwt.client.widgets.form.DynamicForm; | 11 import com.smartgwt.client.widgets.form.DynamicForm; |
14 import com.smartgwt.client.widgets.form.fields.DateRangeItem; | 12 import com.smartgwt.client.widgets.form.fields.DateRangeItem; |
15 import com.smartgwt.client.widgets.grid.CellFormatter; | 13 import com.smartgwt.client.widgets.grid.CellFormatter; |
29 import de.intevation.flys.client.shared.model.DataItem; | 27 import de.intevation.flys.client.shared.model.DataItem; |
30 import de.intevation.flys.client.shared.model.DataList; | 28 import de.intevation.flys.client.shared.model.DataList; |
31 import de.intevation.flys.client.shared.model.LongRangeData; | 29 import de.intevation.flys.client.shared.model.LongRangeData; |
32 import de.intevation.flys.client.shared.model.RangeData; | 30 import de.intevation.flys.client.shared.model.RangeData; |
33 | 31 |
32 import java.util.ArrayList; | |
33 import java.util.Date; | |
34 import java.util.List; | |
35 | |
34 /** | 36 /** |
35 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 37 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
36 */ | 38 */ |
37 public class GaugeTimeRangePanel extends RangePanel { | 39 public class GaugeTimeRangePanel extends RangePanel { |
40 | |
41 private static final long serialVersionUID = -157571967010594739L; | |
38 | 42 |
39 /** The message class that provides i18n strings. */ | 43 /** The message class that provides i18n strings. */ |
40 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); | 44 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); |
41 | 45 |
42 protected ListGrid yearTable; | 46 protected ListGrid yearTable; |
70 | 74 |
71 protected void setMaxLower(Long maxLower) { | 75 protected void setMaxLower(Long maxLower) { |
72 this.maxLower = maxLower; | 76 this.maxLower = maxLower; |
73 } | 77 } |
74 | 78 |
75 | |
76 public Canvas create(DataList data) { | 79 public Canvas create(DataList data) { |
77 setDataName(data); | 80 setDataName(data); |
78 | 81 |
79 VLayout root = new VLayout(); | 82 VLayout root = new VLayout(); |
80 | 83 |
124 label.setWidth(200); | 127 label.setWidth(200); |
125 label.setHeight(20); | 128 label.setHeight(20); |
126 | 129 |
127 Date dl = new Date((Long)((LongRangeData)data).getLower()); | 130 Date dl = new Date((Long)((LongRangeData)data).getLower()); |
128 Date du = new Date((Long)((LongRangeData)data).getUpper()); | 131 Date du = new Date((Long)((LongRangeData)data).getUpper()); |
132 | |
133 @SuppressWarnings("deprecation") | |
129 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); | 134 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); |
130 Label value = new Label(dtf.format(dl) + " - " + dtf.format(du)); | 135 Label value = new Label(dtf.format(dl) + " - " + dtf.format(du)); |
131 value.setHeight(20); | 136 value.setHeight(20); |
132 | 137 |
133 layout.addMember(label); | 138 layout.addMember(label); |
194 long value = Long.valueOf(lower); | 199 long value = Long.valueOf(lower); |
195 dateRange.setFromDate(new Date(value)); | 200 dateRange.setFromDate(new Date(value)); |
196 } | 201 } |
197 catch (NumberFormatException nfe) { | 202 catch (NumberFormatException nfe) { |
198 GWT.log("could not parse lower date."); | 203 GWT.log("could not parse lower date."); |
199 //TODO: Messagebox with error. | 204 SC.warn(MESSAGES.warning_cannot_parse_date()); |
200 } | 205 } |
201 } | 206 } |
202 | 207 |
203 | 208 |
204 @Override | 209 @Override |
207 long value = Long.valueOf(upper); | 212 long value = Long.valueOf(upper); |
208 dateRange.setToDate(new Date(value)); | 213 dateRange.setToDate(new Date(value)); |
209 } | 214 } |
210 catch (NumberFormatException nfe) { | 215 catch (NumberFormatException nfe) { |
211 GWT.log("could not parse upper date."); | 216 GWT.log("could not parse upper date."); |
212 //TODO: Messagebox with error. | 217 SC.warn(MESSAGES.warning_cannot_parse_date()); |
213 } | 218 } |
214 } | 219 } |
215 | 220 |
216 | 221 |
217 protected String buildDateString(String raw) { | 222 protected String buildDateString(String raw) { |
219 return ""; | 224 return ""; |
220 } | 225 } |
221 | 226 |
222 long value = Long.valueOf(raw); | 227 long value = Long.valueOf(raw); |
223 Date date = new Date(value); | 228 Date date = new Date(value); |
229 @SuppressWarnings("deprecation") | |
224 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); | 230 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); |
225 | 231 |
226 return dtf.format(date); | 232 return dtf.format(date); |
227 } | 233 } |
228 | 234 |
236 yearTable.setShowRecordComponentsByCell(true); | 242 yearTable.setShowRecordComponentsByCell(true); |
237 yearTable.setEmptyMessage(MESSAGES.empty_filter()); | 243 yearTable.setEmptyMessage(MESSAGES.empty_filter()); |
238 yearTable.setCanReorderFields(false); | 244 yearTable.setCanReorderFields(false); |
239 | 245 |
240 CellFormatter cf = new CellFormatter() { | 246 CellFormatter cf = new CellFormatter() { |
247 @Override | |
241 public String format( | 248 public String format( |
242 Object value, | 249 Object value, |
243 ListGridRecord record, | 250 ListGridRecord record, |
244 int rowNum, int colNum | 251 int rowNum, int colNum |
245 ) { | 252 ) { |
262 ListGridField addstart = new ListGridField ("", ""); | 269 ListGridField addstart = new ListGridField ("", ""); |
263 addstart.setType (ListGridFieldType.ICON); | 270 addstart.setType (ListGridFieldType.ICON); |
264 addstart.setWidth (20); | 271 addstart.setWidth (20); |
265 addstart.setCellIcon(baseUrl + MESSAGES.markerGreen()); | 272 addstart.setCellIcon(baseUrl + MESSAGES.markerGreen()); |
266 addstart.addRecordClickHandler(new RecordClickHandler() { | 273 addstart.addRecordClickHandler(new RecordClickHandler() { |
274 @Override | |
267 public void onRecordClick(RecordClickEvent e) { | 275 public void onRecordClick(RecordClickEvent e) { |
268 Record r = e.getRecord(); | 276 Record r = e.getRecord(); |
269 if (r.getAttribute("start").equals("-1")) { | 277 if (r.getAttribute("start").equals("-1")) { |
270 return; | 278 return; |
271 } | 279 } |
278 ListGridField addend = new ListGridField ("", ""); | 286 ListGridField addend = new ListGridField ("", ""); |
279 addend.setType (ListGridFieldType.ICON); | 287 addend.setType (ListGridFieldType.ICON); |
280 addend.setWidth (20); | 288 addend.setWidth (20); |
281 addend.setCellIcon(baseUrl + MESSAGES.markerRed()); | 289 addend.setCellIcon(baseUrl + MESSAGES.markerRed()); |
282 addend.addRecordClickHandler(new RecordClickHandler() { | 290 addend.addRecordClickHandler(new RecordClickHandler() { |
291 @Override | |
283 public void onRecordClick(RecordClickEvent e) { | 292 public void onRecordClick(RecordClickEvent e) { |
284 Record r = e.getRecord(); | 293 Record r = e.getRecord(); |
285 if (r.getAttribute("end").equals("-1")) { | 294 if (r.getAttribute("end").equals("-1")) { |
286 return; | 295 return; |
287 } | 296 } |