# HG changeset patch # User Ingo Weinzierl # Date 1300359281 0 # Node ID 45ae03d9ca2ba9d446a0050d3e3c55b071248017 # Parent 0d4795b4f284c648cdda1131b703e900893bcc58 Implemented the getData() method of the WQInputPanel. flys-client/trunk@1495 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0d4795b4f284 -r 45ae03d9ca2b flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Mar 17 10:28:03 2011 +0000 +++ b/flys-client/ChangeLog Thu Mar 17 10:54:41 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-17 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java: + Implemented some methods to retrieve the data that have been entered by + the user. The getData() method retrieves data now! + 2011-03-17 Ingo Weinzierl * src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java: diff -r 0d4795b4f284 -r 45ae03d9ca2b flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java Thu Mar 17 10:28:03 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java Thu Mar 17 10:54:41 2011 +0000 @@ -17,6 +17,9 @@ import com.smartgwt.client.widgets.layout.VLayout; import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.DefaultData; +import de.intevation.flys.client.shared.model.DefaultDataItem; import de.intevation.flys.client.client.FLYSMessages; @@ -191,9 +194,166 @@ * @return the selected/inserted data. */ public Data[] getData() { - // TODO Implement me + return new Data[] { + getDataMode(), + getDataFrom(), + getDataTo(), + getDataStep() }; + } - return null; + + /** + * Returns the Data object for the 'mode' attribute. + * + * @return the Data object for the 'mode' attribute. + */ + protected Data getDataMode() { + String wqMode = modes.getValueAsString(FIELD_WQ); + DataItem item = new DefaultDataItem("wq_mode", "wq_mode", wqMode); + return new DefaultData( + "wq_mode", null, null, new DataItem[] { item }, null); + } + + + /** + * Returns the Data object for the 'from' attribute. + * + * @return the Data object for the 'from' attribute. + */ + protected Data getDataFrom() { + String value = Double.valueOf(getFinalFrom()).toString(); + DataItem item = new DefaultDataItem("wq_from", "wq_from", value); + return new DefaultData( + "wq_from", null, null, new DataItem[] { item }, null); + } + + + /** + * Returns the Data object for the 'to' attribute. + * + * @return the Data object for the 'to' attribute. + */ + protected Data getDataTo() { + String value = Double.valueOf(getFinalTo()).toString(); + DataItem item = new DefaultDataItem("wq_to", "wq_to", value); + return new DefaultData( + "wq_to", null, null, new DataItem[] { item }, null); + } + + + /** + * Returns the Data object for the 'step' attribute. + * + * @return the Data object for the 'step' attribute. + */ + protected Data getDataStep() { + String value = Double.valueOf(getFinalStep()).toString(); + DataItem item = new DefaultDataItem("wq_step","wq_step", value); + return new DefaultData( + "wq_step", null, null, new DataItem[] { item }, null); + } + + + /** + * Returns the value of 'from' depending on the selected input mode. + * + * @return the value of 'from' depending on the selected input mode. + */ + protected double getFinalFrom() { + boolean wMode = isWMode(); + boolean rangeMode = isRangeMode(); + + if (rangeMode) { + return wMode ? getFromW() : getFromQ(); + + } + else { + double[] values = wMode ? getSingleW() : getSingleQ(); + double value = Double.MAX_VALUE; + + for (double v: values) { + value = value < v ? value : v; + } + + return value; + } + } + + + /** + * Returns the value of 'to' depending on the selected input mode. + * + * @return the value of 'to' depending on the selected input mode. + */ + protected double getFinalTo() { + boolean wMode = isWMode(); + boolean rangeMode = isRangeMode(); + + if (rangeMode) { + return wMode ? getToW() : getToQ(); + + } + else { + double[] values = wMode ? getSingleW() : getSingleQ(); + double value = Double.MIN_VALUE; + + for (double v: values) { + value = value > v ? value : v; + } + + return value; + } + } + + + /** + * Returns the value of 'step' depending on the selected input mode. + * + * @return the value of 'step' depending on the selected input mode. + */ + protected double getFinalStep() { + boolean wMode = isWMode(); + boolean rangeMode = isRangeMode(); + + if (rangeMode) { + // we have no field to enter the 'step' attribute in the + // range mode + return 0.0; + } + else { + if (wMode) { + return getStepW(); + } + else { + // we have no field to enter the 'step' attribute in the + // range mode + return getStepQ(); + } + } + } + + + /** + * Determines the range/single mode. + * + * @return true if the range mode is activated. + */ + public boolean isRangeMode() { + String rMode = modes.getValueAsString(FIELD_MODE); + + return rMode.equals(FIELD_MODE_RANGE) ? true : false; + } + + + /** + * Determines the w/q mode. + * + * @return true, if the W mode is activated. + */ + public boolean isWMode() { + String wq = modes.getValueAsString(FIELD_WQ); + + return wq.equals(FIELD_WQ_W) ? true : false; }