Java Code Examples for org.netbeans.modules.php.api.util.FileUtils#validateDirectory()

The following examples show how to use org.netbeans.modules.php.api.util.FileUtils#validateDirectory() . 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: PhpDocPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public String getErrorMessage() {
    String phpDocTarget = getPhpDocTarget();
    if (StringUtils.hasText(phpDocTarget)) {
        String error = FileUtils.validateDirectory(phpDocTarget, true);
        if (error != null) {
            return error;
        }
    }
    if (!StringUtils.hasText(getPhpDocTitle())) {
        return NbBundle.getMessage(PhpDocPanel.class, "MSG_InvalidTitle");
    }
    return null;
}
 
Example 2
Source File: RunConfigScriptValidator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("RunConfigScriptValidator.workDir.label=Working directory")
static String validateWorkDir(String workDir, boolean allowEmptyString) {
    boolean hasText = StringUtils.hasText(workDir);
    if (allowEmptyString && !hasText) {
        return null;
    }
    return FileUtils.validateDirectory(Bundle.RunConfigScriptValidator_workDir_label(), workDir, false);
}
 
Example 3
Source File: TesterUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("TesterUtils.php.ini.error=Absolute path to file or directory must be set for php.ini.")
@CheckForNull
public static String validatePhpIniPath(@NullAllowed String phpIniPath) {
    if (FileUtils.validateDirectory(phpIniPath, false) != null
            && FileUtils.validateFile(phpIniPath, false) != null) {
        return Bundle.TesterUtils_php_ini_error();
    }
    return null;
}
 
Example 4
Source File: TesterUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages("TesterUtils.coverage.source.path.error=Absolute path to directory must be set for coverage source path.")
@CheckForNull
public static String validateCoverageSourcePath(@NullAllowed String sourcePath) {
    if (FileUtils.validateDirectory(sourcePath, false) != null) {
        return Bundle.TesterUtils_coverage_source_path_error();
    }
    return null;
}
 
Example 5
Source File: Nette2OptionsPanelController.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "Nette2ValidationDirectory=Nette2 Directory",
    "# {0} - File in a root of Nette sources directory",
    "Nette2DirectoryValidationWarning=Nette2 Directory does not contain {0} file."
})
public static String validateNetteDirectory(String netteDirectory) {
    String result = FileUtils.validateDirectory(Bundle.Nette2ValidationDirectory(), netteDirectory, false);
    if (result == null) {
        File loaderPhp = new File(netteDirectory, LOADER_FILE);
        if (!loaderPhp.exists() || loaderPhp.isDirectory()) {
            result = Bundle.Nette2DirectoryValidationWarning(LOADER_FILE);
        }
    }
    return result;
}
 
Example 6
Source File: ApiGenPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages({
    "ApiGenPanel.error.relativeTarget=Absolute path for target directory must be provided.",
    "ApiGenPanel.error.invalidTitle=Title must be provided.",
    "ApiGenPanel.error.invalidCharsets=Charsets must be provided.",
    "ApiGenPanel.error.invalidAccessLevels=Access levels must be provided.",
    "ApiGenPanel.warn.nbWillAskForDir=NetBeans will ask for the directory before generating documentation.",
    "ApiGenPanel.warn.targetDirWillBeCreated=Target directory will be created.",
    "# {0} - encoding",
    "ApiGenPanel.warn.missingCharset=Project encoding ''{0}'' nout found within specified charsets."
})
private String validateManualConfig(boolean forErrors) {
    String target = getTarget();
    if (forErrors) {
        // errors
        // target
        if (StringUtils.hasText(target)) {
            File targetDir = new File(target);
            if (targetDir.exists()) {
                return FileUtils.validateDirectory(target, true);
            } else {
                if (!targetDir.isAbsolute()) {
                    return Bundle.ApiGenPanel_error_relativeTarget();
                }
            }
        }
        // title
        if (!StringUtils.hasText(getTitle())) {
            return Bundle.ApiGenPanel_error_invalidTitle();
        }
        // charsets
        if (getCharsets().isEmpty()) {
            return Bundle.ApiGenPanel_error_invalidCharsets();
        }
        // access levels
        if (!accessLevelPublicCheckBox.isSelected()
                && !accessLevelProtectedCheckBox.isSelected()
                && !accessLevelPrivateCheckBox.isSelected()) {
            return Bundle.ApiGenPanel_error_invalidAccessLevels();
        }
        return null;
    }
    // warnings
    // charsets
    String defaultCharset = ApiGenPreferences.CHARSETS.getDefaultValue(phpModule);
    if (getCharsets().indexOf(defaultCharset) == -1) {
        return Bundle.ApiGenPanel_warn_missingCharset(defaultCharset);
    }
    // target
    if (!StringUtils.hasText(target)) {
        return Bundle.ApiGenPanel_warn_nbWillAskForDir();
    }
    if (!new File(target).exists()) {
        return Bundle.ApiGenPanel_warn_targetDirWillBeCreated();
    }
    return null;
}
 
Example 7
Source File: Nette2OptionsPanelController.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@NbBundle.Messages("Nette2ValidationSandbox=Nette2 Sandbox")
public static String validateSandbox(String sandbox) {
    return FileUtils.validateDirectory(Bundle.Nette2ValidationSandbox(), sandbox, false);
}