Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTimeRangePanel.java @ 4115:0cc2c3d89a9d
#900 Added complete start and end date to the discharge info service and display on in the client side.
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 12 Oct 2012 09:27:18 +0200 |
parents | 8d27d2d33d70 |
children | 360e22afb98b f6c73ee1b7f1 |
comparison
equal
deleted
inserted
replaced
4114:ae5119da92cd | 4115:0cc2c3d89a9d |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import java.util.List; | |
4 import java.util.ArrayList; | 3 import java.util.ArrayList; |
5 import java.util.Date; | 4 import java.util.Date; |
5 import java.util.List; | |
6 | 6 |
7 import com.google.gwt.core.client.GWT; | 7 import com.google.gwt.core.client.GWT; |
8 import com.google.gwt.i18n.client.DateTimeFormat; | 8 import com.google.gwt.i18n.client.DateTimeFormat; |
9 | 9 import com.smartgwt.client.data.Record; |
10 import com.smartgwt.client.types.ListGridFieldType; | 10 import com.smartgwt.client.types.ListGridFieldType; |
11 | 11 import com.smartgwt.client.widgets.Canvas; |
12 import com.smartgwt.client.data.Record; | 12 import com.smartgwt.client.widgets.Label; |
13 import com.smartgwt.client.widgets.layout.HLayout; | |
14 import com.smartgwt.client.widgets.form.DynamicForm; | 13 import com.smartgwt.client.widgets.form.DynamicForm; |
15 import com.smartgwt.client.widgets.form.fields.DateRangeItem; | 14 import com.smartgwt.client.widgets.form.fields.DateRangeItem; |
16 import com.smartgwt.client.widgets.Label; | 15 import com.smartgwt.client.widgets.grid.CellFormatter; |
17 | |
18 import com.smartgwt.client.widgets.layout.VLayout; | |
19 import com.smartgwt.client.widgets.Canvas; | |
20 import com.smartgwt.client.widgets.grid.ListGrid; | 16 import com.smartgwt.client.widgets.grid.ListGrid; |
21 import com.smartgwt.client.widgets.grid.ListGridField; | 17 import com.smartgwt.client.widgets.grid.ListGridField; |
22 import com.smartgwt.client.widgets.grid.CellFormatter; | |
23 import com.smartgwt.client.widgets.grid.ListGridRecord; | 18 import com.smartgwt.client.widgets.grid.ListGridRecord; |
19 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; | |
24 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; | 20 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; |
25 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; | 21 import com.smartgwt.client.widgets.layout.HLayout; |
26 | 22 import com.smartgwt.client.widgets.layout.VLayout; |
23 | |
24 import de.intevation.flys.client.client.Config; | |
27 import de.intevation.flys.client.client.FLYSConstants; | 25 import de.intevation.flys.client.client.FLYSConstants; |
28 import de.intevation.flys.client.client.Config; | 26 import de.intevation.flys.client.client.ui.range.DischargeInfoDataSource; |
29 | |
30 import de.intevation.flys.client.shared.model.DataList; | |
31 import de.intevation.flys.client.shared.model.DataItem; | |
32 import de.intevation.flys.client.shared.model.ArtifactDescription; | 27 import de.intevation.flys.client.shared.model.ArtifactDescription; |
33 import de.intevation.flys.client.shared.model.Data; | 28 import de.intevation.flys.client.shared.model.Data; |
29 import de.intevation.flys.client.shared.model.DataItem; | |
30 import de.intevation.flys.client.shared.model.DataList; | |
31 import de.intevation.flys.client.shared.model.LongRangeData; | |
34 import de.intevation.flys.client.shared.model.RangeData; | 32 import de.intevation.flys.client.shared.model.RangeData; |
35 import de.intevation.flys.client.shared.model.LongRangeData; | |
36 | |
37 import de.intevation.flys.client.client.ui.range.DischargeInfoDataSource; | |
38 | 33 |
39 /** | 34 /** |
40 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | 35 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
41 */ | 36 */ |
42 public class GaugeTimeRangePanel extends RangePanel { | 37 public class GaugeTimeRangePanel extends RangePanel { |
51 public GaugeTimeRangePanel() { | 46 public GaugeTimeRangePanel() { |
52 GWT.log("Creating YearInputPanel"); | 47 GWT.log("Creating YearInputPanel"); |
53 yearTable = new ListGrid(); | 48 yearTable = new ListGrid(); |
54 yearTable.setAutoFetchData(true); | 49 yearTable.setAutoFetchData(true); |
55 yearTable.setShowHeaderContextMenu(false); | 50 yearTable.setShowHeaderContextMenu(false); |
56 | |
57 } | 51 } |
58 | 52 |
59 public Canvas create(DataList data) { | 53 public Canvas create(DataList data) { |
60 setDataName(data); | 54 setDataName(data); |
61 | 55 |
169 | 163 |
170 | 164 |
171 @Override | 165 @Override |
172 public void setLower(String lower) { | 166 public void setLower(String lower) { |
173 try { | 167 try { |
174 DateTimeFormat dtf = | 168 long value = Long.valueOf(lower); |
175 DateTimeFormat.getFormat("yyyy"); | 169 dateRange.setFromDate(new Date(value)); |
176 Date dy = dtf.parse(lower); | 170 } |
177 dy.setMonth(0); | 171 catch (NumberFormatException nfe) { |
178 dy.setDate(1); | |
179 dateRange.setFromDate(dy); | |
180 } | |
181 catch(IllegalArgumentException iae) { | |
182 GWT.log("could not parse lower date."); | 172 GWT.log("could not parse lower date."); |
183 //TODO: Messagebox with error. | 173 //TODO: Messagebox with error. |
184 } | 174 } |
185 } | 175 } |
186 | 176 |
187 | 177 |
188 @Override | 178 @Override |
189 public void setUpper(String upper) { | 179 public void setUpper(String upper) { |
190 try { | 180 try { |
191 DateTimeFormat dtf = | 181 long value = Long.valueOf(upper); |
192 DateTimeFormat.getFormat("yyyy"); | 182 dateRange.setToDate(new Date(value)); |
193 Date dy = dtf.parse(upper); | 183 } |
194 dy.setMonth(0); | 184 catch (NumberFormatException nfe) { |
195 dy.setDate(1); | |
196 dateRange.setToDate(dy); | |
197 } | |
198 catch(IllegalArgumentException iae) { | |
199 GWT.log("could not parse upper date."); | 185 GWT.log("could not parse upper date."); |
200 //TODO: Messagebox with error. | 186 //TODO: Messagebox with error. |
201 } | 187 } |
188 } | |
189 | |
190 | |
191 protected String buildDateString(String raw) { | |
192 if (raw == null || raw.length() == 0) { | |
193 return ""; | |
194 } | |
195 | |
196 long value = Long.valueOf(raw); | |
197 Date date = new Date(value); | |
198 DateTimeFormat dtf = DateTimeFormat.getMediumDateFormat(); | |
199 | |
200 return dtf.format(date); | |
202 } | 201 } |
203 | 202 |
204 | 203 |
205 protected ListGrid initYearTable() { | 204 protected ListGrid initYearTable() { |
206 String baseUrl = GWT.getHostPageBaseURL(); | 205 String baseUrl = GWT.getHostPageBaseURL(); |
214 | 213 |
215 CellFormatter cf = new CellFormatter() { | 214 CellFormatter cf = new CellFormatter() { |
216 public String format( | 215 public String format( |
217 Object value, | 216 Object value, |
218 ListGridRecord record, | 217 ListGridRecord record, |
219 int rowNum, int colNum) { | 218 int rowNum, int colNum |
220 if (value == null) return null; | 219 ) { |
221 if (value.toString().equals("-1")) { | 220 if (value == null) { |
221 return null; | |
222 } | |
223 else if (value.toString().equals("-1")) { | |
222 return ""; | 224 return ""; |
223 } | 225 } |
226 else if (colNum == 3 || colNum == 4) { | |
227 return buildDateString(value.toString()); | |
228 } | |
229 else { | |
224 return value.toString(); | 230 return value.toString(); |
225 } | 231 } |
232 } | |
226 }; | 233 }; |
227 | 234 |
228 | 235 |
229 ListGridField addstart = new ListGridField ("", ""); | 236 ListGridField addstart = new ListGridField ("", ""); |
230 addstart.setType (ListGridFieldType.ICON); | 237 addstart.setType (ListGridFieldType.ICON); |
264 desc.setWidth("*"); | 271 desc.setWidth("*"); |
265 | 272 |
266 ListGridField start = | 273 ListGridField start = |
267 new ListGridField("start", MESSAGES.start_year()); | 274 new ListGridField("start", MESSAGES.start_year()); |
268 start.setType(ListGridFieldType.INTEGER); | 275 start.setType(ListGridFieldType.INTEGER); |
269 start.setWidth(50); | 276 start.setWidth(100); |
270 start.setCellFormatter(cf); | 277 start.setCellFormatter(cf); |
271 | 278 |
272 ListGridField end = | 279 ListGridField end = |
273 new ListGridField("end", MESSAGES.end_year()); | 280 new ListGridField("end", MESSAGES.end_year()); |
274 end.setType(ListGridFieldType.INTEGER); | 281 end.setType(ListGridFieldType.INTEGER); |
275 end.setWidth(50); | 282 end.setWidth(100); |
276 end.setCellFormatter(cf); | 283 end.setCellFormatter(cf); |
277 | 284 |
278 yearTable.setFields(addstart, addend, desc, start, end); | 285 yearTable.setFields(addstart, addend, desc, start, end); |
279 | 286 |
280 return yearTable; | 287 return yearTable; |