Mercurial > dive4elements > river
changeset 3355:dab808e5f516
Improve validation of double-type style arguments.
flys-client/trunk@5038 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Wed, 18 Jul 2012 12:38:04 +0000 |
parents | 22f39c2d7a72 |
children | 6352244a4153 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java |
diffstat | 2 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Jul 18 12:34:05 2012 +0000 +++ b/flys-client/ChangeLog Wed Jul 18 12:38:04 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-18 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + * src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java: + Improve validation. + 2012-07-18 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java Wed Jul 18 12:34:05 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java Wed Jul 18 12:38:04 2012 +0000 @@ -23,6 +23,7 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; +import com.smartgwt.client.widgets.form.validator.IsFloatValidator; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYSConstants; @@ -70,7 +71,11 @@ /** Main layout. */ protected VLayout layout; + /** The form that contains all the input widgets. */ + DynamicForm df; + protected VLayout properties; + protected Canvas container; protected Map<String, Style> styleGroups; @@ -87,6 +92,7 @@ protected ThemeListingServiceAsync themeListingService = GWT.create(ThemeListingService.class); + /** * Setup editor dialog. * @param collection The collection the current theme belongs to. @@ -206,7 +212,11 @@ accept.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent e) { - saveStyle(); + // TODO Fix this, for whatever reason it doesnt work + // (always valid). + if (!df.hasErrors() && df.validate()) { + saveStyle(); + } } }); @@ -346,7 +356,7 @@ String type, String value) { - DynamicForm df = new DynamicForm(); + df = new DynamicForm(); df.setColWidths("40%", "60%"); FormItem f; @@ -423,7 +433,12 @@ f = c; } else if (type.equals("double")) { - f = new FormItem(MSG.getString(name)); + f = new FormItem(name); + IsFloatValidator fpv = new IsFloatValidator(); + + f.setValidators(fpv); + f.setValidateOnChange(true); + f.setTitle(MSG.getString(name)); f.addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent e) { DoubleValidator validator = new DoubleValidator();