com.vaadin.data.validator.StringLengthValidator Java Examples

The following examples show how to use com.vaadin.data.validator.StringLengthValidator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpServerConfigForm.java    From sensorhub with Mozilla Public License 2.0 6 votes vote down vote up
@Override
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
    Field<?> field = super.buildAndBindField(label, propId, prop);
    
    if (propId.equals(PROP_SERVLET_ROOT))
    {
        field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 2, 256, false));
    }
    else if (propId.equals(PROP_HTTP_PORT))
    {
        field.setWidth(100, Unit.PIXELS);
        //((TextField)field).getConverter().
        field.addValidator(new Validator() {
            private static final long serialVersionUID = 1L;
            public void validate(Object value) throws InvalidValueException
            {
                int portNum = (Integer)value;
                if (portNum > 10000 || portNum <= 80)
                    throw new InvalidValueException("Port number must be an integer number greater than 80 and lower than 10000");
            }
        });
    }
    
    return field;
}
 
Example #2
Source File: WinLoadBalancerEdit.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));

    if (PCCConstant.LOAD_BALANCER_ELB.equals(loadBalancerType)) {
        if (BooleanUtils.isTrue(awsVpc)) {
            message = ViewMessages.getMessage("IUI-000029");
            securityGroupSelect.setRequired(true);
            securityGroupSelect.setRequiredError(message);

            message = ViewMessages.getMessage("IUI-000108");
            subnetSelect.setRequired(true);
            subnetSelect.setRequiredError(message);
        }
    }
}
 
Example #3
Source File: GenericStorageConfigForm.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
    Field<Object> field = (Field<Object>)super.buildAndBindField(label, propId, prop);
    
    if (propId.equals(PROP_STORAGE_PATH))
        field.setVisible(false);
    
    else if (propId.equals(PROP_DATASRC_ID))
    {
        field = makeModuleSelectField(field, IDataProducerModule.class);
        field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
    }
    
    return field;
}
 
Example #4
Source File: SOSConfigForm.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected Field<?> buildAndBindField(String label, String propId, Property<?> prop)
{
    Field<Object> field = (Field<Object>)super.buildAndBindField(label, propId, prop);
    
    if (propId.endsWith(PROP_ENDPOINT))
    {
        field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
    }
    else if (propId.endsWith(PROP_ENABLED))
    {
        field.setVisible(true);
    }
    else if (propId.endsWith(PROP_URI))
    {
        field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
    }
    else if (propId.endsWith(PROP_STORAGEID))
    {
        field = makeModuleSelectField(field, IStorageModule.class);
    }
    else if (propId.endsWith(PROP_SENSORID))
    {
        field = makeModuleSelectField(field, ISensorModule.class);
        field.addValidator(new StringLengthValidator(MSG_REQUIRED_FIELD, 1, 256, false));
    }
    else if (propId.endsWith(PROP_DATAPROVIDERS + PROP_SEP + PROP_NAME))
        field.setVisible(true);
    
    return field;
}
 
Example #5
Source File: WinServiceAdd.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000031");
    serviceNameField.setRequired(true);
    serviceNameField.setRequiredError(message);
    serviceNameField.addValidator(new StringLengthValidator(message, -1, 15, false));
    serviceNameField.addValidator(new RegexpValidator("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", true, message));

    message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));

    message = ViewMessages.getMessage("IUI-000032");
    diskSizeField.setRequired(true);
    diskSizeField.setRequiredError(message);
    diskSizeField.addValidator(new RegexpValidator("^[1-9]|[1-9][0-9]{1,2}|1000$", true, message));
}
 
Example #6
Source File: MyCloudAdd.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000002");
    cloudNameField.setRequired(true);
    cloudNameField.setRequiredError(message);
    cloudNameField.addValidator(new StringLengthValidator(message, 1, 15, false));
    cloudNameField.addValidator(new RegexpValidator("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", true, message));

    message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
 
Example #7
Source File: WinServerAdd.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000022");
    serverNameField.setRequired(true);
    serverNameField.setRequiredError(message);
    serverNameField.addValidator(new StringLengthValidator(message, -1, 15, false));
    serverNameField.addValidator(new RegexpValidator("^[a-z]|[a-z][0-9a-z-]*[0-9a-z]$", true, message));

    message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
 
Example #8
Source File: WinLoadBalancerAdd.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000055");
    loadBalancerNameField.setRequired(true);
    loadBalancerNameField.setRequiredError(message);
    loadBalancerNameField.addValidator(new StringLengthValidator(message, 1, 15, false));
    loadBalancerNameField
            .addValidator(new RegexpValidator("^[0-9a-z]|[0-9a-z][0-9a-z-]*[0-9a-z]$", true, message));

    message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
 
Example #9
Source File: WinServiceEdit.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));

    message = ViewMessages.getMessage("IUI-000032");
    diskSizeField.setRequired(true);
    diskSizeField.setRequiredError(message);
    diskSizeField.addValidator(new RegexpValidator("^[1-9]|[1-9][0-9]{1,2}|1000$", true, message));
}
 
Example #10
Source File: WinServiceEdit.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000113");
    customParam1Field.addValidator(new StringLengthValidator(message, -1, 200, true));
    customParam1Field.addValidator(new RegexpValidator("^[0-9a-zA-Z-,._ ]*$", true, message));

    message = ViewMessages.getMessage("IUI-000114");
    customParam2Field.addValidator(new StringLengthValidator(message, -1, 200, true));
    customParam2Field.addValidator(new RegexpValidator("^[0-9a-zA-Z-,._ ]*$", true, message));

    message = ViewMessages.getMessage("IUI-000115");
    customParam3Field.addValidator(new StringLengthValidator(message, -1, 200, true));
    customParam3Field.addValidator(new RegexpValidator("^[0-9a-zA-Z-,._ ]*$", true, message));
}
 
Example #11
Source File: WinLoadBalancerEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
private void initValidation() {
    String message;

    // 監視プロトコル
    message = ViewMessages.getMessage("IUI-000069");
    checkProtocolSelect.setRequired(true);
    checkProtocolSelect.setRequiredError(message);

    // 監視ポート
    message = ViewMessages.getMessage("IUI-000070", 1, 65535);
    checkPortField.setRequired(true);
    checkPortField.setRequiredError(message);
    checkPortField.addValidator(new IntegerRangeValidator(1, 65535, message));

    // 監視Path
    message = ViewMessages.getMessage("IUI-000071", 100);
    checkPathField.setRequired(true);
    checkPathField.setRequiredError(message);
    checkPathField.addValidator(new StringLengthValidator(message, 1, 100, false));

    // タイムアウト時間
    message = ViewMessages.getMessage("IUI-000072", 2, 60);
    checkTimeoutField.setRequired(true);
    checkTimeoutField.setRequiredError(message);
    checkTimeoutField.addValidator(new IntegerRangeValidator(2, 60, message));

    // ヘルスチェック間隔
    message = ViewMessages.getMessage("IUI-000073", 5, 600);
    checkIntervalField.setRequired(true);
    checkIntervalField.setRequiredError(message);
    checkIntervalField.addValidator(new IntegerRangeValidator(5, 600, message));

    // 障害閾値
    message = ViewMessages.getMessage("IUI-000074", 2, 10);
    unhealthyThresholdField.setRequired(true);
    unhealthyThresholdField.setRequiredError(message);
    unhealthyThresholdField.addValidator(new IntegerRangeValidator(2, 10, message));

    // 復帰閾値
    if (PCCConstant.LOAD_BALANCER_ELB.equals(loadBalancerType)) {
        message = ViewMessages.getMessage("IUI-000075", 2, 10);
        healthyThresholdField.setRequired(true);
        healthyThresholdField.setRequiredError(message);
        healthyThresholdField.addValidator(new IntegerRangeValidator(2, 10, message));
    }
}
 
Example #12
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
 
Example #13
Source File: MyCloudEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}
 
Example #14
Source File: WinCloudStackLoadBalancerEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
private void initValidation() {
    String message = ViewMessages.getMessage("IUI-000003");
    commentField.addValidator(new StringLengthValidator(message, -1, 100, true));
}