Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java @ 46:0d4795b4f284
Implemented the getData() method of the LocationDistancePanel.
flys-client/trunk@1492 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Mar 2011 10:28:03 +0000 |
parents | f99c5f8e4672 |
children | d573ae975330 |
comparison
equal
deleted
inserted
replaced
45:f99c5f8e4672 | 46:0d4795b4f284 |
---|---|
21 import com.smartgwt.client.widgets.form.fields.TextItem; | 21 import com.smartgwt.client.widgets.form.fields.TextItem; |
22 import com.smartgwt.client.widgets.layout.HLayout; | 22 import com.smartgwt.client.widgets.layout.HLayout; |
23 import com.smartgwt.client.widgets.layout.VLayout; | 23 import com.smartgwt.client.widgets.layout.VLayout; |
24 | 24 |
25 import de.intevation.flys.client.shared.model.Data; | 25 import de.intevation.flys.client.shared.model.Data; |
26 import de.intevation.flys.client.shared.model.DataItem; | |
27 import de.intevation.flys.client.shared.model.DefaultData; | |
28 import de.intevation.flys.client.shared.model.DefaultDataItem; | |
26 import de.intevation.flys.client.client.FLYSMessages; | 29 import de.intevation.flys.client.client.FLYSMessages; |
27 | 30 |
28 | 31 |
29 /** | 32 /** |
30 * This UIProvider creates a widget to enter locations or a distance. | 33 * This UIProvider creates a widget to enter locations or a distance. |
133 * This method returns the selected data. | 136 * This method returns the selected data. |
134 * | 137 * |
135 * @return the selected/inserted data. | 138 * @return the selected/inserted data. |
136 */ | 139 */ |
137 public Data[] getData() { | 140 public Data[] getData() { |
138 // TODO Implement me | 141 return new Data[] { getDataFrom(), getDataTo(), getDataStep() }; |
139 | 142 } |
140 return null; | 143 |
144 | |
145 /** | |
146 * Returns the Data object for the 'from' attribute. | |
147 * | |
148 * @return the Data object for the 'from' attribute. | |
149 */ | |
150 protected Data getDataFrom() { | |
151 String value = Double.valueOf(getFinalFrom()).toString(); | |
152 DataItem item = new DefaultDataItem("ld_from", "ld_from", value); | |
153 return new DefaultData( | |
154 "ld_from", null, null, new DataItem[] { item }, null); | |
155 } | |
156 | |
157 | |
158 /** | |
159 * Returns the Data object for the 'to' attribute. | |
160 * | |
161 * @return the Data object for the 'to' attribute. | |
162 */ | |
163 protected Data getDataTo() { | |
164 String value = Double.valueOf(getFinalTo()).toString(); | |
165 DataItem item = new DefaultDataItem("ld_to", "ld_to", value); | |
166 return new DefaultData( | |
167 "ld_to", null, null, new DataItem[] { item }, null); | |
168 } | |
169 | |
170 | |
171 /** | |
172 * Returns the Data object for the 'step' attribute. | |
173 * | |
174 * @return the Data object for the 'step' attribute. | |
175 */ | |
176 protected Data getDataStep() { | |
177 String value = Double.valueOf(getFinalStep()).toString(); | |
178 DataItem item = new DefaultDataItem("ld_step","ld_step", value); | |
179 return new DefaultData( | |
180 "ld_step", null, null, new DataItem[] { item }, null); | |
181 } | |
182 | |
183 | |
184 /** | |
185 * Returns the value of 'from' depending on the selected input mode. | |
186 * | |
187 * @return the value of 'from' depending on the selected input mode. | |
188 */ | |
189 protected double getFinalFrom() { | |
190 if (isLocationMode()) { | |
191 double[] values = getLocationValues(); | |
192 double value = Double.MAX_VALUE; | |
193 | |
194 for (double v: values) { | |
195 value = value < v ? value : v; | |
196 } | |
197 | |
198 return value; | |
199 } | |
200 else { | |
201 return getFrom(); | |
202 } | |
203 } | |
204 | |
205 | |
206 /** | |
207 * Returns the value of 'to' depending on the selected input mode. | |
208 * | |
209 * @return the value of 'to' depending on the selected input mode. | |
210 */ | |
211 protected double getFinalTo() { | |
212 if (isLocationMode()) { | |
213 double[] values = getLocationValues(); | |
214 double value = Double.MIN_VALUE; | |
215 | |
216 for (double v: values) { | |
217 value = value > v ? value : v; | |
218 } | |
219 | |
220 return value; | |
221 } | |
222 else { | |
223 return getTo(); | |
224 } | |
225 } | |
226 | |
227 | |
228 /** | |
229 * Returns the value of 'step' depending on the selected input mode. | |
230 * | |
231 * @return the value of 'step' depending on the selected input mode. | |
232 */ | |
233 protected double getFinalStep() { | |
234 if (isLocationMode()) { | |
235 // we have no field to enter the 'step' attribute in the location | |
236 // mode | |
237 return 0.0; | |
238 } | |
239 else { | |
240 return getStep(); | |
241 } | |
242 } | |
243 | |
244 | |
245 /** | |
246 * Determines the current input mode. | |
247 * | |
248 * @return true, if 'location' is the current input mode, otherwise false. | |
249 */ | |
250 public boolean isLocationMode() { | |
251 String inputMode = mode.getValueAsString("mode"); | |
252 | |
253 return inputMode.equals(FIELD_LOCATION) ? true : false; | |
141 } | 254 } |
142 | 255 |
143 | 256 |
144 /** | 257 /** |
145 * This method switches the input mode between location and distance input. | 258 * This method switches the input mode between location and distance input. |