Example usage for com.jgoodies.validation Severity ERROR

List of usage examples for com.jgoodies.validation Severity ERROR

Introduction

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

Prototype

Severity ERROR

To view the source code for com.jgoodies.validation Severity ERROR.

Click Source Link

Document

Indicates a problem that cannot be resumed or worked around.

Usage

From source file:com.aw.swing.mvp.ui.painter.ErrorBorderPainter.java

License:Open Source License

private JComponent createFeedbackComponent() {
    Icon icon = ValidationResultViewFactory.getSmallIcon(Severity.ERROR);
    JLabel label = new JLabel(icon);
    label.setToolTipText("Fail");
    label.setSize(label.getPreferredSize());
    return label;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Advanced Settings components
    if (ValidationUtils.isBlank(this.getAppBasePathLinuxField().getText())) {
        result.add(new SimpleValidationMessage(APP_BASE_PATH_LINUX + " must not be blank.", Severity.ERROR,
                APP_BASE_PATH_LINUX));/*from  ww  w  . j a va2s.  co m*/
    }

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

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

    return result;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    // Turns out that the External Server HTTP URL is not a required field
    //      if (ValidationUtils.isBlank(getExternalServerHttpUrlField().getText())) {
    //         result.add(new SimpleValidationMessage(SERVER_HTTP_URL + " must not be blank.", Severity.ERROR, SERVER_HTTP_URL));
    //      } //from   w w  w  .  j  a  v a  2s .  c o  m

    String serverType = getServerType();
    if (ValidationUtils.isBlank(serverType)) {
        result.add(
                new SimpleValidationMessage(SERVER_TYPE + " must not be blank.", Severity.ERROR, SERVER_TYPE));
    }

    //Tomcat Server Components
    if (serverType.equalsIgnoreCase(TOMCAT)) {

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

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

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

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

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

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

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

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

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

    } else if (serverType.equalsIgnoreCase(JBOSS)) {

        if (ValidationUtils.isBlank(this.getJbossPortNameComboBox().getSelectedItem().toString())) {
            result.add(new SimpleValidationMessage(JBOSS_PORT_NAME + " must not be blank.", Severity.ERROR,
                    JBOSS_PORT_NAME));
        }

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

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

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

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

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

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

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

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

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

    return result;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //Security setting Validation
    if (isSecurityEnabled && isCaGridLoginModuleEnabled) {

        //caGrid Authentication Setting Validation      
        if (getCaGridTargetGridComboBox().getSelectedItem().toString() == "") {
            result.add(new SimpleValidationMessage(TARGET_GRID + " must be selected.", Severity.ERROR,
                    TARGET_GRID));//  www  .  j  a v  a  2  s.c  o  m
        }

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

            if (!this.getGridSecureCertFileField().getText().endsWith("pem")) {
                result.add(new SimpleValidationMessage(
                        GRID_SECURE_CERT_FILE + " must refer to a Certificate (*.pem) file.", Severity.ERROR,
                        GRID_SECURE_CERT_FILE));
            }
        }

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

            if (!this.getGridSecureKeyFileField().getText().endsWith("pem")) {
                result.add(new SimpleValidationMessage(
                        GRID_SECURE_KEY_FILE + " must refer to a Certificate (*.pem) file.", Severity.ERROR,
                        GRID_SECURE_KEY_FILE));
            }
        }

    }

    return result;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    //CLM Settings Validation
    if (parentContainer.isClmEnabled()) {

        String clmDbConnectionUrlField = this.getClmDbConnectionUrlField().getText();
        if (ValidationUtils.isBlank(clmDbConnectionUrlField)) {
            result.add(new SimpleValidationMessage(CLM_DB_CONNECTION_URL + " must not be blank.",
                    Severity.ERROR, CLM_DB_CONNECTION_URL));
        }//  w  w  w .j  a  v a  2 s .co  m

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

        String clmDbPort = getClmDbPortField().getText();
        if (ValidationUtils.isBlank(clmDbPort)) {
            result.add(new SimpleValidationMessage(CLM_DB_SERVER_PORT + " must not be blank.", Severity.ERROR,
                    CLM_DB_SERVER_PORT));
        }

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

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

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

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

        if (getClmDbDropSchemaCheckBox().isSelected() && !parentContainer.isAppDbAndClmSchemaSame()) {
            if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) {
                result.add(new SimpleValidationMessage(
                        CLM_DB_SQL_FILE + " must not be blank when " + CLM_DB_DROP_SCHEMA + " is selected.",
                        Severity.ERROR, CLM_DB_SQL_FILE));
            }
        }

        if (getClmDbDropSchemaCheckBox().isSelected() && !parentContainer.isCsmDbAndClmSchemaSame()) {
            if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) {
                result.add(new SimpleValidationMessage(
                        CLM_DB_SQL_FILE + " must not be blank when " + CLM_DB_DROP_SCHEMA + " is selected.",
                        Severity.ERROR, CLM_DB_SQL_FILE));
            }
        }

        String clmDbSchema = getClmDbSchemaField().getText();
        if (ValidationUtils.isNotBlank(clmDbSchema) && parentContainer.isAppDbAndClmSchemaSame()
                && parentContainer.isAppDbDropSchemaSelected()) {
            //TODO :: investigate if there is a way to visually signal that a CheckBox has a validation error.
            //        Currently, creating a validation error for the CheckBox has no effect.  As a result,
            //        using toggleReCreateClmDBFields() instead to enforce rule
            //           if (getClmDbDropSchemaCheckBox().isSelected()){
            //           log.debug("* * * Validation error: App DB and CLM Schema are the same, and CLM Drop Schema CheckBox is selected.");
            //           result.add(new SimpleValidationMessage(CLM_DB_DROP_SCHEMA + " must not selected when both the App DB and CLM schema are the same.", Severity.ERROR, CLM_DB_DROP_SCHEMA));
            //           }

            if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) {
                result.add(new SimpleValidationMessage(CLM_DB_SQL_FILE
                        + " must not be blank when the application DB is being dropped, and both the App DB and CLM DB schema are the same.",
                        Severity.ERROR, CLM_DB_SQL_FILE));
            }
        }

        if (ValidationUtils.isNotBlank(clmDbSchema) && parentContainer.isCsmDbAndClmSchemaSame()
                && parentContainer.isCsmDbDropSchemaSelected()) {
            //TODO :: investigate if there is a way to visually signal that a CheckBox has a validation error.
            //        Currently, creating a validation error for the CheckBox has no effect.  As a result,
            //        using toggleReCreateClmDBFields() instead to enforce rule
            //           if (getClmDbDropSchemaCheckBox().isSelected()){
            //           log.debug("* * * Validation error: App DB and CLM Schema are the same, and CLM Drop Schema CheckBox is selected.");
            //           result.add(new SimpleValidationMessage(CLM_DB_DROP_SCHEMA + " must not selected when both the App DB and CLM schema are the same.", Severity.ERROR, CLM_DB_DROP_SCHEMA));
            //           }

            if (ValidationUtils.isBlank(this.getClmDbSqlFileField().getText())) {
                result.add(new SimpleValidationMessage(CLM_DB_SQL_FILE
                        + " must not be blank when the CSM DB is being dropped, and both the CSM DB and CLM DB schema are the same.",
                        Severity.ERROR, CLM_DB_SQL_FILE));
            }
        }

        if (ValidationUtils.isNotBlank(this.getClmDbSqlFileField().getText())) {
            File file = new File(this.getClmDbSqlFileField().getText());
            if (!file.exists()) {
                result.add(new SimpleValidationMessage(
                        CLM_DB_SQL_FILE
                                + " does not exist.  Please select or enter a valid absolute path to the file.",
                        Severity.ERROR, CLM_DB_SQL_FILE));
            }

            if (!this.getClmDbSqlFileField().getText().endsWith("sql")) {
                result.add(new SimpleValidationMessage(CLM_DB_SQL_FILE + " must refer to a SQL (*.sql) file.",
                        Severity.ERROR, CLM_DB_SQL_FILE));
            }
        }
    }

    return result;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = new ValidationResult();

    if (getGenerateXsdWithPermissibleValuesCheckBox().isSelected()
            || getGenerateHibernateValidatorCheckBox().isSelected()) {
        if (ValidationUtils.isBlank(this.getCaDsrConnectionUrlField().getText())) {
            result.add(new SimpleValidationMessage(CADSR_CONNECTION_URL + " must not be blank.", Severity.ERROR,
                    CADSR_CONNECTION_URL));
        }//from   ww w  .ja  v  a 2s  . co m
    }

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

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

    return result;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = validateDbConnectionInput();

    if (isEnableSecuritySelected) {

        if (!getCsmUseDbConnectionSettingsCheckBox().isSelected()
                && getCsmUseJndiBasedConnectionCheckBox().isSelected()) {
            if (ValidationUtils.isBlank(this.getCsmDbJndiNameField().getText())) {
                result.add(new SimpleValidationMessage(CSM_JNDI_NAME + " must not be blank.", Severity.ERROR,
                        CSM_JNDI_NAME));
            }//from w  w  w.  j  a  v a2  s . c  o  m
        }

        if (getCsmDbDropSchemaCheckBox().isSelected() && !parentContainer.isAppDbAndCsmSchemaSame()) {
            if (ValidationUtils.isBlank(this.getCsmDbSqlFileField().getText())) {
                result.add(new SimpleValidationMessage(
                        CSM_DB_SQL_FILE + " must not be blank when " + CSM_DB_DROP_SCHEMA + " is selected.",
                        Severity.ERROR, CSM_DB_SQL_FILE));
            }
        }

        String csmDbSchema = getCsmDbSchemaField().getText();
        if (ValidationUtils.isNotBlank(csmDbSchema) && parentContainer.isAppDbAndCsmSchemaSame()
                && parentContainer.isAppDbDropSchemaSelected()) {
            //TODO :: investigate if there is a way to visually signal that a CheckBox has a validation error.
            //        Currently, creating a validation error for the CheckBox has no effect.  As a result,
            //        using toggleReCreateCsmDBFields() instead to enforce rule
            //             if (getCsmDbDropSchemaCheckBox().isSelected()){
            //                log.debug("* * * Validation error: App DB and CSM are the same, and CSM Drop Schema CheckBox is selected.");
            //                result.add(new SimpleValidationMessage(CSM_DB_DROP_SCHEMA + " must not selected when both the App DB and CSM schema are the same.", Severity.ERROR, CSM_DB_DROP_SCHEMA));
            //             }

            if (ValidationUtils.isBlank(this.getCsmDbSqlFileField().getText())) {
                result.add(new SimpleValidationMessage(CSM_DB_SQL_FILE
                        + " must not be blank when the application DB is being dropped, and both the App DB and CSM DB schema are the same.",
                        Severity.ERROR, CSM_DB_SQL_FILE));
            }
        }

        if (ValidationUtils.isNotBlank(this.getCsmDbSqlFileField().getText())) {
            File file = new File(this.getCsmDbSqlFileField().getText());
            if (!file.exists()) {
                result.add(new SimpleValidationMessage(
                        CSM_DB_SQL_FILE
                                + " does not exist.  Please select or enter a valid absolute path to the file.",
                        Severity.ERROR, CSM_DB_SQL_FILE));
            }

            if (!this.getCsmDbSqlFileField().getText().endsWith("sql")) {
                result.add(new SimpleValidationMessage(CSM_DB_SQL_FILE + " must refer to a SQL (*.sql) file.",
                        Severity.ERROR, CSM_DB_SQL_FILE));
            }
        }
    }

    return result;
}

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

License:BSD License

public ValidationResult validateDbConnectionInput() {

    ValidationResult result = new ValidationResult();

    if (isEnableSecuritySelected && !getCsmUseDbConnectionSettingsCheckBox().isSelected()) {

        if (ValidationUtils.isBlank(getCsmDbHostnameField().getText())) {
            result.add(new SimpleValidationMessage(CSM_DB_SERVER + " must not be blank.", Severity.ERROR,
                    CSM_DB_SERVER));/* www.  j  a v  a  2 s .  com*/
        }

        String csmDbPort = getCsmDbPortField().getText();
        if (ValidationUtils.isBlank(csmDbPort)) {
            result.add(new SimpleValidationMessage(CSM_DB_SERVER_PORT + " must not be blank.", Severity.ERROR,
                    CSM_DB_SERVER_PORT));
        }

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

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

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

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

    return result;
}

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

License:BSD License

public ValidationResult validateInput() {

    ValidationResult result = validateDbConnectionInput();

    if (getUseJndiBasedConnectionCheckBox().isSelected()) {
        if (ValidationUtils.isBlank(this.getDbJndiNameField().getText())) {
            result.add(new SimpleValidationMessage(DB_JNDI_NAME + " must not be blank.", Severity.ERROR,
                    DB_JNDI_NAME));/*from ww  w .  ja  va 2s. co m*/
        }
    }

    if (getDbDropSchemaCheckBox().isSelected()) {
        if (ValidationUtils.isBlank(this.getDbSqlFileField().getText())) {
            result.add(new SimpleValidationMessage(
                    DB_SQL_FILE + " must not be blank when " + DB_DROP_SCHEMA + " is selected.", Severity.ERROR,
                    DB_SQL_FILE));
        }
    }

    if (ValidationUtils.isNotBlank(this.getDbSqlFileField().getText())) {
        File file = new File(this.getDbSqlFileField().getText());
        if (!file.exists()) {
            result.add(new SimpleValidationMessage(
                    DB_SQL_FILE + " does not exist.  Please select or enter a valid absolute path to the file.",
                    Severity.ERROR, DB_SQL_FILE));
        }

        if (!this.getDbSqlFileField().getText().endsWith("sql")) {
            result.add(new SimpleValidationMessage(DB_SQL_FILE + " must refer to a SQL (*.sql) file.",
                    Severity.ERROR, DB_SQL_FILE));
        }
    }

    return result;
}

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

License:BSD License

public ValidationResult validateDbConnectionInput() {

    ValidationResult result = new ValidationResult();

    //DB Connection Settings Validation
    if (ValidationUtils.isBlank(getDbHostnameField().getText())) {
        result.add(new SimpleValidationMessage(DB_SERVER + " must not be blank.", Severity.ERROR, DB_SERVER));
    }/* w  ww. j a v  a 2s. co  m*/

    String dbPort = getDbPortField().getText();
    if (ValidationUtils.isBlank(dbPort)) {
        result.add(new SimpleValidationMessage(DB_SERVER_PORT + " must not be blank.", Severity.ERROR,
                DB_SERVER_PORT));
    }

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

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

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

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

    return result;
}