# HG changeset patch # User Felix Wolfsteller # Date 1328015091 0 # Node ID 60f8edc7a6f0708554d48e28af6c855088e9f74c # Parent 1227878665b52743a6f59a96259443b07068192e Slightly improved Spinner- behaviour in CrossSectionControl, but regress in other case. flys-client/trunk@3837 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1227878665b5 -r 60f8edc7a6f0 flys-client/ChangeLog --- a/flys-client/ChangeLog Tue Jan 31 10:34:54 2012 +0000 +++ b/flys-client/ChangeLog Tue Jan 31 13:04:51 2012 +0000 @@ -1,3 +1,9 @@ +2012-01-31 Felix Wolfsteller + + * src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java: + Refactored und introduces a temproray regression: Update only when + losing the focus (not on click or enter- press). + 2012-01-31 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/DataFactory.java: New. diff -r 1227878665b5 -r 60f8edc7a6f0 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Tue Jan 31 10:34:54 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Tue Jan 31 13:04:51 2012 +0000 @@ -25,10 +25,13 @@ import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.BlurEvent; +import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; +import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuItem; @@ -54,7 +57,6 @@ import de.intevation.flys.client.client.ui.CollectionView; - /** * ThemePanel much like ChartThemePanel, but shows an "Actions" column, * needed for interaction in the CrossSection Charts and a selector to @@ -348,22 +350,83 @@ }); } + public void spinnerValueEntered(final SpinnerItem item, + final double enteredKm, final FacetRecord facetRecord + ) { + Config config = Config.getInstance(); + final String locale = config.getLocale(); + + Map map = new HashMap(); + int _dbid = -1; + try { + _dbid = Integer.valueOf(facetRecord.getTheme() + .getCollectionItem() + .getData().get("cross_section.dbid")); + } + catch (NumberFormatException nfe) { + GWT.log("Could not extract cross-section db id from data."); + } + final int dbid = _dbid; + + map.put(dbid, enteredKm); + + disable(); + + kmService.getCrossSectionKMs(locale, map, 2, + new AsyncCallback>() { + @Override + public void onFailure(Throwable caught) { + GWT.log("Could not get single km for " + + dbid + ": "+ caught.getMessage()); + SC.warn(MSG.getString(caught.getMessage())); + updateCollection(); + updateGrid(); + enable(); + } + @Override + public void onSuccess(Map obj) { + Double[] kms = obj.get(dbid); + double closest = + CrossSectionChartThemePanel.closest(kms, + enteredKm); + GWT.log("Got single km for " + dbid + ", it is " + + closest); + item.setValue(closest); + if (synchronNavigation) { + // Feed many ... + // Find all activated cross section themes + ThemeList themes = getThemeList(); + int nThemes = themes.getThemeCount(); + List artifacts = new ArrayList(); + for (int i = 0; i < nThemes; i++) { + final Theme theme = themes.getThemeAt(i+1); + if (theme.getFacet().equals("cross_section") && + theme.getActive() == 1) { + artifacts.add(artifactReference(theme.getArtifact())); + } + } + sendFeed(artifacts, + closest); + } + else { + sendFeed(facetRecord.getTheme().getArtifact(), + closest); + } + } + }); + } + /** * Create the handler for ChangeEvents on the Spinner in the * facets that control km of cross section. * - * @param feedService The FeedService to send (changed) data to. * @param facetRecord The FacetRecord (~row in table) where this * handler is added to (to a child, to be exact). */ public final ChangedHandler createSpinnerHandler( - final FeedServiceAsync feedService, final FacetRecord facetRecord) { - Config config = Config.getInstance(); - final String locale = config.getLocale(); - ChangedHandler handler = new ChangedHandler() { @Override @@ -371,70 +434,14 @@ if (ce.getValue() == null) { return; } + String value = ce.getValue().toString(); // Now, query the value with the kmService. - Map map = new HashMap(); final double selected_km = - Double.parseDouble(ce.getValue().toString()); - - int _dbid = -1; - try { - _dbid = Integer.valueOf(facetRecord.getTheme() - .getCollectionItem() - .getData().get("cross_section.dbid")); - } - catch (NumberFormatException nfe) { - GWT.log("Could not extract cross-section db id from data."); - } - final int dbid = _dbid; - - map.put(dbid, Double.parseDouble(ce.getValue().toString())); + Double.parseDouble(value); + final SpinnerItem item = (SpinnerItem) ce.getItem(); - disable(); - - kmService.getCrossSectionKMs(locale, map, 2, - new AsyncCallback>() { - @Override - public void onFailure(Throwable caught) { - GWT.log("Could not get single km for " - + dbid + ": "+ caught.getMessage()); - SC.warn(MSG.getString(caught.getMessage())); - updateCollection(); - updateGrid(); - enable(); - } - @Override - public void onSuccess(Map obj) { - Double[] kms = obj.get(dbid); - double closest = - CrossSectionChartThemePanel.closest(kms, - selected_km); - GWT.log("Got single km for " + dbid + ", it is " - + closest); - SpinnerItem item = (SpinnerItem) ce.getItem(); - item.setValue(closest); - if (synchronNavigation) { - // Feed many ... - // Find all activated cross section themes - ThemeList themes = getThemeList(); - int nThemes = themes.getThemeCount(); - List artifacts = new ArrayList(); - for (int i = 0; i < nThemes; i++) { - final Theme theme = themes.getThemeAt(i+1); - if (theme.getFacet().equals("cross_section") && - theme.getActive() == 1) { - artifacts.add(artifactReference(theme.getArtifact())); - } - } - sendFeed(artifacts, - closest); - } - else { - sendFeed(facetRecord.getTheme().getArtifact(), - closest); - } - } - }); + spinnerValueEntered(item, selected_km, facetRecord); } }; return handler; @@ -457,7 +464,7 @@ spinnerItem.setMin(0); spinnerItem.setMax(2000); - spinnerItem.setStep(0.1f); + spinnerItem.setStep(0.1d); spinnerItem.setChangeOnKeypress(true); return spinnerItem; } @@ -489,9 +496,17 @@ HLayout recordCanvas = new HLayout(3); recordCanvas.setHeight(22); recordCanvas.setAlign(Alignment.CENTER); - SpinnerItem spinnerItem = createSpinnerItem(facetRecord); - spinnerItem.addChangedHandler( - createSpinnerHandler(feedService, facetRecord)); + final SpinnerItem spinnerItem = createSpinnerItem(facetRecord); + //spinnerItem.addChangedHandler( + // createSpinnerHandler(feedService, facetRecord)); + spinnerItem.addBlurHandler(new BlurHandler() { + @Override + public void onBlur (BlurEvent be) { + spinnerValueEntered(spinnerItem, + Double.parseDouble(spinnerItem.getValue().toString()), + facetRecord); + } + }); DynamicForm formWrap = new DynamicForm(); formWrap.setFields(spinnerItem);