# HG changeset patch # User Ingo Weinzierl # Date 1300357683 0 # Node ID 0d4795b4f284c648cdda1131b703e900893bcc58 # Parent f99c5f8e46724db98f9215c3710d7effb5c6dc36 Implemented the getData() method of the LocationDistancePanel. flys-client/trunk@1492 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f99c5f8e4672 -r 0d4795b4f284 flys-client/ChangeLog --- a/flys-client/ChangeLog Thu Mar 17 09:54:05 2011 +0000 +++ b/flys-client/ChangeLog Thu Mar 17 10:28:03 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-17 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.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/ModuleSelection.java: diff -r f99c5f8e4672 -r 0d4795b4f284 flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java Thu Mar 17 09:54:05 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java Thu Mar 17 10:28:03 2011 +0000 @@ -23,6 +23,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; @@ -135,9 +138,119 @@ * @return the selected/inserted data. */ public Data[] getData() { - // TODO Implement me + return new Data[] { getDataFrom(), getDataTo(), getDataStep() }; + } - return 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("ld_from", "ld_from", value); + return new DefaultData( + "ld_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("ld_to", "ld_to", value); + return new DefaultData( + "ld_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("ld_step","ld_step", value); + return new DefaultData( + "ld_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() { + if (isLocationMode()) { + double[] values = getLocationValues(); + double value = Double.MAX_VALUE; + + for (double v: values) { + value = value < v ? value : v; + } + + return value; + } + else { + return getFrom(); + } + } + + + /** + * 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() { + if (isLocationMode()) { + double[] values = getLocationValues(); + double value = Double.MIN_VALUE; + + for (double v: values) { + value = value > v ? value : v; + } + + return value; + } + else { + return getTo(); + } + } + + + /** + * 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() { + if (isLocationMode()) { + // we have no field to enter the 'step' attribute in the location + // mode + return 0.0; + } + else { + return getStep(); + } + } + + + /** + * Determines the current input mode. + * + * @return true, if 'location' is the current input mode, otherwise false. + */ + public boolean isLocationMode() { + String inputMode = mode.getValueAsString("mode"); + + return inputMode.equals(FIELD_LOCATION) ? true : false; }