Example usage for com.vaadin.data.validator LongRangeValidator LongRangeValidator

List of usage examples for com.vaadin.data.validator LongRangeValidator LongRangeValidator

Introduction

In this page you can find the example usage for com.vaadin.data.validator LongRangeValidator LongRangeValidator.

Prototype

public LongRangeValidator(String errorMessage, Long minValue, Long maxValue) 

Source Link

Document

Creates a validator for checking that an Long is within a given range.

Usage

From source file:com.yoncabt.ebr.ui.ReportWindow.java

private void showFields(ReportDefinition definition, final Window w, final FormLayout fl)
        throws AssertionError, JSONException {
    fl.removeAllComponents();//  www  .  jav a  2s  . c  om
    w.setCaption(definition.getCaption());
    for (ReportParam param : definition.getReportParams()) {
        AbstractField comp = null;
        if (param.getInputType() == InputType.COMBO) {
            ComboBox f = new ComboBox(param.getLabel());
            param.getLovData().forEach((k, v) -> {
                f.addItem(k);
                f.setItemCaption(k, (String) v);
            });
            comp = f;
        } else {
            switch (param.getFieldType()) {
            case STRING: {
                TextField f = new TextField(param.getLabel());
                comp = f;
                break;
            }
            case INTEGER: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new IntegerRangeValidator("Say kontrol", (Integer) param.getMin(),
                        (Integer) param.getMax()));
                comp = f;
                break;
            }
            case LONG: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new LongRangeValidator("Say kontrol", (Long) param.getMin(),
                        (Long) param.getMax()));
                comp = f;
                break;
            }
            case DOUBLE: {
                TextField f = new TextField(param.getLabel());
                f.addValidator(new DoubleRangeValidator("Say kontrol", (Double) param.getMin(),
                        (Double) param.getMax()));
                comp = f;
                break;
            }
            case DATE: {
                DateField f = new DateField(param.getLabel());
                f.setDateFormat(param.getFormat());
                comp = f;
                break;
            }
            default: {
                throw new AssertionError(param.getName() + " in tipi tannmyor :" + param.getJavaType());
            }
            }
        }
        if (param.getDefaultValue() != null) {
            comp.setValue(param.getDefaultValue());
        }
        comp.setImmediate(true);
        comp.setValidationVisible(false);
        comp.setId(param.getName());
        fl.addComponent(comp);

    }
    if (report instanceof SQLReport) {
        reportType.addItem(ReportOutputFormat.xls);
        reportType.setItemCaption(ReportOutputFormat.xls, ReportOutputFormat.xls.getTypeName());
    } else {
        for (ReportOutputFormat value : ReportOutputFormat.values()) {
            reportType.addItem(value);
            reportType.setItemCaption(value, value.getTypeName());
        }
    }
    reportType.setValue(ReportOutputFormat.xls);
    fl.addComponent(reportType);
    fl.addComponent(reportLocale);
    fl.addComponent(email);
}

From source file:info.magnolia.jcrtools.field.validator.LongRangeValidatorFactory.java

License:Open Source License

public Validator createValidator() {
    return new LongRangeValidator(definition.getErrorMessage(), definition.getMin(), definition.getMax());
}