# HG changeset patch # User Felix Wolfsteller # Date 1328019023 0 # Node ID 0fbbcec35462f274ad7135d0aff241f0a34b5bb5 # Parent 60f8edc7a6f0708554d48e28af6c855088e9f74c Improved spinner-behaviour in cross section km control. flys-client/trunk@3838 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 60f8edc7a6f0 -r 0fbbcec35462 flys-client/ChangeLog --- a/flys-client/ChangeLog Tue Jan 31 13:04:51 2012 +0000 +++ b/flys-client/ChangeLog Tue Jan 31 14:10:23 2012 +0000 @@ -1,3 +1,10 @@ +2012-01-31 Felix Wolfsteller + + * src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java: + Added documentation, minor cleanup. + Added KeyPressHandler to km-spinnerItem, lose focus on + Enter-KeyPress. + 2012-01-31 Felix Wolfsteller * src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java: diff -r 60f8edc7a6f0 -r 0fbbcec35462 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 13:04:51 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java Tue Jan 31 14:10:23 2012 +0000 @@ -32,6 +32,8 @@ 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.form.fields.events.KeyPressEvent; +import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler; import com.smartgwt.client.widgets.menu.Menu; import com.smartgwt.client.widgets.menu.MenuItem; @@ -94,6 +96,7 @@ /** Combobox for master artifacts.*/ protected SelectItem masterCb; + /** * Trivial constructor. */ @@ -225,7 +228,8 @@ feedData, new AsyncCallback() { public void onFailure(Throwable caught) { - GWT.log("Could not un-master artifact ("+getCurrentCSMaster()+"): " + + GWT.log("Could not un-master artifact (" + + getCurrentCSMaster() + "): " + caught.getMessage()); SC.warn(MSG.getString(caught.getMessage())); enable(); @@ -288,8 +292,14 @@ return bestMatch; } - /** Feed a single artifact with the km of the crosssection to display. - * If its the selected master, also feed the collectionmaster. */ + + /** + * Feed a single artifact with the km of the crosssection to display. + * If its the selected master, also feed the collectionmaster. + * + * @param artifacts List of artifacts to feed. + * @param kmD The km to set. + */ public void sendFeed(final List artifacts, final double kmD) { Config config = Config.getInstance(); final String locale = config.getLocale(); @@ -319,8 +329,13 @@ }); } - /** Feed a single artifact with the km of the crosssection to display. - * If its the selected master, also feed the collectionmaster. */ + + /** + * Feed a single artifact with the km of the crosssection to display. + * If its the selected master, also feed the collectionmaster. + * @param artUUID The UUID of the artifact to feed. + * @param kmD The km to set. + */ public void sendFeed(final String artUUID, final double kmD) { Config config = Config.getInstance(); final String locale = config.getLocale(); @@ -350,9 +365,11 @@ }); } + public void spinnerValueEntered(final SpinnerItem item, final double enteredKm, final FacetRecord facetRecord ) { + disable(); Config config = Config.getInstance(); final String locale = config.getLocale(); @@ -370,7 +387,6 @@ map.put(dbid, enteredKm); - disable(); kmService.getCrossSectionKMs(locale, map, 2, new AsyncCallback>() { @@ -380,7 +396,7 @@ + dbid + ": "+ caught.getMessage()); SC.warn(MSG.getString(caught.getMessage())); updateCollection(); - updateGrid(); + //updateGrid(); enable(); } @Override @@ -496,9 +512,9 @@ HLayout recordCanvas = new HLayout(3); recordCanvas.setHeight(22); recordCanvas.setAlign(Alignment.CENTER); + + // When losing focus, update values. final SpinnerItem spinnerItem = createSpinnerItem(facetRecord); - //spinnerItem.addChangedHandler( - // createSpinnerHandler(feedService, facetRecord)); spinnerItem.addBlurHandler(new BlurHandler() { @Override public void onBlur (BlurEvent be) { @@ -508,6 +524,15 @@ } }); + // Add KeyPressHandler to lose focus when Enter key is pressed. + spinnerItem.addKeyPressHandler(new KeyPressHandler(){ + public void onKeyPress(KeyPressEvent kpe) { + if (kpe.getKeyName().equals("Enter")) { + spinnerItem.blurItem(); + } + } + }); + DynamicForm formWrap = new DynamicForm(); formWrap.setFields(spinnerItem); formWrap.setTitlePrefix("");