com.wix.settings.Validator Java Examples

The following examples show how to use com.wix.settings.Validator. 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: RTSettingsPage.java    From react-templates-plugin with MIT License 6 votes vote down vote up
private void validate() {
        if (!pluginEnabledCheckbox.isSelected()) {
            return;
        }
        Validator validator = new Validator();
        validateField(validator, rtBinField, false, "Path to react-templates is invalid {{LINK}}");
        validateField(validator, nodeInterpreterField, false, "Path to node interpreter is invalid {{LINK}}");
//        if (!validateDirectory(customRulesPathField.getText(), true)) {
//            RTValidationInfo error = new RTValidationInfo(customRulesPathField, "Path to custom rules is invalid {{LINK}}", FIX_IT);
//            errors.add(error);
//        }
//        if (!validateDirectory(rulesPathField.getChildComponent().getText(), true)) {
//            RTValidationInfo error = new RTValidationInfo(rulesPathField.getChildComponent().getTextEditor(), "Path to rules is invalid {{LINK}}", FIX_IT);
//            errors.add(error);
//        }
        if (validator.isEmpty()) {
            getVersion();
        }
        packagesNotificationPanel.processErrors(validator);
    }
 
Example #2
Source File: RTSettingsPage.java    From react-templates-plugin with MIT License 6 votes vote down vote up
private void validate() {
        if (!pluginEnabledCheckbox.isSelected()) {
            return;
        }
        Validator validator = new Validator();
        validateField(validator, rtBinField, false, "Path to react-templates is invalid {{LINK}}");
        validateField(validator, nodeInterpreterField, false, "Path to node interpreter is invalid {{LINK}}");
//        if (!validateDirectory(customRulesPathField.getText(), true)) {
//            RTValidationInfo error = new RTValidationInfo(customRulesPathField, "Path to custom rules is invalid {{LINK}}", FIX_IT);
//            errors.add(error);
//        }
//        if (!validateDirectory(rulesPathField.getChildComponent().getText(), true)) {
//            RTValidationInfo error = new RTValidationInfo(rulesPathField.getChildComponent().getTextEditor(), "Path to rules is invalid {{LINK}}", FIX_IT);
//            errors.add(error);
//        }
        if (validator.isEmpty()) {
            getVersion();
        }
        packagesNotificationPanel.processErrors(validator);
    }
 
Example #3
Source File: ESLintSettingsPage.java    From eslint-plugin with MIT License 6 votes vote down vote up
private void validate() {
    if (!pluginEnabledCheckbox.isSelected()) {
        return;
    }
    Validator validator = new Validator();
    validateField(validator, eslintBinField2, false, "Path to eslint is invalid {{LINK}}");
    validateField(validator, eslintrcFile, true, "Path to eslintrc is invalid {{LINK}}"); //Please correct path to
    validateField(validator, nodeInterpreterField, false, "Path to node interpreter is invalid {{LINK}}");
    if (!validateDirectory(customRulesPathField.getText(), true)) {
        addError(validator, customRulesPathField, "Path to custom rules is invalid {{LINK}}", FIX_IT);
    }
    if (!validateDirectory(rulesPathField.getChildComponent().getText(), true)) {
        addError(validator, rulesPathField.getChildComponent().getTextEditor(), "Path to rules is invalid {{LINK}}", FIX_IT);
    }
    if (!validateExt(textFieldExt.getText())) {
        addError(validator, textFieldExt, "Extensions format is invalid, should be e.g. .js,.jsx without white space {{LINK}}", FIX_IT);
    }
    if (!validator.hasErrors() && !project.isDefault()) {
        getVersion();
    }
    packagesNotificationPanel.processErrors(validator);
}
 
Example #4
Source File: SassLintSettingsPage.java    From sass-lint-plugin with MIT License 5 votes vote down vote up
private void validate() {
    if (!pluginEnabledCheckbox.isSelected()) {
        return;
    }
    Validator validator = new Validator();
    validateField(validator, sasslintBinField, false, "Path to sass-lint is invalid {{LINK}}");
    validateField(validator, sassLintConfigFile, true, "Path to config file is invalid {{LINK}}"); //Please correct path to
    validateField(validator, nodeInterpreterField, false, "Path to node interpreter is invalid {{LINK}}");
    if (!validator.hasErrors()) {
        getVersion();
    }
    packagesNotificationPanel.processErrors(validator);
}
 
Example #5
Source File: SassLintSettingsPage.java    From sass-lint-plugin with MIT License 4 votes vote down vote up
private void validateField(Validator validator, TextFieldWithHistoryWithBrowseButton field, boolean allowEmpty, String message) {
    if (!ValidationUtils.validatePath(project, field.getChildComponent().getText(), allowEmpty)) {
        validator.add(field.getChildComponent().getTextEditor(), message, FIX_IT);
    }
}
 
Example #6
Source File: RTSettingsPage.java    From react-templates-plugin with MIT License 4 votes vote down vote up
private void validateField(Validator validator, TextFieldWithHistoryWithBrowseButton field, boolean allowEmpty, String message) {
    if (!ValidationUtils.validatePath(project, field.getChildComponent().getText(), allowEmpty)) {
        ValidationInfo error = new ValidationInfo(field.getChildComponent().getTextEditor(), message, FIX_IT);
        validator.errors.add(error);
    }
}
 
Example #7
Source File: RTSettingsPage.java    From react-templates-plugin with MIT License 4 votes vote down vote up
private void validateField(Validator validator, TextFieldWithHistoryWithBrowseButton field, boolean allowEmpty, String message) {
    if (!ValidationUtils.validatePath(project, field.getChildComponent().getText(), allowEmpty)) {
        ValidationInfo error = new ValidationInfo(field.getChildComponent().getTextEditor(), message, FIX_IT);
        validator.errors.add(error);
    }
}
 
Example #8
Source File: ESLintSettingsPage.java    From eslint-plugin with MIT License 4 votes vote down vote up
private void validateField(Validator validator, TextFieldWithHistoryWithBrowseButton field, boolean allowEmpty, String message) {
        if (!validatePath(field.getChildComponent().getText(), allowEmpty)) {
            validator.add(field.getChildComponent().getTextEditor(), message, FIX_IT);
//            addError(validator, field.getChildComponent().getTextEditor(), message, FIX_IT);
        }
    }
 
Example #9
Source File: ESLintSettingsPage.java    From eslint-plugin with MIT License 4 votes vote down vote up
private static void addError(Validator validator, @Nullable JTextComponent textComponent, @NotNull String errorHtmlDescriptionTemplate, @NotNull String linkText) {
        validator.add((JTextField) textComponent, errorHtmlDescriptionTemplate, linkText);
//        ValidationInfo error = new ValidationInfo(textComponent, errorHtmlDescriptionTemplate, linkText);
//        errors.add(error);
    }