Example usage for com.jgoodies.validation ValidationResult ValidationResult

List of usage examples for com.jgoodies.validation ValidationResult ValidationResult

Introduction

In this page you can find the example usage for com.jgoodies.validation ValidationResult ValidationResult.

Prototype

public ValidationResult() 

Source Link

Document

Constructs an empty modifiable ValidationResult.

Usage

From source file:gov.nih.nci.cacore.workbench.portal.panel.ProjectDirSettingsPanel.java

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Project Directory Setting Validation
    if (ValidationUtils.isBlank(this.getProjectGenDirField().getText())) {
        result.add(new SimpleValidationMessage(PROJECT_GEN_DIR + " must not be blank", Severity.ERROR,
                PROJECT_GEN_DIR));//  ww w. j a v  a 2 s  .  c om
    } else {
        File file = new File(this.getProjectGenDirField().getText());
        if (file.exists()) {
            result.add(new SimpleValidationMessage(
                    PROJECT_GEN_DIR + " already exists.  The output directory will be overwritten.",
                    Severity.WARNING, PROJECT_GEN_DIR));
        } else {
            result.add(new SimpleValidationMessage(
                    PROJECT_GEN_DIR
                            + " does not exist.  Please select the Home directory of an existing directory.",
                    Severity.ERROR, PROJECT_GEN_DIR));
        }
    }

    return result;
}

From source file:gov.nih.nci.cacore.workbench.portal.panel.ProjectSettingsPanel.java

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Panel Settings Validation
    if (ValidationUtils.isBlank(this.getProjectDirField().getText())) {
        result.add(//from w ww. ja  v a2  s.c o m
                new SimpleValidationMessage(PROJECT_DIR + " must not be blank.", Severity.ERROR, PROJECT_DIR));
    } else {
        File file = new File(this.getProjectDirField().getText());
        if (file.exists()) {
            result.add(new SimpleValidationMessage(
                    PROJECT_DIR + " already exists.  The output directory will be overwritten.",
                    Severity.WARNING, PROJECT_DIR));
        }
    }

    if (ValidationUtils.isBlank(this.getSdkInstallDirField().getText())) {
        result.add(new SimpleValidationMessage(SDK_INSTALL_DIR + " must not be blank.", Severity.ERROR,
                SDK_INSTALL_DIR));
    } else {
        File file = new File(this.getSdkInstallDirField().getText());
        if (!file.exists()) {
            result.add(new SimpleValidationMessage(SDK_INSTALL_DIR
                    + " does not exist.  Please select the Home directory of an existing SDK Installation.",
                    Severity.ERROR, SDK_INSTALL_DIR));
        }
    }

    if (ValidationUtils.isNotBlank(this.getProjectDirField().getText())
            && ValidationUtils.isNotBlank(this.getSdkInstallDirField().getText())
            && this.getProjectDirField().getText().equalsIgnoreCase(this.getSdkInstallDirField().getText())) {
        result.add(new SimpleValidationMessage(PROJECT_DIR + " and " + SDK_INSTALL_DIR + " must be different.",
                Severity.ERROR, PROJECT_DIR));
        result.add(new SimpleValidationMessage(PROJECT_DIR + " and " + SDK_INSTALL_DIR + " must be different.",
                Severity.ERROR, SDK_INSTALL_DIR));
    }

    if (ValidationUtils.isBlank(this.getProjectNameField().getText())) {
        result.add(new SimpleValidationMessage(PROJECT_NAME + " must not be blank.", Severity.ERROR,
                PROJECT_NAME));
    }

    if (ValidationUtils.isBlank(this.getNamespacePrefixField().getText())) {
        result.add(new SimpleValidationMessage(NAMESPACE_PREFIX + " must not be blank.", Severity.ERROR,
                NAMESPACE_PREFIX));
    }

    if (ValidationUtils.isBlank(this.getWebServiceNameField().getText())) {
        result.add(new SimpleValidationMessage(WEBSERVICE_NAME + " must not be blank.", Severity.ERROR,
                WEBSERVICE_NAME));
    }

    return result;
}

From source file:gov.nih.nci.cacore.workbench.portal.panel.RemoteSshSettingsPanel.java

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    if (parentContainer.isRemoteDeployment()) {

        if (ValidationUtils.isBlank(this.getSshServerUsernameField().getText())) {
            result.add(new SimpleValidationMessage(SSH_SERVER_USERNAME + " must not be blank.", Severity.ERROR,
                    SSH_SERVER_USERNAME));
        }//from   w  ww . java 2  s .c om

        if (ValidationUtils.isBlank(this.getSshServerHostnameField().getText())) {
            result.add(new SimpleValidationMessage(SSH_SERVER_HOSTNAME + " must not be blank.", Severity.ERROR,
                    SSH_SERVER_HOSTNAME));
        }

        String sshPort = getSshPortField().getText();
        if (ValidationUtils.isBlank(this.getSshPortField().getText())) {
            result.add(new SimpleValidationMessage(SSH_PORT + " must not be blank.", Severity.ERROR, SSH_PORT));
        }

        if (!ValidationUtils.isNumeric(sshPort)) {
            result.add(new SimpleValidationMessage(SSH_PORT + " must be numeric.", Severity.ERROR, SSH_PORT));
        }

        if (ValidationUtils.isBlank(this.getSshKeyFileField().getText())) {
            result.add(new SimpleValidationMessage(SSH_KEY_FILE + " must not be blank.", Severity.ERROR,
                    SSH_KEY_FILE));
        } else {
            File file = new File(this.getSshKeyFileField().getText());
            if (!file.exists()) {
                result.add(new SimpleValidationMessage(
                        SSH_KEY_FILE
                                + " does not exist.  Please select or enter a valid absolute path to the file.",
                        Severity.ERROR, SSH_KEY_FILE));
            }
        }

        if (ValidationUtils.isBlank(this.getSshTempDirField().getText())) {
            result.add(new SimpleValidationMessage(SSH_TEMP_DIR + " must not be blank.", Severity.ERROR,
                    SSH_TEMP_DIR));
        } else {
            // Cannot validate if it is a valid directory as it is remote.
            //             File file = new File(this.getSshTempDirField().getText());
            //             if(!file.exists()){
            //                result.add(new SimpleValidationMessage(SSH_TEMP_DIR + " does not exist.  Please select or enter a valid absolute path to the directory.", Severity.ERROR, SSH_TEMP_DIR));
            //             }
        }
    }

    return result;
}

From source file:gov.nih.nci.cacore.workbench.portal.panel.SdkInstallSettingsPanel.java

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Sdk Install Panel Settings Validation

    if (ValidationUtils.isBlank(this.getSdkInstallDirField().getText())) {
        result.add(new SimpleValidationMessage(SDK_INSTALL_DIR + " must not be blank.", Severity.ERROR,
                SDK_INSTALL_DIR));/*from  w  ww.j a v a 2 s.com*/
    } else {
        File file = new File(this.getSdkInstallDirField().getText());
        if (!file.exists()) {
            result.add(new SimpleValidationMessage(SDK_INSTALL_DIR
                    + " does not exist.  Please select the Home directory of an existing SDK Installation.",
                    Severity.ERROR, SDK_INSTALL_DIR));
        }
    }

    return result;
}

From source file:gov.nih.nci.cacore.workbench.portal.panel.SecuritySettingsPanel.java

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Security setting Validation
    if (getEnableSecurityCheckBox().isSelected()) {

        if (ValidationUtils.isBlank(this.getCsmProjectNameField().getText())) {
            result.add(new SimpleValidationMessage(CSM_PROJECT_NAME + " must not be blank.", Severity.ERROR,
                    CSM_PROJECT_NAME));/*from  ww  w  .j  a  va2s.c o  m*/
        }

        //caGrid Auth Setting Validation
        if (getEnableCaGridLoginModuleCheckBox().isSelected()) {

            if (ValidationUtils.isBlank(this.getCaGridLoginModuleNameField().getText())) {
                result.add(new SimpleValidationMessage(CAGRID_LOGIN_MODULE_NAME + " must not be blank.",
                        Severity.ERROR, CAGRID_LOGIN_MODULE_NAME));
            }

            if (ValidationUtils.isBlank(this.getSdkGridLoginSvcNameField().getText())) {
                result.add(new SimpleValidationMessage(SDK_GRID_LOGIN_SERVICE_NAME + " must not be blank.",
                        Severity.ERROR, SDK_GRID_LOGIN_SERVICE_NAME));
            }
        }
    }

    return result;
}

From source file:gov.nih.nci.cacore.workbench.portal.panel.WritableApiSettingsPanel.java

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Writable API Settings Validation
    if (getEnableWritableApiExtensionCheckBox().isSelected()) {

        if (ValidationUtils.isBlank(this.getIdentityGeneratorTagField().getText())) {
            result.add(new SimpleValidationMessage(IDENTITY_GENERATOR_TAG + " must not be blank.",
                    Severity.ERROR, IDENTITY_GENERATOR_TAG));
        }//from  www .ja  v a  2s  .c o m

        if (getEnableCommonLoggingModuleCheckBox().isSelected()) {
            if (ValidationUtils.isBlank(this.getClmProjectNameField().getText())) {
                result.add(new SimpleValidationMessage(CLM_PROJECT_NAME + " must not be blank.", Severity.ERROR,
                        CLM_PROJECT_NAME));
            }
        }
    }

    return result;
}

From source file:gov.nih.nci.cacore.workbench.portal.validation.CodegenPropertiesValidator.java

License:BSD License

public void validateInput() {

    ValidationResult result = new ValidationResult();

    for (PanelValidator panelValidator : parentContainer.getPanelValidators()) {
        result.addAllFrom(panelValidator.validateInput());
    }/*from   w w  w .ja v a2 s.c om*/

    parentContainer.getValidationModel().setResult(result);

    parentContainer.toggleSaveButton();
    parentContainer.togglePreviousButton();
    parentContainer.toggleNextButton();
    parentContainer.toggleGenerateButton();

    parentContainer.togglePanels();

    parentContainer.updateGenerateApplicationTabContents();

    parentContainer.updateComponentTreeSeverity();

}

From source file:gov.nih.nci.cacore.workbench.portal.validation.DeploymentPropertiesValidator.java

License:BSD License

public void validateInput() {

    ValidationResult result = new ValidationResult();

    for (PanelValidator panelValidator : parentContainer.getPanelValidators()) {
        result.addAllFrom(panelValidator.validateInput());
    }//  www . ja v a  2s.co  m

    parentContainer.getValidationModel().setResult(result);

    parentContainer.toggleWritableApiFields();
    parentContainer.toggleSecurityFields();
    parentContainer.toggleRemoteSshFields();

    parentContainer.toggleTestConnectionButton();
    parentContainer.toggleClmTestConnectionButton();
    parentContainer.toggleCsmTestConnectionButton();
    parentContainer.toggleDbJndiNameField();
    parentContainer.toggleCsmDbJndiNameField();

    parentContainer.toggleSaveButton();
    parentContainer.togglePreviousButton();
    parentContainer.toggleNextButton();
    parentContainer.toggleDeployButton();

    parentContainer.togglePanels();

    parentContainer.updateDeployApplicationTabContents();

    parentContainer.updateComponentTreeSeverity();

}

From source file:org.archiviststoolkit.dialog.BatchLocationValidator.java

License:Open Source License

public ValidationResult validate() {

    ValidationResult result = new ValidationResult();

    if (!checkForMinimumRequirements())
        result.addError("Building and Coordinate1 are mandatory");

    if (dialog.getRepository() == null)
        result.addError("Repository is mandatory");

    ATFieldInfo field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_BUILDING);
    if (!ValidationUtils.hasMaximumLength(dialog.getBuilding(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }//from   w ww .j a v  a 2  s.co m

    field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_FLOOR);
    if (!ValidationUtils.hasMaximumLength(dialog.getFloor(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }

    field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_ROOM);
    if (!ValidationUtils.hasMaximumLength(dialog.getRoom(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }

    field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_AREA);
    if (!ValidationUtils.hasMaximumLength(dialog.getArea(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }

    field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_COORDINATE_1_LABEL);
    if (!ValidationUtils.hasMaximumLength(dialog.getCoordinate1Label(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }

    field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_COORDINATE_2_LABEL);
    if (!ValidationUtils.hasMaximumLength(dialog.getCoordinate2Label(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }

    field = ATFieldInfo.getFieldInfo(Locations.class, Locations.PROPERTYNAME_COORDINATE_3_LABEL);
    if (!ValidationUtils.hasMaximumLength(dialog.getCoordinate3Label(), field.getStringLengthLimit())) {
        result.addError(field.getFieldName() + " has a maximum length of " + field.getStringLengthLimit()
                + " characters");
    }

    return result;
}

From source file:org.archiviststoolkit.editor.rde.RapidResourceComponentDataEntryValidator.java

License:Open Source License

public ValidationResult validate() {

    ValidationResult result = new ValidationResult();

    if (ATAbstractValidator.isFutureYear(dialog.getDateBegin())) {
        result.addError("Date Begin can't be in the future");
    }//w  ww. j a  va 2s. c o  m
    if (ATAbstractValidator.isFutureYear(dialog.getDateEnd())) {
        result.addError("End Begin can't be in the future");
    }

    if (ValidationUtils.isBlank(dialog.getLevel()))
        result.addError("Level is mandatory");

    if (!checkForTitleOrDate())
        result.addError("Title or Date is mandatory");

    String container1Type = dialog.getContainer1Type();
    String container2Type = dialog.getContainer2Type();
    Double container1NumericValue = dialog.getContainer1NumericValue();
    String container1AlphaNumericValue = dialog.getContainer1AlphaNumericValue();
    Double container2NumericValue = dialog.getContainer2NumericValue();
    String container2AlphaNumericValue = dialog.getContainer2AlphaNumericValue();

    if (container2Type.length() > 0 && container1Type.length() == 0) {
        result.addError("You must enter container 1 if you enter container 2");
    }

    if (isValueEntered(container1NumericValue, container1AlphaNumericValue) && container1Type.length() == 0) {
        result.addError("You must enter container 1 type if you enter container 1 value");
    }

    if (isValueEntered(container2NumericValue, container2AlphaNumericValue) && container2Type.length() == 0) {
        result.addError("You must enter container 2 type if you enter container 2 value");
    }

    if (!isValueEntered(container1NumericValue, container1AlphaNumericValue) && container1Type.length() > 0) {
        result.addError("You must enter container 1 value if you enter container 1 type");
    }

    if (!isValueEntered(container2NumericValue, container2AlphaNumericValue) && container2Type.length() > 0) {
        result.addError("You must enter container 2 value if you enter container 2 type");
    }

    if (isValueEntered(container1NumericValue, container1AlphaNumericValue)
            && dialog.getInstanceType().length() == 0) {
        result.addError("You must enter an instance type when you enter container information");
    }
    return result;
}