Search in sources :

Example 1 with ValidationResult

use of org.apache.netbeans.modules.python4nb.util.ValidationResult in project python4nb by ebresie.

the class PythonOptionsPanelController method isValid.

@Override
public boolean isValid() {
    assert EventQueue.isDispatchThread();
    PythonOptionsPanel panel = getPanel();
    ValidationResult result = new PythonOptionsValidator().validatePython(panel.getPython(), panel.getPythonSources()).validatePip(panel.getPip()).getResult();
    // errors
    if (result.hasErrors()) {
        panel.setError(result.getFirstErrorMessage());
        return false;
    }
    // warnings
    if (result.hasWarnings()) {
        panel.setWarning(result.getFirstWarningMessage());
        return true;
    }
    // everything ok
    // NOI18N
    panel.setError(" ");
    return true;
}
Also used : PythonOptionsValidator(org.apache.netbeans.modules.python4nb.editor.options.PythonOptionsValidator) ValidationResult(org.apache.netbeans.modules.python4nb.util.ValidationResult)

Example 2 with ValidationResult

use of org.apache.netbeans.modules.python4nb.util.ValidationResult in project python4nb by ebresie.

the class PythonExecutable method forPath.

@CheckForNull
public static PythonExecutable forPath(String path) {
    ValidationResult result = new ValidationResult();
    ValidationUtils.validatePython(result, path);
    ;
    if (validateResult(result) != null) {
        return null;
    }
    return createExecutable(path, null);
}
Also used : ValidationResult(org.apache.netbeans.modules.python4nb.util.ValidationResult) CheckForNull(org.netbeans.api.annotations.common.CheckForNull)

Example 3 with ValidationResult

use of org.apache.netbeans.modules.python4nb.util.ValidationResult 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 4 with ValidationResult

use of org.apache.netbeans.modules.python4nb.util.ValidationResult 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

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