Search in sources :

Example 1 with PythonPreferencesValidator

use of org.apache.netbeans.modules.python4nb.preferences.PythonPreferencesValidator in project python4nb by ebresie.

the class PythonCustomizerPanel method validateData.

void validateData() {
    ValidationResult result = new PythonPreferencesValidator().validateCustomizer(pythonEnabled, defaultPython, python, pythonPathPanel.getPythonSources(), debugPort).getResult();
    if (result.hasErrors()) {
        category.setErrorMessage(result.getFirstErrorMessage());
        category.setValid(false);
        return;
    }
    if (result.hasWarnings()) {
        category.setErrorMessage(result.getFirstWarningMessage());
        category.setValid(true);
        return;
    }
    category.setErrorMessage(null);
    category.setValid(true);
}
Also used : PythonPreferencesValidator(org.apache.netbeans.modules.python4nb.preferences.PythonPreferencesValidator) ValidationResult(org.apache.netbeans.modules.python4nb.util.ValidationResult)

Example 2 with PythonPreferencesValidator

use of org.apache.netbeans.modules.python4nb.preferences.PythonPreferencesValidator in project python4nb by ebresie.

the class PythonExecutable method forProjectInternal.

@CheckForNull
private static PythonExecutable forProjectInternal(@NullAllowed Project project, boolean showCustomizer) {
    if (project == null) {
        return getDefault(null, showCustomizer);
    }
    PythonPreferences preferences = PythonSupport.forProject(project).getPreferences();
    if (preferences.isDefaultPython()) {
        return getDefault(project, showCustomizer);
    }
    String node = preferences.getPython();
    ValidationResult result = new PythonPreferencesValidator().validateNode(node).getResult();
    if (validateResult(result) != null) {
        if (showCustomizer) {
            PythonCustomizerProvider.openCustomizer(project, result);
        }
        return null;
    }
    assert node != null;
    return createExecutable(node, project);
}
Also used : PythonPreferencesValidator(org.apache.netbeans.modules.python4nb.preferences.PythonPreferencesValidator) PythonPreferences(org.apache.netbeans.modules.python4nb.preferences.PythonPreferences) ValidationResult(org.apache.netbeans.modules.python4nb.util.ValidationResult) CheckForNull(org.netbeans.api.annotations.common.CheckForNull)

Aggregations

PythonPreferencesValidator (org.apache.netbeans.modules.python4nb.preferences.PythonPreferencesValidator)2 ValidationResult (org.apache.netbeans.modules.python4nb.util.ValidationResult)2 PythonPreferences (org.apache.netbeans.modules.python4nb.preferences.PythonPreferences)1 CheckForNull (org.netbeans.api.annotations.common.CheckForNull)1