Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java @ 1502:d1223d93dd68
Issue 358.
Validate dialog on accept.
flys-client/trunk@3629 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Mon, 09 Jan 2012 14:28:37 +0000 |
parents | d12cb71965cf |
children | 3304608baf35 |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java Mon Jan 09 09:50:37 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java Mon Jan 09 14:28:37 2012 +0000 @@ -1,6 +1,7 @@ package de.intevation.flys.client.client.ui.chart; import java.util.List; +import java.util.Map; import com.google.gwt.core.client.GWT; import com.google.gwt.user.client.rpc.AsyncCallback; @@ -123,7 +124,13 @@ cancel.addClickHandler(this); accept.addClickHandler(new ClickHandler() { public void onClick(ClickEvent e) { - updateCollection(); + if(isDialogValid()) { + updateCollection(); + } + else { + GWT.log("Dialog not valid"); + SC.warn(MSG.error_dialog_not_valid()); + } } }); @@ -404,4 +411,39 @@ this.tab.updateChartInfo(); this.tab.updateChartPanel(); } + + + protected boolean isDialogValid() { + boolean valid = true; + for (int i = 0; i < tabs.getNumTabs(); i++) { + Tab t = tabs.getTab(i); + Canvas container = t.getPane(); + Canvas[] children = container.getChildren(); + for (Canvas c: children) { + valid = validateCanvas(c); + if(!valid) { + return valid; + } + } + } + return valid; + } + + + protected boolean validateCanvas(Canvas c) { + boolean valid = true; + if(c instanceof DynamicForm) { + DynamicForm f = (DynamicForm) c; + return !f.hasErrors(); + } + else if(c.getChildren().length > 0) { + for (Canvas child: c.getChildren()) { + valid = validateCanvas(child); + if(!valid) { + return valid; + } + } + } + return valid; + } }