Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java @ 4131:360e22afb98b
Cosmetics, warnings and minor TODOs.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 15 Oct 2012 00:04:35 +0200 |
parents | 0cc2c3d89a9d |
children | c722c08cf502 |
comparison
equal
deleted
inserted
replaced
4130:df8ac7ff6b1a | 4131:360e22afb98b |
---|---|
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; |
48 yearTable = new ListGrid(); | 52 yearTable = new ListGrid(); |
49 yearTable.setAutoFetchData(true); | 53 yearTable.setAutoFetchData(true); |
50 yearTable.setShowHeaderContextMenu(false); | 54 yearTable.setShowHeaderContextMenu(false); |
51 } | 55 } |
52 | 56 |
57 @Override | |
53 public Canvas create(DataList data) { | 58 public Canvas create(DataList data) { |
54 setDataName(data); | 59 setDataName(data); |
55 | 60 |
56 VLayout root = new VLayout(); | 61 VLayout root = new VLayout(); |
57 | 62 |
87 | 92 |
88 @Override | 93 @Override |
89 public Canvas createOld(DataList dataList) { | 94 public Canvas createOld(DataList dataList) { |
90 GWT.log("create old date."); | 95 GWT.log("create old date."); |
91 Data data = dataList.get(0); | 96 Data data = dataList.get(0); |
92 DataItem[] items = data.getItems(); | 97 |
93 GWT.log(data.getClass().toString()); | |
94 HLayout layout = new HLayout(); | 98 HLayout layout = new HLayout(); |
95 | 99 |
96 Label label = new Label(dataList.getLabel()); | 100 Label label = new Label(dataList.getLabel()); |
97 label.setWidth(200); | 101 label.setWidth(200); |
98 label.setHeight(20); | 102 label.setHeight(20); |
99 | 103 |
100 Date dl = new Date((Long)((LongRangeData)data).getLower()); | 104 Date dl = new Date((Long)((LongRangeData)data).getLower()); |
101 Date du = new Date((Long)((LongRangeData)data).getUpper()); | 105 Date du = new Date((Long)((LongRangeData)data).getUpper()); |
106 | |
107 @SuppressWarnings("deprecation") | |
102 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); | 108 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); |
103 Label value = new Label(dtf.format(dl) + " - " + dtf.format(du)); | 109 Label value = new Label(dtf.format(dl) + " - " + dtf.format(du)); |
104 value.setHeight(20); | 110 value.setHeight(20); |
105 | 111 |
106 layout.addMember(label); | 112 layout.addMember(label); |
168 long value = Long.valueOf(lower); | 174 long value = Long.valueOf(lower); |
169 dateRange.setFromDate(new Date(value)); | 175 dateRange.setFromDate(new Date(value)); |
170 } | 176 } |
171 catch (NumberFormatException nfe) { | 177 catch (NumberFormatException nfe) { |
172 GWT.log("could not parse lower date."); | 178 GWT.log("could not parse lower date."); |
173 //TODO: Messagebox with error. | 179 SC.warn(MESSAGES.warning_cannot_parse_date()); |
174 } | 180 } |
175 } | 181 } |
176 | 182 |
177 | 183 |
178 @Override | 184 @Override |
181 long value = Long.valueOf(upper); | 187 long value = Long.valueOf(upper); |
182 dateRange.setToDate(new Date(value)); | 188 dateRange.setToDate(new Date(value)); |
183 } | 189 } |
184 catch (NumberFormatException nfe) { | 190 catch (NumberFormatException nfe) { |
185 GWT.log("could not parse upper date."); | 191 GWT.log("could not parse upper date."); |
186 //TODO: Messagebox with error. | 192 SC.warn(MESSAGES.warning_cannot_parse_date()); |
187 } | 193 } |
188 } | 194 } |
189 | 195 |
190 | 196 |
191 protected String buildDateString(String raw) { | 197 protected String buildDateString(String raw) { |
193 return ""; | 199 return ""; |
194 } | 200 } |
195 | 201 |
196 long value = Long.valueOf(raw); | 202 long value = Long.valueOf(raw); |
197 Date date = new Date(value); | 203 Date date = new Date(value); |
204 @SuppressWarnings("deprecation") | |
198 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); | 205 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); |
199 | 206 |
200 return dtf.format(date); | 207 return dtf.format(date); |
201 } | 208 } |
202 | 209 |
210 yearTable.setShowRecordComponentsByCell(true); | 217 yearTable.setShowRecordComponentsByCell(true); |
211 yearTable.setEmptyMessage(MESSAGES.empty_filter()); | 218 yearTable.setEmptyMessage(MESSAGES.empty_filter()); |
212 yearTable.setCanReorderFields(false); | 219 yearTable.setCanReorderFields(false); |
213 | 220 |
214 CellFormatter cf = new CellFormatter() { | 221 CellFormatter cf = new CellFormatter() { |
222 @Override | |
215 public String format( | 223 public String format( |
216 Object value, | 224 Object value, |
217 ListGridRecord record, | 225 ListGridRecord record, |
218 int rowNum, int colNum | 226 int rowNum, int colNum |
219 ) { | 227 ) { |
236 ListGridField addstart = new ListGridField ("", ""); | 244 ListGridField addstart = new ListGridField ("", ""); |
237 addstart.setType (ListGridFieldType.ICON); | 245 addstart.setType (ListGridFieldType.ICON); |
238 addstart.setWidth (20); | 246 addstart.setWidth (20); |
239 addstart.setCellIcon(baseUrl + MESSAGES.markerGreen()); | 247 addstart.setCellIcon(baseUrl + MESSAGES.markerGreen()); |
240 addstart.addRecordClickHandler(new RecordClickHandler() { | 248 addstart.addRecordClickHandler(new RecordClickHandler() { |
249 @Override | |
241 public void onRecordClick(RecordClickEvent e) { | 250 public void onRecordClick(RecordClickEvent e) { |
242 Record r = e.getRecord(); | 251 Record r = e.getRecord(); |
243 if (r.getAttribute("start").equals("-1")) { | 252 if (r.getAttribute("start").equals("-1")) { |
244 return; | 253 return; |
245 } | 254 } |
252 ListGridField addend = new ListGridField ("", ""); | 261 ListGridField addend = new ListGridField ("", ""); |
253 addend.setType (ListGridFieldType.ICON); | 262 addend.setType (ListGridFieldType.ICON); |
254 addend.setWidth (20); | 263 addend.setWidth (20); |
255 addend.setCellIcon(baseUrl + MESSAGES.markerRed()); | 264 addend.setCellIcon(baseUrl + MESSAGES.markerRed()); |
256 addend.addRecordClickHandler(new RecordClickHandler() { | 265 addend.addRecordClickHandler(new RecordClickHandler() { |
266 @Override | |
257 public void onRecordClick(RecordClickEvent e) { | 267 public void onRecordClick(RecordClickEvent e) { |
258 Record r = e.getRecord(); | 268 Record r = e.getRecord(); |
259 if (r.getAttribute("end").equals("-1")) { | 269 if (r.getAttribute("end").equals("-1")) { |
260 return; | 270 return; |
261 } | 271 } |