teichmann@5861: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5861: * Software engineering by Intevation GmbH teichmann@5861: * teichmann@5861: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5861: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5861: * documentation coming with Dive4Elements River for details. teichmann@5861: */ teichmann@5861: teichmann@5835: package org.dive4elements.river.client.client.ui.chart; raimund@1429: raimund@1429: import com.google.gwt.core.client.GWT; raimund@1478: import com.google.gwt.user.client.rpc.AsyncCallback; raimund@1429: christian@4568: import com.smartgwt.client.types.Alignment; raimund@1478: import com.smartgwt.client.util.SC; christian@4568: import com.smartgwt.client.widgets.Button; christian@4568: import com.smartgwt.client.widgets.Canvas; christian@4568: import com.smartgwt.client.widgets.Label; raimund@1429: import com.smartgwt.client.widgets.Window; christian@4568: import com.smartgwt.client.widgets.events.ClickEvent; christian@4568: import com.smartgwt.client.widgets.events.ClickHandler; raimund@1429: import com.smartgwt.client.widgets.form.DynamicForm; christian@4568: import com.smartgwt.client.widgets.form.fields.CheckboxItem; raimund@1429: import com.smartgwt.client.widgets.form.fields.FormItem; felix@3511: import com.smartgwt.client.widgets.form.fields.SelectItem; raimund@1431: import com.smartgwt.client.widgets.form.fields.TextItem; christian@4568: import com.smartgwt.client.widgets.form.fields.events.BlurEvent; christian@4568: import com.smartgwt.client.widgets.form.fields.events.BlurHandler; christian@4568: import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; raimund@1465: import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; christian@4568: import com.smartgwt.client.widgets.layout.HLayout; christian@4568: import com.smartgwt.client.widgets.layout.VLayout; christian@4568: import com.smartgwt.client.widgets.tab.Tab; christian@4568: import com.smartgwt.client.widgets.tab.TabSet; raimund@1429: teichmann@5835: import org.dive4elements.river.client.client.Config; teichmann@5835: import org.dive4elements.river.client.client.FLYSConstants; teichmann@5835: import org.dive4elements.river.client.client.services.CollectionAttributeService; teichmann@5835: import org.dive4elements.river.client.client.services.CollectionAttributeServiceAsync; teichmann@5835: import org.dive4elements.river.client.client.utils.DoubleValidator; teichmann@5835: import org.dive4elements.river.client.client.utils.IntegerValidator; teichmann@5835: import org.dive4elements.river.client.shared.model.BooleanProperty; teichmann@5835: import org.dive4elements.river.client.shared.model.Collection; teichmann@5835: import org.dive4elements.river.client.shared.model.DoubleProperty; teichmann@5835: import org.dive4elements.river.client.shared.model.IntegerProperty; teichmann@5835: import org.dive4elements.river.client.shared.model.OutputSettings; teichmann@5835: import org.dive4elements.river.client.shared.model.Property; teichmann@5835: import org.dive4elements.river.client.shared.model.PropertyGroup; teichmann@5835: import org.dive4elements.river.client.shared.model.PropertySetting; teichmann@5835: import org.dive4elements.river.client.shared.model.Settings; teichmann@5835: import org.dive4elements.river.client.shared.model.StringProperty; raimund@1429: christian@4568: import java.util.LinkedHashMap; christian@4568: import java.util.List; christian@4568: import java.util.Map; raimund@1478: raimund@1429: /** felix@3511: * Dialog for the Chart-Properties, constructed from respective xml document. felix@3511: * raimund@1429: * @author Raimund Renkert raimund@1429: */ raimund@1429: public class ChartPropertiesEditor felix@1550: extends Window felix@1550: implements ClickHandler raimund@1429: { raimund@1429: /** The interface that provides i18n messages. */ raimund@1429: protected FLYSConstants MSG = GWT.create(FLYSConstants.class); raimund@1429: felix@2940: /** CollectionAttribute Update Service. */ raimund@1478: protected CollectionAttributeServiceAsync updater = raimund@1478: GWT.create(CollectionAttributeService.class); raimund@1478: raimund@1429: /** The tab called the editor window. */ raimund@1482: protected ChartOutputTab tab; raimund@1429: felix@1543: /** The tabset for chart properties. */ raimund@1429: protected TabSet tabs; raimund@1429: felix@1543: /** The collection. */ raimund@1478: protected Collection collection; raimund@1478: felix@1543: /** The cloned output settings. */ raimund@1478: protected OutputSettings settings; raimund@1478: felix@1543: /** The original output settings. */ raimund@1503: protected OutputSettings origSettings; raimund@1503: raimund@1478: felix@5334: raimund@1429: /** raimund@1429: * Setup editor dialog. felix@1560: * @param callerTab The tab called the editor window. raimund@1429: */ raimund@1482: public ChartPropertiesEditor(ChartOutputTab callerTab) { raimund@1429: this.tab = callerTab; raimund@1429: this.tabs = new TabSet(); raimund@1429: raimund@1429: init(); raimund@1429: } raimund@1429: felix@2940: raimund@1429: /** raimund@1429: * Initialize the editor window and its components. raimund@1429: */ raimund@1429: protected void init() { raimund@1429: setTitle(MSG.properties()); raimund@1429: setCanDragReposition(true); raimund@1429: setCanDragResize(true); raimund@1429: raimund@1478: collection = tab.getCollectionView().getCollection(); raimund@1465: String outputName = tab.getOutputName(); raimund@1503: origSettings = (OutputSettings)collection.getSettings(outputName); raimund@1465: raimund@1503: settings = (OutputSettings)origSettings.clone(); raimund@1465: if (settings == null) { raimund@1465: return; raimund@1465: } raimund@1465: List list = settings.getCategories(); raimund@1465: raimund@1465: for (int i = 0; i < list.size(); i++) { raimund@1465: Tab t = new Tab(MSG.getString(list.get(i))); raimund@1465: List props = settings.getSettings(list.get(i)); raimund@1503: List origProps = origSettings.getSettings(list.get(i)); raimund@1465: VLayout layout = new VLayout(); raimund@1465: for (int j = 0; j < props.size(); j++) { raimund@1465: if (props.get(j) instanceof PropertyGroup) { raimund@1503: layout.addMember(generatePropertyGroup(props.get(j), raimund@1503: origProps.get(j))); raimund@1465: } raimund@1465: else if (props.get(j) instanceof PropertySetting) { raimund@1465: PropertySetting p = (PropertySetting)props.get(j); raimund@1465: if (p.getAttribute("display").equals("false")) { raimund@1465: continue; raimund@1465: } raimund@1503: layout.addMember(generatePropertySetting(props.get(j), raimund@1503: origProps.get(j))); raimund@1465: } raimund@1465: } raimund@1465: t.setPane(layout); raimund@1465: tabs.addTab(t); raimund@1465: } raimund@1429: raimund@1429: Button accept = new Button(MSG.label_ok()); raimund@1429: Button cancel = new Button(MSG.label_cancel()); raimund@1429: cancel.addClickHandler(this); raimund@1429: accept.addClickHandler(new ClickHandler() { christian@4568: @Override raimund@1429: public void onClick(ClickEvent e) { raimund@1502: if(isDialogValid()) { raimund@1502: updateCollection(); raimund@1502: } raimund@1502: else { raimund@1502: GWT.log("Dialog not valid"); raimund@1502: SC.warn(MSG.error_dialog_not_valid()); raimund@1502: } raimund@1429: } raimund@1429: }); raimund@1429: raimund@1429: HLayout buttons = new HLayout(); raimund@1429: buttons.addMember(accept); raimund@1429: buttons.addMember(cancel); raimund@1429: buttons.setAlign(Alignment.CENTER); raimund@1429: buttons.setHeight(30); raimund@1429: raimund@1429: addItem(tabs); raimund@1429: addItem(buttons); raimund@1500: setWidth(380); raimund@1431: setHeight(470); raimund@1429: centerInPage(); raimund@1429: } raimund@1429: felix@3511: raimund@1429: /** raimund@1429: * This method is called when the user aborts theming. raimund@1429: * @param event The event. raimund@1429: */ christian@4568: @Override raimund@1429: public void onClick(ClickEvent event) { raimund@1503: this.destroy(); raimund@1429: } raimund@1431: raimund@1431: raimund@1431: /** felix@5334: * Create a section from group (usually axis properties). raimund@1431: */ raimund@1503: protected Canvas generatePropertyGroup(Property group, Property orig) { raimund@1465: PropertyGroup pg = (PropertyGroup)group; raimund@1503: PropertyGroup origPg = (PropertyGroup)orig; raimund@1431: raimund@1465: if (pg.getName().equals("axis")) { raimund@1465: Label scale = new Label(MSG.scale() + " :"); raimund@1465: scale.setHeight(25); raimund@1465: scale.setMargin(2); raimund@1431: raimund@1465: DynamicForm form1 = new DynamicForm(); raimund@1465: DynamicForm form2 = new DynamicForm(); raimund@1465: form2.setNumCols(6); raimund@1431: raimund@1465: StringProperty label = raimund@1465: (StringProperty)pg.getPropertyByName("label"); raimund@1465: FormItem title = createStringProperty(label); raimund@1503: title.setValue( raimund@1503: ((StringProperty)origPg.getPropertyByName("label")).getValue()); raimund@1431: raimund@1465: IntegerProperty fontsize = raimund@1465: (IntegerProperty)pg.getPropertyByName("font-size"); raimund@1465: FormItem fs = createIntegerProperty(fontsize); raimund@1503: fs.setValue( raimund@1503: ((IntegerProperty) raimund@1503: origPg.getPropertyByName("font-size")).getValue()); raimund@1465: raimund@1465: DoubleProperty upper = raimund@1465: (DoubleProperty)pg.getPropertyByName("upper"); raimund@1465: final FormItem range1 = createDoubleProperty(upper); raimund@2475: range1.setName("rangeupper"); raimund@1500: range1.setWidth(70); raimund@1507: range1.setValue( raimund@1507: ((DoubleProperty) raimund@1507: origPg.getPropertyByName("upper")).toUIString()); raimund@1507: raimund@1465: DoubleProperty lower = raimund@1465: (DoubleProperty)pg.getPropertyByName("lower"); raimund@1465: final FormItem range2 = createDoubleProperty(lower); raimund@2475: range2.setName("rangelower"); raimund@1500: range2.setWidth(70); raimund@1507: range2.setValue( raimund@1507: ((DoubleProperty) raimund@1507: origPg.getPropertyByName("lower")).toUIString()); raimund@1465: raimund@1465: BooleanProperty fixation = raimund@1465: (BooleanProperty)pg.getPropertyByName("fixation"); raimund@1465: FormItem fix = createBooleanProperty(fixation); raimund@1507: fix.setValue(((BooleanProperty) raimund@1507: origPg.getPropertyByName("fixation")).getValue().booleanValue()); raimund@1507: raimund@1465: fix.addChangedHandler(new ChangedHandler() { christian@4568: @Override raimund@1465: public void onChanged(ChangedEvent e) { raimund@1465: if ((Boolean)e.getValue()) { raimund@1465: range1.enable(); raimund@1465: range2.enable(); raimund@1465: } raimund@1465: else { raimund@1465: range1.disable(); raimund@1465: range2.disable(); raimund@1465: } raimund@1465: } raimund@1465: }); raimund@1507: if (fix.getValue().toString().equals("true")) { raimund@1465: range1.enable(); raimund@1465: range2.enable(); raimund@1465: } raimund@1465: else { raimund@1465: range1.disable(); raimund@1465: range2.disable(); raimund@1465: } raimund@1465: raimund@1465: form1.setFields(title, fs); raimund@1501: form2.setFields(fix, range2, range1); raimund@1465: raimund@1465: HLayout scaleLayout = new HLayout(); raimund@1465: scaleLayout.setHeight(30); raimund@1465: scaleLayout.addMember(scale); raimund@1465: scaleLayout.addMember(form2); raimund@1503: scaleLayout.setStyleName("property-dialog-axis"); raimund@1465: raimund@1465: VLayout root = new VLayout(); raimund@1465: root.addMember(form1); raimund@1465: root.addMember(scaleLayout); raimund@1465: root.setHeight(90); raimund@1465: raimund@1465: return root; raimund@1465: } raimund@1465: return null; raimund@1465: } raimund@1431: raimund@1431: raimund@1465: /** felix@3511: * Generate a form with items for the properties/settings, preset with felix@3511: * values. raimund@1465: */ raimund@1503: protected DynamicForm generatePropertySetting( raimund@1503: Property setting, raimund@1503: Property orig) raimund@1503: { raimund@1465: DynamicForm form = new DynamicForm(); raimund@1478: FormItem item = new FormItem(); raimund@1465: if (setting instanceof BooleanProperty) { raimund@1478: item = createBooleanProperty((BooleanProperty)setting); raimund@1508: item.setValue(((BooleanProperty)orig).getValue().booleanValue()); raimund@1465: } raimund@1465: else if (setting instanceof DoubleProperty) { raimund@1478: item = createDoubleProperty((DoubleProperty)setting); raimund@1507: item.setValue(((DoubleProperty)orig).toUIString()); raimund@1465: } raimund@1465: else if (setting instanceof IntegerProperty) { raimund@1478: item = createIntegerProperty((IntegerProperty)setting); raimund@1503: item.setValue(((IntegerProperty)orig).getValue()); raimund@1465: } raimund@1465: else if (setting instanceof StringProperty) { felix@3511: StringProperty property = (StringProperty) setting; felix@3511: item = createStringProperty(property); raimund@1503: item.setValue(((StringProperty)orig).getValue()); raimund@1465: } felix@3511: else { felix@3511: GWT.log("generatePropertySetting: unknown setting type."); felix@3511: } raimund@1478: form.setFields(item); raimund@1465: return form; raimund@1465: } raimund@1431: raimund@1431: raimund@1478: protected FormItem createStringProperty(final StringProperty sp) { raimund@1465: String name = sp.getName(); raimund@1465: if (name.contains("-")) { raimund@1465: name = name.replace("-", "_"); raimund@1465: } felix@3511: felix@3511: String choiceAttribute = sp.getAttribute("choice"); felix@3520: felix@3511: if (choiceAttribute != null && choiceAttribute.equals("logo")) { felix@3511: SelectItem logoChooser = new SelectItem(); felix@3536: logoChooser.setImageURLPrefix(GWT.getHostPageBaseURL() + "images/logo-"); felix@3536: logoChooser.setValueIconHeight(50); felix@3536: logoChooser.setValueIconWidth(100); felix@3536: felix@3511: LinkedHashMap valueMap = new LinkedHashMap(); felix@3536: LinkedHashMap valueIcons = new LinkedHashMap(); felix@3520: valueMap.put("none", MSG.getString("none")); felix@3536: /* felix@3536: If you want to add images, remember to change code in these places: felix@3536: flys-artifacts: felix@3536: XYChartGenerator.java felix@3536: Timeseries*Generator.java and felix@3536: in the flys-client projects Chart*Propert*Editor.java. felix@3536: Also, these images have to be put in felix@3536: flys-artifacts/src/main/resources/images/ felix@3536: flys-client/src/main/webapp/images/ felix@3536: */ felix@3537: valueMap.put("BfG", ""); felix@3537: valueMap.put("Intevation", ""); felix@3536: valueIcons.put("BfG", "bfg.gif"); felix@3536: valueIcons.put("Intevation", "intevation.png"); felix@3536: logoChooser.setValueIcons(valueIcons); felix@3511: logoChooser.setValueMap(valueMap); felix@3511: logoChooser.setTitleStyle("color:#000;"); felix@3511: logoChooser.setTitleAlign(Alignment.LEFT); felix@3511: logoChooser.setTitle(MSG.getString(name)); felix@3511: logoChooser.setTitleAlign(Alignment.LEFT); felix@3511: logoChooser.addBlurHandler(new BlurHandler() { christian@4568: @Override felix@3511: public void onBlur(BlurEvent e) { felix@3511: String val; felix@3511: if (e.getItem().getValue() == null) { felix@3511: val = ""; felix@3511: } felix@3511: else { felix@3511: val = e.getItem().getValue().toString(); felix@3511: } felix@3511: sp.setValue(val); felix@3511: } felix@3511: }); felix@3511: return logoChooser; felix@3511: } felix@3513: else if (choiceAttribute != null && choiceAttribute.equals("placeh")) { felix@3513: SelectItem placeChooser = new SelectItem(); felix@3513: LinkedHashMap valueMap = new LinkedHashMap(); felix@3520: valueMap.put("right", MSG.getString("right")); felix@3520: valueMap.put("left", MSG.getString("left")); felix@3520: valueMap.put("center", MSG.getString("center")); felix@3513: placeChooser.setValueMap(valueMap); felix@3513: placeChooser.setTitleStyle("color:#000;"); felix@3513: placeChooser.setTitleAlign(Alignment.LEFT); felix@3513: placeChooser.setTitle(MSG.getString(name)); felix@3513: placeChooser.setTitleAlign(Alignment.LEFT); felix@3513: placeChooser.addBlurHandler(new BlurHandler() { christian@4568: @Override felix@3513: public void onBlur(BlurEvent e) { felix@3513: String val; felix@3513: if (e.getItem().getValue() == null) { felix@3513: val = ""; felix@3513: } felix@3513: else { felix@3513: val = e.getItem().getValue().toString(); felix@3513: } felix@3513: sp.setValue(val); felix@3513: } felix@3513: }); felix@3513: return placeChooser; felix@3513: } felix@3513: else if (choiceAttribute != null && choiceAttribute.equals("placev")) { felix@3512: SelectItem placeChooser = new SelectItem(); felix@3512: LinkedHashMap valueMap = new LinkedHashMap(); felix@3520: valueMap.put("top", MSG.getString("top")); felix@3520: valueMap.put("bottom", MSG.getString("bottom")); felix@3520: valueMap.put("center", MSG.getString("center")); felix@3512: placeChooser.setValueMap(valueMap); felix@3512: placeChooser.setTitleStyle("color:#000;"); felix@3512: placeChooser.setTitleAlign(Alignment.LEFT); felix@3512: placeChooser.setTitle(MSG.getString(name)); felix@3512: placeChooser.setTitleAlign(Alignment.LEFT); felix@3512: placeChooser.addBlurHandler(new BlurHandler() { christian@4568: @Override felix@3512: public void onBlur(BlurEvent e) { felix@3512: String val; felix@3512: if (e.getItem().getValue() == null) { felix@3512: val = ""; felix@3512: } felix@3512: else { felix@3512: val = e.getItem().getValue().toString(); felix@3512: } felix@3512: sp.setValue(val); felix@3512: } felix@3512: }); felix@3512: return placeChooser; felix@3512: } felix@3511: raimund@1465: TextItem item = new TextItem(); raimund@1465: item.setTitle(MSG.getString(name)); raimund@1465: item.setTitleAlign(Alignment.LEFT); raimund@1507: item.addBlurHandler(new BlurHandler() { christian@4568: @Override raimund@1507: public void onBlur(BlurEvent e) { raimund@1478: String val; raimund@1507: if (e.getItem().getValue() == null) { raimund@1478: val = ""; raimund@1478: } raimund@1478: else { raimund@1507: val = e.getItem().getValue().toString(); raimund@1478: } raimund@1478: sp.setValue(val); raimund@1478: } raimund@1478: }); raimund@1465: return item; raimund@1465: } raimund@1431: raimund@1431: raimund@1465: /** raimund@1465: * raimund@1465: */ raimund@1478: protected FormItem createBooleanProperty(final BooleanProperty bp) { raimund@1465: String name = bp.getName(); raimund@1465: if (name.contains("-")) { raimund@1465: name = name.replace("-", "_"); raimund@1465: } raimund@1431: raimund@1465: CheckboxItem item = new CheckboxItem("item", MSG.getString(name)); raimund@1465: item.setLabelAsTitle(true); raimund@1465: item.setTitleStyle("color:#000;"); raimund@1465: item.setTitleAlign(Alignment.LEFT); raimund@1507: item.addBlurHandler(new BlurHandler() { christian@4568: @Override raimund@1507: public void onBlur(BlurEvent e) { raimund@1478: String val; raimund@1507: if (e.getItem().getValue() == null) { raimund@1478: val = ""; raimund@1478: } raimund@1478: else { raimund@1507: val = e.getItem().getValue().toString(); raimund@1478: } raimund@1478: bp.setValue(val); raimund@1478: } raimund@1478: }); raimund@1465: return item; raimund@1431: } raimund@1431: raimund@1465: raimund@1431: /** raimund@1465: * raimund@1431: */ raimund@1478: protected FormItem createDoubleProperty(final DoubleProperty dp) { raimund@1465: String name = dp.getName(); raimund@1465: if (name.contains("-")) { raimund@1465: name = name.replace("-", "_"); raimund@1465: } raimund@1431: raimund@1465: TextItem item = new TextItem(); raimund@1465: item.setTitle(MSG.getString(name)); raimund@1465: item.setTitleAlign(Alignment.LEFT); raimund@1507: item.addBlurHandler(new BlurHandler() { christian@4568: @Override raimund@1507: public void onBlur(BlurEvent e) { raimund@1507: DoubleValidator validator = new DoubleValidator(); raimund@1507: Map errors = e.getForm().getErrors(); raimund@1507: if(validator.validate(e.getItem(), errors)) { raimund@1507: dp.setValueFromUI(e.getItem().getValue().toString()); raimund@1507: } felix@3356: e.getForm().setErrors(errors, true); raimund@1478: } raimund@1478: }); raimund@1465: return item; raimund@1431: } raimund@1431: raimund@1465: raimund@1465: /** raimund@1465: * raimund@1465: */ raimund@1478: protected FormItem createIntegerProperty(final IntegerProperty ip) { raimund@1465: String name = ip.getName(); raimund@1465: if (name.contains("-")) { raimund@1465: name = name.replace("-", "_"); raimund@1465: } raimund@1465: raimund@1465: TextItem item = new TextItem(); raimund@1465: item.setTitle(MSG.getString(name)); raimund@1465: item.setTitleAlign(Alignment.LEFT); raimund@1507: item.addBlurHandler(new BlurHandler() { christian@4568: @Override raimund@1507: public void onBlur(BlurEvent e) { raimund@1507: IntegerValidator validator = new IntegerValidator(); raimund@1507: Map errors = e.getForm().getErrors(); raimund@1507: if(validator.validate(e.getItem(), errors)) { raimund@1507: ip.setValue(e.getItem().getValue().toString()); raimund@1478: } felix@3356: e.getForm().setErrors(errors, true); raimund@1478: } raimund@1478: }); raimund@1465: return item; raimund@1465: } raimund@1478: raimund@1478: raimund@1478: protected void updateCollection() { raimund@1478: final Config config = Config.getInstance(); raimund@1478: final String loc = config.getLocale(); raimund@1478: raimund@1478: GWT.log("PropertiesEditor.updateCollection via RPC now"); raimund@1478: raimund@1503: Settings s = settings; raimund@1503: collection.addSettings(this.tab.getOutputName(), s); raimund@1478: updater.update(collection, loc, new AsyncCallback() { christian@4568: @Override raimund@1478: public void onFailure(Throwable caught) { raimund@1478: GWT.log("Could not update collection attributes."); raimund@1478: SC.warn(MSG.getString(caught.getMessage())); raimund@1478: } christian@4568: @Override raimund@1478: public void onSuccess(Collection collection) { raimund@1482: updateChartTab(); raimund@1478: } raimund@1478: }); raimund@1478: } raimund@1478: raimund@1482: protected void updateChartTab() { raimund@1482: this.tab.updateChartInfo(); raimund@1482: this.tab.updateChartPanel(); raimund@1503: this.destroy(); raimund@1482: } raimund@1502: raimund@1502: raimund@1502: protected boolean isDialogValid() { raimund@1502: boolean valid = true; raimund@1502: for (int i = 0; i < tabs.getNumTabs(); i++) { raimund@1502: Tab t = tabs.getTab(i); raimund@1502: Canvas container = t.getPane(); raimund@1502: Canvas[] children = container.getChildren(); raimund@1502: for (Canvas c: children) { raimund@1502: valid = validateCanvas(c); raimund@1502: if(!valid) { raimund@1502: return valid; raimund@1502: } raimund@1502: } raimund@1502: } raimund@1502: return valid; raimund@1502: } raimund@1502: raimund@1502: raimund@1502: protected boolean validateCanvas(Canvas c) { raimund@1502: boolean valid = true; raimund@1502: if(c instanceof DynamicForm) { raimund@1502: DynamicForm f = (DynamicForm) c; raimund@2475: FormItem up = f.getItem("rangeupper"); raimund@2475: FormItem lo = f.getItem("rangelower"); raimund@2475: raimund@2475: if(up != null && lo != null && raimund@2475: !up.isDisabled() && !lo.isDisabled()) raimund@2475: { raimund@2475: validateRange(f); raimund@2475: } raimund@1502: return !f.hasErrors(); raimund@1502: } raimund@1502: else if(c.getChildren().length > 0) { raimund@1502: for (Canvas child: c.getChildren()) { raimund@1502: valid = validateCanvas(child); raimund@1502: if(!valid) { raimund@1502: return valid; raimund@1502: } raimund@1502: } raimund@1502: } raimund@1502: return valid; raimund@1502: } raimund@2475: raimund@2475: protected boolean validateRange(DynamicForm form) { raimund@2475: Map errors = form.getErrors(); raimund@2475: FormItem up = form.getItem("rangeupper"); raimund@2475: FormItem lo = form.getItem("rangelower"); raimund@2475: raimund@2475: String v1 = up.getValue().toString(); raimund@2475: String v2 = lo.getValue().toString(); raimund@2475: raimund@2475: if(v1.equals(v2)) { raimund@2475: errors.put(up.getFieldName(), MSG.wrongFormat()); raimund@2475: errors.put(lo.getFieldName(), MSG.wrongFormat()); raimund@2475: form.setErrors(errors, true); raimund@2475: return false; raimund@2475: } raimund@2475: return true; raimund@2475: } raimund@1429: } felix@1550: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :