# HG changeset patch # User Felix Wolfsteller # Date 1342615084 0 # Node ID dab808e5f5167b9493e7a0b1667fbddbcb66a531 # Parent 22f39c2d7a720a7db6e9f62eaaae352803aaf255 Improve validation of double-type style arguments. flys-client/trunk@5038 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 22f39c2d7a72 -r dab808e5f516 flys-client/ChangeLog --- 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 + + * src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.java: + Improve validation. + 2012-07-18 Felix Wolfsteller * src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java, diff -r 22f39c2d7a72 -r dab808e5f516 flys-client/src/main/java/de/intevation/flys/client/client/ui/StyleEditorWindow.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 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();