Example usage for com.jgoodies.validation ValidationMessage key

List of usage examples for com.jgoodies.validation ValidationMessage key

Introduction

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

Prototype

Object key();

Source Link

Document

Returns this message's association key that can be used to model a loose coupling between validation messages and views that present the validated data.

Usage

From source file:gov.nih.nci.cacore.workbench.portal.viewer.CodegenPropertiesViewer.java

License:BSD License

public void toggleGenerateButton() {
    //if (this.validationModel.hasErrors() || (this.isDirty) || (mainTabbedPane.getSelectedIndex() != GENERATE_TAB_INDEX) ) {
    if (this.isDirty || (mainTabbedPane.getSelectedIndex() != GENERATE_TAB_INDEX) || (!this.isPropsLoaded)) {
        log.debug("Generate Button is disabled; required conditions have not been met");
        generateButton.setEnabled(false);
    } else {//  www. ja v a 2  s.co m
        log.debug("* * * Validation model has errors? " + this.validationModel.hasErrors());
        if (this.validationModel.hasErrors()) {

            ValidationResult results = validationModel.getResult();
            List<com.jgoodies.validation.ValidationMessage> errors = results.getErrors();

            //debug error results
            for (ValidationMessage errorMessage : results.getErrors()) {
                log.debug("* * * * Validation Error Message key: " + errorMessage.key()
                        + "; Validation Error Message: " + errorMessage.formattedText());
            }

            if (errors != null && errors.size() == 1) {
                for (ValidationMessage errorMessage : results.getErrors()) {
                    if (((String) (errorMessage.key()))
                            .equalsIgnoreCase(CacoreWorkbenchConstants.LOG_FILE_VALIDATION_KEY)) {
                        log.debug("Generate Button is enabled; required conditions have been met");
                        generateButton.setEnabled(true);
                        return;
                    }
                }

            }
            log.debug("Generate Button is disabled; Validation errors have been found");
            generateButton.setEnabled(false);
            return;
        }

        log.debug("Generate Button is enabled; required conditions have been met");
        generateButton.setEnabled(true);

    }
}

From source file:gov.nih.nci.cacore.workbench.portal.viewer.DeployPropertiesViewer.java

License:BSD License

public void toggleDeployButton() {
    if ((this.isDirty) || (mainTabbedPane.getSelectedIndex() != DEPLOY_TAB_INDEX) || (!this.isPropsLoaded)) {

        log.debug("Deploy Button is disabled; here's why: ");
        log.debug("* * * Viewer is 'Dirty' (properties need to be saved)? " + this.isDirty);
        log.debug("* * * Not on Deploy Tab? " + (mainTabbedPane.getSelectedIndex() != DEPLOY_TAB_INDEX));

        if (mainTabbedPane.getSelectedIndex() != DEPLOY_TAB_INDEX)
            log.debug("* * * Tabbed Panel Index: " + mainTabbedPane.getSelectedIndex() + ";  DEPLOY_TAB_INDEX: "
                    + DEPLOY_TAB_INDEX);
        log.debug("* * * Have the properties been loaded? " + this.isPropsLoaded);

        deployButton.setEnabled(false);/*from www .  ja  va 2  s. co m*/
    } else {
        log.debug("* * * Validation model has errors? " + this.validationModel.hasErrors());
        if (this.validationModel.hasErrors()) {

            ValidationResult results = validationModel.getResult();
            List<com.jgoodies.validation.ValidationMessage> errors = results.getErrors();

            //debug error results
            for (ValidationMessage errorMessage : results.getErrors()) {
                log.debug("* * * * Validation Error Message key: " + errorMessage.key()
                        + "; Validation Error Message: " + errorMessage.formattedText());
            }

            if (errors != null && errors.size() == 1) {
                for (ValidationMessage errorMessage : results.getErrors()) {
                    if (((String) (errorMessage.key()))
                            .equalsIgnoreCase(CacoreWorkbenchConstants.LOG_FILE_VALIDATION_KEY)) {
                        log.debug("Deploy Button is enabled; required conditions have been met");
                        deployButton.setEnabled(true);
                        return;
                    }
                }

            }
            deployButton.setEnabled(false);
            return;
        }

        log.debug("Deploy Button is enabled; required conditions have been met");
        deployButton.setEnabled(true);
    }
}