Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java @ 3362:bea50e45f0d3
FixA: Input fields for chart navigation now use the correct i18n number formats.
flys-client/trunk@5049 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 19 Jul 2012 07:39:50 +0000 |
parents | f362e54b7e80 |
children | 8bedd1fcaeee |
comparison
equal
deleted
inserted
replaced
3361:89df168f289c | 3362:bea50e45f0d3 |
---|---|
8 | 8 |
9 import com.google.gwt.json.client.JSONObject; | 9 import com.google.gwt.json.client.JSONObject; |
10 import com.google.gwt.json.client.JSONNumber; | 10 import com.google.gwt.json.client.JSONNumber; |
11 import com.google.gwt.json.client.JSONString; | 11 import com.google.gwt.json.client.JSONString; |
12 import com.google.gwt.i18n.client.DateTimeFormat; | 12 import com.google.gwt.i18n.client.DateTimeFormat; |
13 import com.google.gwt.i18n.client.NumberFormat; | |
13 | 14 |
14 import com.smartgwt.client.util.SC; | 15 import com.smartgwt.client.util.SC; |
15 | 16 |
16 import com.smartgwt.client.widgets.Canvas; | 17 import com.smartgwt.client.widgets.Canvas; |
17 import com.smartgwt.client.widgets.Button; | 18 import com.smartgwt.client.widgets.Button; |
154 fixInfo = info; | 155 fixInfo = info; |
155 htmlOverview = info.getHTML(); | 156 htmlOverview = info.getHTML(); |
156 FixAnalysisArtifact art = (FixAnalysisArtifact)artifact; | 157 FixAnalysisArtifact art = (FixAnalysisArtifact)artifact; |
157 FixFilter filter = art.getFilter(); | 158 FixFilter filter = art.getFilter(); |
158 filter.setRiver(info.getRiver()); | 159 filter.setRiver(info.getRiver()); |
159 if (filter.getCurrentKm() == -Double.MAX_VALUE) { | 160 if (filter.getCurrentKm() == -Double.MAX_VALUE || |
161 filter.getCurrentKm() == -1d) { | |
160 filter.setCurrentKm(info.getFrom()); | 162 filter.setCurrentKm(info.getFrom()); |
161 filter.setToKm(info.getTo()); | 163 filter.setToKm(info.getTo()); |
162 } | 164 } |
163 if (kmText != null) { | 165 if (kmText != null) { |
164 kmText.setValue(filter.getCurrentKm()); | 166 NumberFormat nf = NumberFormat.getDecimalFormat(); |
167 try { | |
168 double d = Double.valueOf(filter.getCurrentKm()); | |
169 kmText.setValue(nf.format(d)); | |
170 } catch (NumberFormatException e) { | |
171 kmText.setValue(filter.getCurrentKm()); | |
172 } | |
165 } | 173 } |
166 eventPane.setContents(htmlOverview); | 174 eventPane.setContents(htmlOverview); |
167 updateChartTab(fixInfo.getFrom()); | 175 updateChartTab(fixInfo.getFrom()); |
168 events.setPane(eventPane); | 176 events.setPane(eventPane); |
169 success(); | 177 success(); |
184 Button upper = new Button(">>"); | 192 Button upper = new Button(">>"); |
185 upper.setWidth(30); | 193 upper.setWidth(30); |
186 kmText = new TextItem(); | 194 kmText = new TextItem(); |
187 kmText.setWidth(60); | 195 kmText.setWidth(60); |
188 kmText.setShowTitle(false); | 196 kmText.setShowTitle(false); |
189 kmText.setValidators(new IsFloatValidator()); | 197 |
190 | 198 |
191 form.setFields(kmText); | 199 form.setFields(kmText); |
192 form.setWidth(60); | 200 form.setWidth(60); |
193 lower.addClickHandler(new ClickHandler() { | 201 lower.addClickHandler(new ClickHandler() { |
194 public void onClick(ClickEvent ce) { | 202 public void onClick(ClickEvent ce) { |
195 FixFilter filter = updateChartTabLow(); | 203 FixFilter filter = updateChartTabLow(); |
196 FixAnalysisArtifact art = (FixAnalysisArtifact) artifact; | 204 NumberFormat nf = NumberFormat.getDecimalFormat(); |
197 kmText.setValue(filter.getCurrentKm()); | 205 try { |
206 double d = Double.valueOf(filter.getCurrentKm()); | |
207 kmText.setValue(nf.format(d)); | |
208 } catch (NumberFormatException e) { | |
209 kmText.setValue(filter.getCurrentKm()); | |
210 } | |
198 } | 211 } |
199 }); | 212 }); |
200 | 213 |
201 upper.addClickHandler(new ClickHandler() { | 214 upper.addClickHandler(new ClickHandler() { |
202 public void onClick(ClickEvent ce) { | 215 public void onClick(ClickEvent ce) { |
203 FixFilter filter = updateChartTabUp(); | 216 FixFilter filter = updateChartTabUp(); |
204 FixAnalysisArtifact art = (FixAnalysisArtifact) artifact; | 217 NumberFormat nf = NumberFormat.getDecimalFormat(); |
205 kmText.setValue(filter.getCurrentKm()); | 218 try { |
219 double d = Double.valueOf(filter.getCurrentKm()); | |
220 kmText.setValue(nf.format(d)); | |
221 } catch (NumberFormatException e) { | |
222 kmText.setValue(filter.getCurrentKm()); | |
223 } | |
206 } | 224 } |
207 }); | 225 }); |
208 | 226 |
209 kmText.addChangedHandler(new ChangedHandler() { | 227 kmText.addChangedHandler(new ChangedHandler() { |
210 public void onChanged(ChangedEvent ce) { | 228 public void onChanged(ChangedEvent ce) { |
211 //TODO: get current value. | 229 //TODO: get current value. |
212 if(ce.getForm().validate() && ce.getItem().getValue() != null) { | 230 if(ce.getItem().getValue() != null) { |
231 NumberFormat nf = NumberFormat.getDecimalFormat(); | |
213 try { | 232 try { |
214 double d = Double.parseDouble( | 233 double d = nf.parse(ce.getItem().getValue().toString()); |
215 ce.getItem().getValue().toString()); | |
216 updateChartTab(d); | 234 updateChartTab(d); |
217 } | 235 } |
218 catch(NumberFormatException nfe) { | 236 catch(NumberFormatException nfe) { |
219 // Do nothing. | 237 // Do nothing. |
220 } | 238 } |