Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java @ 47:45ae03d9ca2b
Implemented the getData() method of the WQInputPanel.
flys-client/trunk@1495 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Mar 2011 10:54:41 +0000 |
parents | f99c5f8e4672 |
children | 6e191588a295 |
comparison
equal
deleted
inserted
replaced
46:0d4795b4f284 | 47:45ae03d9ca2b |
---|---|
15 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; | 15 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; |
16 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; | 16 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; |
17 import com.smartgwt.client.widgets.layout.VLayout; | 17 import com.smartgwt.client.widgets.layout.VLayout; |
18 | 18 |
19 import de.intevation.flys.client.shared.model.Data; | 19 import de.intevation.flys.client.shared.model.Data; |
20 import de.intevation.flys.client.shared.model.DataItem; | |
21 import de.intevation.flys.client.shared.model.DefaultData; | |
22 import de.intevation.flys.client.shared.model.DefaultDataItem; | |
20 import de.intevation.flys.client.client.FLYSMessages; | 23 import de.intevation.flys.client.client.FLYSMessages; |
21 | 24 |
22 | 25 |
23 /** | 26 /** |
24 * This UIProvider creates a widget to enter W or Q data. | 27 * This UIProvider creates a widget to enter W or Q data. |
189 * This method returns the selected data. | 192 * This method returns the selected data. |
190 * | 193 * |
191 * @return the selected/inserted data. | 194 * @return the selected/inserted data. |
192 */ | 195 */ |
193 public Data[] getData() { | 196 public Data[] getData() { |
194 // TODO Implement me | 197 return new Data[] { |
195 | 198 getDataMode(), |
196 return null; | 199 getDataFrom(), |
200 getDataTo(), | |
201 getDataStep() }; | |
202 } | |
203 | |
204 | |
205 /** | |
206 * Returns the Data object for the 'mode' attribute. | |
207 * | |
208 * @return the Data object for the 'mode' attribute. | |
209 */ | |
210 protected Data getDataMode() { | |
211 String wqMode = modes.getValueAsString(FIELD_WQ); | |
212 DataItem item = new DefaultDataItem("wq_mode", "wq_mode", wqMode); | |
213 return new DefaultData( | |
214 "wq_mode", null, null, new DataItem[] { item }, null); | |
215 } | |
216 | |
217 | |
218 /** | |
219 * Returns the Data object for the 'from' attribute. | |
220 * | |
221 * @return the Data object for the 'from' attribute. | |
222 */ | |
223 protected Data getDataFrom() { | |
224 String value = Double.valueOf(getFinalFrom()).toString(); | |
225 DataItem item = new DefaultDataItem("wq_from", "wq_from", value); | |
226 return new DefaultData( | |
227 "wq_from", null, null, new DataItem[] { item }, null); | |
228 } | |
229 | |
230 | |
231 /** | |
232 * Returns the Data object for the 'to' attribute. | |
233 * | |
234 * @return the Data object for the 'to' attribute. | |
235 */ | |
236 protected Data getDataTo() { | |
237 String value = Double.valueOf(getFinalTo()).toString(); | |
238 DataItem item = new DefaultDataItem("wq_to", "wq_to", value); | |
239 return new DefaultData( | |
240 "wq_to", null, null, new DataItem[] { item }, null); | |
241 } | |
242 | |
243 | |
244 /** | |
245 * Returns the Data object for the 'step' attribute. | |
246 * | |
247 * @return the Data object for the 'step' attribute. | |
248 */ | |
249 protected Data getDataStep() { | |
250 String value = Double.valueOf(getFinalStep()).toString(); | |
251 DataItem item = new DefaultDataItem("wq_step","wq_step", value); | |
252 return new DefaultData( | |
253 "wq_step", null, null, new DataItem[] { item }, null); | |
254 } | |
255 | |
256 | |
257 /** | |
258 * Returns the value of 'from' depending on the selected input mode. | |
259 * | |
260 * @return the value of 'from' depending on the selected input mode. | |
261 */ | |
262 protected double getFinalFrom() { | |
263 boolean wMode = isWMode(); | |
264 boolean rangeMode = isRangeMode(); | |
265 | |
266 if (rangeMode) { | |
267 return wMode ? getFromW() : getFromQ(); | |
268 | |
269 } | |
270 else { | |
271 double[] values = wMode ? getSingleW() : getSingleQ(); | |
272 double value = Double.MAX_VALUE; | |
273 | |
274 for (double v: values) { | |
275 value = value < v ? value : v; | |
276 } | |
277 | |
278 return value; | |
279 } | |
280 } | |
281 | |
282 | |
283 /** | |
284 * Returns the value of 'to' depending on the selected input mode. | |
285 * | |
286 * @return the value of 'to' depending on the selected input mode. | |
287 */ | |
288 protected double getFinalTo() { | |
289 boolean wMode = isWMode(); | |
290 boolean rangeMode = isRangeMode(); | |
291 | |
292 if (rangeMode) { | |
293 return wMode ? getToW() : getToQ(); | |
294 | |
295 } | |
296 else { | |
297 double[] values = wMode ? getSingleW() : getSingleQ(); | |
298 double value = Double.MIN_VALUE; | |
299 | |
300 for (double v: values) { | |
301 value = value > v ? value : v; | |
302 } | |
303 | |
304 return value; | |
305 } | |
306 } | |
307 | |
308 | |
309 /** | |
310 * Returns the value of 'step' depending on the selected input mode. | |
311 * | |
312 * @return the value of 'step' depending on the selected input mode. | |
313 */ | |
314 protected double getFinalStep() { | |
315 boolean wMode = isWMode(); | |
316 boolean rangeMode = isRangeMode(); | |
317 | |
318 if (rangeMode) { | |
319 // we have no field to enter the 'step' attribute in the | |
320 // range mode | |
321 return 0.0; | |
322 } | |
323 else { | |
324 if (wMode) { | |
325 return getStepW(); | |
326 } | |
327 else { | |
328 // we have no field to enter the 'step' attribute in the | |
329 // range mode | |
330 return getStepQ(); | |
331 } | |
332 } | |
333 } | |
334 | |
335 | |
336 /** | |
337 * Determines the range/single mode. | |
338 * | |
339 * @return true if the range mode is activated. | |
340 */ | |
341 public boolean isRangeMode() { | |
342 String rMode = modes.getValueAsString(FIELD_MODE); | |
343 | |
344 return rMode.equals(FIELD_MODE_RANGE) ? true : false; | |
345 } | |
346 | |
347 | |
348 /** | |
349 * Determines the w/q mode. | |
350 * | |
351 * @return true, if the W mode is activated. | |
352 */ | |
353 public boolean isWMode() { | |
354 String wq = modes.getValueAsString(FIELD_WQ); | |
355 | |
356 return wq.equals(FIELD_WQ_W) ? true : false; | |
197 } | 357 } |
198 | 358 |
199 | 359 |
200 /** | 360 /** |
201 * This method changes the lower panel with the input fields depending on | 361 * This method changes the lower panel with the input fields depending on |