Java Code Examples for org.netbeans.modules.php.api.util.StringUtils

The following examples show how to use org.netbeans.modules.php.api.util.StringUtils. These examples are extracted from open source projects. 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 Project: cakephp3-netbeans   Source File: TableVisitor.java    License: Apache License 2.0 6 votes vote down vote up
private void handleMethod(FunctionInvocation method) {
    String methodName = CodeUtils.extractFunctionName(method);
    if (StringUtils.isEmpty(methodName)) {
        return;
    }
    Assosiation assosiation = Assosiation.get(methodName);
    if (assosiation != Assosiation.UNKNOWN) {
        addTable(method);
    }

    switch (methodName) {
        case ADD_BEHABIOR_METHOD:
            addBehavior(method);
            break;
        default:
            break;
    }
}
 
Example 2
Source Project: netbeans   Source File: SymfonyScript.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void processLine(String line) {
    if (!StringUtils.hasText(line)) {
        prefix = null;
        return;
    }

    String trimmed = line.trim();
    Matcher prefixMatcher = PREFIX_PATTERN.matcher(trimmed);
    if (prefixMatcher.matches()) {
        prefix = prefixMatcher.group(1);
    }
    Matcher commandMatcher = COMMAND_PATTERN.matcher(trimmed);
    if (commandMatcher.matches()) {
        String command = commandMatcher.group(1);
        if (prefix != null) {
            command = prefix + ":" + command; // NOI18N
        }
        String description = commandMatcher.group(2);
        synchronized (commands) {
            commands.add(new SymfonyCommand(phpModule, command, description, command));
        }
    }
}
 
Example 3
Source Project: netbeans   Source File: SourceRoots.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Returns the display names of source roots.
 * The returned array has the same length as an array returned by the {@link #getRootProperties()}.
 * It may contain empty {@link String}s but not <code>null</code>.
 * @return an array of source roots names.
 */
@NbBundle.Messages({
    "# {0} - display name of the source root",
    "# {1} - directory of the source root",
    "SourceRoots.displayName={0} ({1})",
})
public String[] getRootNames() {
    String[] pureRootNames = getPureRootNames();
    if (pureRootNames.length == 0) {
        return new String[0];
    }
    String[] names = new String[pureRootNames.length];
    for (int i = 0; i < names.length; i++) {
        String pureName = pureRootNames[i];
        String name;
        if (StringUtils.hasText(pureName)) {
            name = Bundle.SourceRoots_displayName(displayName, pureName);
        } else {
            name = displayName;
        }
        names[i] = name;
    }
    return names;
}
 
Example 4
Source Project: netbeans   Source File: PHP5ErrorHandlerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("SE_After=after")
public String createAfterText() {
    String result;
    String afterText = null;
    if (isValuableToken(token)) {
        afterText = getTokenTextForm(token.sym) + " '" + String.valueOf(token.value) + "'";
    } else {
        if (!isNodeToken()) {
            String previousText = getTokenTextForm(token.sym);
            if (StringUtils.hasText(previousText)) {
                afterText = previousText.trim();
            }
        }
    }
    if (afterText == null) {
        result = ""; //NOI18N
    } else {
        result = "\n " + Bundle.SE_After() + ":\t" + afterText; //NOI18N
    }
    return result;
}
 
Example 5
Source Project: netbeans   Source File: RemoteUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sanitize upload directory, see issue #169793 for more information.
 * @param uploadDirectory upload directory to sanitize
 * @param allowEmpty <code>true</code> if the string can be empty
 * @return sanitized upload directory
 */
public static String sanitizeUploadDirectory(String uploadDirectory, boolean allowEmpty) {
    if (StringUtils.hasText(uploadDirectory)) {
        while (uploadDirectory.length() > 1
                && uploadDirectory.endsWith(TransferFile.REMOTE_PATH_SEPARATOR)) {
            uploadDirectory = uploadDirectory.substring(0, uploadDirectory.length() - 1);
        }
    } else if (!allowEmpty) {
        uploadDirectory = TransferFile.REMOTE_PATH_SEPARATOR;
    }
    if (allowEmpty
            && (uploadDirectory == null || TransferFile.REMOTE_PATH_SEPARATOR.equals(uploadDirectory))) {
        uploadDirectory = ""; // NOI18N
    }
    return uploadDirectory;
}
 
Example 6
Source Project: netbeans   Source File: RemoteUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Get parent path for the given path.
 * @param path file path
 * @return parent path or "/" for absolute top-level path
 * or {@code null} if parent path does not exist
 */
public static String getParentPath(String path) {
    if (path.equals(TransferFile.REMOTE_PATH_SEPARATOR)) {
        return null;
    }
    boolean absolute = path.startsWith(TransferFile.REMOTE_PATH_SEPARATOR);
    if (absolute) {
        path = path.substring(1);
    }
    String parent;
    List<String> parts = new ArrayList<>(StringUtils.explode(path, TransferFile.REMOTE_PATH_SEPARATOR));
    if (parts.size() <= 1) {
        return absolute ? TransferFile.REMOTE_PATH_SEPARATOR : null;
    }
    parts.remove(parts.size() - 1);
    parent = StringUtils.implode(parts, TransferFile.REMOTE_PATH_SEPARATOR);
    if (absolute) {
        return TransferFile.REMOTE_PATH_SEPARATOR + parent;
    }
    return parent;
}
 
Example 7
Source Project: netbeans   Source File: RemoteValidator.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "RemoteValidator.error.uploadDirectory.missing=Upload directory must be specified.",
    "# {0} - remote path separator",
    "RemoteValidator.error.uploadDirectory.start=Upload directory must start with \"{0}\".",
    "# {0} - invalid path separator",
    "RemoteValidator.error.uploadDirectory.content=Upload directory cannot contain \"{0}\"."
})
public static String validateUploadDirectory(String uploadDirectory) {
    if (!StringUtils.hasText(uploadDirectory)) {
        return Bundle.RemoteValidator_error_uploadDirectory_missing();
    } else if (!uploadDirectory.startsWith(TransferFile.REMOTE_PATH_SEPARATOR)) {
        return Bundle.RemoteValidator_error_uploadDirectory_start(TransferFile.REMOTE_PATH_SEPARATOR);
    } else if (uploadDirectory.contains(INVALID_SEPARATOR)) {
        return Bundle.RemoteValidator_error_uploadDirectory_content(INVALID_SEPARATOR);
    }
    return null;
}
 
Example 8
Source Project: netbeans   Source File: RunConfigLocalValidator.java    License: Apache License 2.0 6 votes vote down vote up
private static String validate(RunConfigLocal config, boolean validateIndex) {
    String error;
    error = RunConfigWebValidator.validateUrl(config.getUrl());
    if (error != null) {
        return error;
    }
    if (validateIndex) {
        String indexRelativePath = config.getIndexRelativePath();
        if (StringUtils.hasText(indexRelativePath)) {
            error = BaseRunConfigValidator.validateIndexFile(config.getIndexParentDir(), indexRelativePath);
            if (error != null) {
                return error;
            }
        }
    }
    return null;
}
 
Example 9
Source Project: netbeans   Source File: RunConfigInternalValidator.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages("RunConfigInternalValidator.router.label=Router")
private static String validate(RunConfigInternal config, boolean validateRouter) {
    String error;
    error = RemoteValidator.validateHost(config.getHostname());
    if (error != null) {
        return error;
    }
    error = RemoteValidator.validatePort(config.getPort());
    if (error != null) {
        return error;
    }
    if (validateRouter) {
        String routerRelativePath = config.getRouterRelativePath();
        if (StringUtils.hasText(routerRelativePath)) {
            error = BaseRunConfigValidator.validateRelativeFile(config.getWorkDir(), routerRelativePath, Bundle.RunConfigInternalValidator_router_label());
            if (error != null) {
                return error;
            }
        }
    }
    return null;
}
 
Example 10
Source Project: netbeans   Source File: RunConfigScript.java    License: Apache License 2.0 6 votes vote down vote up
public String getHint() {
    StringBuilder sb = new StringBuilder(100);
    sb.append(interpreter);
    if (StringUtils.hasText(options)) {
        sb.append(" "); // NOI18N
        sb.append(options);
    }
    if (StringUtils.hasText(indexRelativePath)) {
        sb.append(" "); // NOI18N
        sb.append(indexRelativePath);
    }
    if (StringUtils.hasText(arguments)) {
        sb.append(" "); // NOI18N
        sb.append(arguments);
    }
    return sb.toString();
}
 
Example 11
Source Project: cakephp3-netbeans   Source File: ControllerVisitor.java    License: Apache License 2.0 6 votes vote down vote up
private void addModel(FunctionInvocation method) {
    List<Expression> parameters = method.getParameters();
    String tableName = ""; // NOI18N
    for (Expression parameter : parameters) {
        if (parameter instanceof Scalar) {
            tableName = CakePHPCodeUtils.getStringValue(parameter);
        }
        // only the first parameter
        break;
    }
    if (!StringUtils.isEmpty(tableName)) {
        Pair<String, PhpClass> phpClass = createPhpClass(Category.TABLE, tableName, ""); // NOI18N
        if (phpClass != null) {
            addPhpClasss(Category.TABLE, phpClass);
        }
    }
}
 
Example 12
Source Project: netbeans   Source File: RunAsWebAdvanced.java    License: Apache License 2.0 6 votes vote down vote up
private Object[][] getPathMappings(String remotePaths, String localPaths) {
    List<String> remotes = StringUtils.explode(remotePaths, PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    List<String> locals = StringUtils.explode(localPaths, PhpProjectProperties.DEBUG_PATH_MAPPING_SEPARATOR);
    int remotesSize = remotes.size();
    int localsSize = locals.size();
    Object[][] paths = new Object[remotesSize + 1][2];
    for (int i = 0; i < remotesSize; ++i) {
        // if user has only 1 path and local == sources => property is not stored at all!
        String local = DEFAULT_LOCAL_PATH;
        if (i < localsSize) {
            local = locals.get(i);
        }
        Pair<String, String> pathMapping = getPathMapping(remotes.get(i), local);
        paths[i][COLUMN_REMOTE_PATH] = pathMapping.first();
        paths[i][COLUMN_LOCAL_PATH] = new LocalPathCell(pathMapping.second());
    }
    paths[remotesSize][COLUMN_REMOTE_PATH] = null;
    paths[remotesSize][COLUMN_LOCAL_PATH] = new LocalPathCell(DEFAULT_LOCAL_PATH);
    return paths;
}
 
Example 13
Source Project: netbeans   Source File: CommandUtils.java    License: Apache License 2.0 6 votes vote down vote up
static String encodeRelativeUrl(String relativeUrl) {
    if (!StringUtils.hasText(relativeUrl)) {
        return relativeUrl;
    }
    StringBuilder sb = new StringBuilder(relativeUrl.length() * 2);
    try {
        for (String part : StringUtils.explode(relativeUrl, "/")) { // NOI18N
            if (sb.length() > 0) {
                sb.append('/'); // NOI18N
            }
            sb.append(URLEncoder.encode(part, "UTF-8")); // NOI18N
        }
    } catch (UnsupportedEncodingException ex) {
        Exceptions.printStackTrace(ex);
        return relativeUrl;
    }
    return sb.toString();
}
 
Example 14
Source Project: netbeans   Source File: FunctionScopeImpl.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Add new return type but <b>only if the return type is not defined
 * in its declaration already</b> (in such a case, this new return type
 * is simply ignored).
 * @param type return type to be added
 */
public void addReturnType(String type) {
    if (declaredReturnType) {
        return;
    }
    synchronized (this) {
        if (!StringUtils.hasText(returnType)) {
            returnType = type;
        } else {
            Set<String> distinctTypes = new HashSet<>();
            distinctTypes.addAll(Arrays.asList(returnType.split(TYPE_SEPARATOR_REGEXP)));
            distinctTypes.add(type);
            returnType = StringUtils.implode(distinctTypes, TYPE_SEPARATOR);
        }
    }
}
 
Example 15
Source Project: netbeans   Source File: NewPhpProjectWizardIterator.java    License: Apache License 2.0 6 votes vote down vote up
private void setIncludePath(PhpProject project, PhpProjectGenerator.ProjectProperties createProperties, EditableProperties projectProperties,
        EditableProperties privateProperties, List<PhpModuleProperties> phpModuleProperties) {
    if (phpModuleProperties.isEmpty()) {
        return;
    }

    for (PhpModuleProperties properties : phpModuleProperties) {
        List<String> customIncludePath = properties.getIncludePath();
        if (customIncludePath != null && !customIncludePath.isEmpty()) {
            Set<String> includePath = new LinkedHashSet<>();
            String current = projectProperties.getProperty(PhpProjectProperties.INCLUDE_PATH);
            if (StringUtils.hasText(current)) {
                includePath.add(current);
            }
            includePath.addAll(customIncludePath);
            IncludePathSupport includePathSupport = new IncludePathSupport(
                    ProjectPropertiesSupport.getPropertyEvaluator(project), project.getRefHelper(), project.getHelper());
            Iterator<Item> itemsIterator = includePathSupport.itemsIterator(
                    StringUtils.implode(new ArrayList<>(includePath), ":")); // NOI18N
            String[] encoded = includePathSupport.encodeToStrings(itemsIterator);
            projectProperties.setProperty(PhpProjectProperties.INCLUDE_PATH, encoded);
        }
    }
}
 
Example 16
Source Project: netbeans   Source File: UserAnnotationPanel.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "UserAnnotationPanel.error.noName=Name must be set.",
    "UserAnnotationPanel.error.noFor=At least one target must be set.",
    "UserAnnotationPanel.error.noTemplate=Template must be set."
})
void validateAnnotation() {
    if (!StringUtils.hasText(nameTextField.getText())) {
        setError(Bundle.UserAnnotationPanel_error_noName());
        return;
    }
    if (!anyTypeSelected()) {
        setError(Bundle.UserAnnotationPanel_error_noFor());
        return;
    }
    if (!StringUtils.hasText(templateTextField.getText())) {
        setError(Bundle.UserAnnotationPanel_error_noTemplate());
        return;
    }
    clearError();
}
 
Example 17
Source Project: netbeans   Source File: PHPStan.java    License: Apache License 2.0 6 votes vote down vote up
private List<String> getParameters(PHPStanParams parameters, FileObject file) {
    // analyse /path/to/{dir|file}
    List<String> params = new ArrayList<>();
    params.add(ANALYSE_COMMAND);
    params.addAll(ANALYZE_DEFAULT_PARAMS);
    String level = parameters.getLevel();
    if (!StringUtils.isEmpty(level)) {
        params.add(String.format(LEVEL_PARAM, level));
    }
    FileObject configuration = parameters.getConfiguration();
    if (configuration != null) {
        params.add(String.format(CONFIGURATION_PARAM, FileUtil.toFile(configuration).getAbsolutePath()));
    }
    String memoryLimit = parameters.getMemoryLimit();
    if (!StringUtils.isEmpty(memoryLimit)) {
        params.add(String.format(MEMORY_LIMIT_PARAM, memoryLimit));
    }
    params.add(FileUtil.toFile(file).getAbsolutePath());
    return params;
}
 
Example 18
Source Project: netbeans   Source File: OccurenceBuilder.java    License: Apache License 2.0 6 votes vote down vote up
private void buildDocTagsForClasses(ElementInfo nodeCtxInfo, FileScopeImpl fileScope, final List<Occurence> occurences) {
    Set<? extends PhpElement> elements = nodeCtxInfo.getDeclarations();
    for (PhpElement phpElement : elements) {
        for (Entry<PhpDocTypeTagInfo, Scope> entry : docTags.entrySet()) {
            if (CancelSupport.getDefault().isCancelled()) {
                return;
            }
            PhpDocTypeTagInfo nodeInfo = entry.getKey();
            final QualifiedName qualifiedName = VariousUtils.getFullyQualifiedName(nodeInfo.getQualifiedName(), nodeInfo.getOriginalNode().getStartOffset(), entry.getValue());
            final String name = CodeUtils.removeNullableTypePrefix(nodeInfo.getName());
            if (StringUtils.hasText(name) && NameKind.exact(name).matchesName(PhpElementKind.CLASS, phpElement.getName())
                    && NameKind.exact(qualifiedName).matchesName(phpElement)) {
                if (qualifiedName.getKind().isUnqualified()) {
                    occurences.add(new OccurenceImpl(ElementFilter.forFiles(fileScope.getFileObject()).prefer(elements), nodeInfo.getRange()));
                } else {
                    occurences.add(new OccurenceImpl(phpElement, nodeInfo.getRange()));
                }
            }
        }
    }
}
 
Example 19
Source Project: cakephp3-netbeans   Source File: FilePathParameter.java    License: Apache License 2.0 5 votes vote down vote up
private List<String> getCategoryElements(CakePHP3Module cakeModule, ModuleInfo info, String subpath, String filter, String pluginName, Category category) {
    Base base = info.getBase();
    if (StringUtils.isEmpty(pluginName)) {
        if (base == Base.PLUGIN) {
            pluginName = info.getPluginName();
        }
    } else {
        if (base != Base.PLUGIN) {
            base = Base.PLUGIN;
        }
    }
    // app or plugin
    List<FileObject> directories = cakeModule.getDirectories(base, category, pluginName);
    List<FileObject> coreDirectories;
    if (!StringUtils.isEmpty(pluginName)) {
        coreDirectories = Collections.emptyList();
    } else {
        coreDirectories = cakeModule.getDirectories(Base.CORE, category, null);
    }
    List<String> elements = new ArrayList<>();
    for (List<FileObject> targets : Arrays.asList(directories, coreDirectories)) {
        for (FileObject directory : targets) {
            FileObject baseDirectory = directory.getFileObject(subpath);
            if (baseDirectory != null) {
                for (FileObject child : baseDirectory.getChildren()) {
                    if (child.isFolder()) {
                        continue;
                    }
                    String name = child.getName();
                    name = ModuleUtils.toCommonName(name, category);
                    if (!elements.contains(name) && name.toLowerCase().startsWith(filter.toLowerCase())) {
                        elements.add(name);
                    }
                }
            }
        }
    }
    return elements;
}
 
Example 20
Source Project: netbeans   Source File: PhpExecutable.java    License: Apache License 2.0 5 votes vote down vote up
public static String getInfoCommand(List<String> fullCommand) {
    List<String> escapedCommand = new ArrayList<>(fullCommand.size());
    for (String command : fullCommand) {
        escapedCommand.add("\"" + command.replace("\"", "\\\"") + "\""); // NOI18N
    }
    return StringUtils.implode(escapedCommand, " "); // NOI18N
}
 
Example 21
Source Project: netbeans   Source File: AtoumPreferences.java    License: Apache License 2.0 5 votes vote down vote up
private static String relativizePath(PhpModule phpModule, String filePath) {
    if (!StringUtils.hasText(filePath)) {
        return ""; // NOI18N
    }
    File file = new File(filePath);
    String path = PropertyUtils.relativizeFile(FileUtil.toFile(phpModule.getProjectDirectory()), file);
    if (path == null) {
        // sorry, cannot be relativized
        path = file.getAbsolutePath();
    }
    return path;
}
 
Example 22
Source Project: cakephp3-netbeans   Source File: CakePHP3ModuleImpl.java    License: Apache License 2.0 5 votes vote down vote up
protected String getAppImageBaseUrl() {
    if (phpModule == null) {
        return ""; // NOI18N
    }
    String imageUrl = CakePHP3Preferences.getImageUrl(phpModule);
    if (StringUtils.isEmpty(imageUrl)) {
        imageUrl = DEFAULT_IMAGE_BASE_URL;
    }
    return imageUrl;
}
 
Example 23
Source Project: cakephp3-netbeans   Source File: CakePHP3ModuleImpl.java    License: Apache License 2.0 5 votes vote down vote up
protected String getSrcDirName() {
    if (phpModule == null) {
        return ""; // NOI18N
    }
    String srcName = CakePHP3Preferences.getSrcName(phpModule);
    if (StringUtils.isEmpty(srcName)) {
        srcName = DEFAULT_SRC_DIR_NAME;
    }
    return srcName;
}
 
Example 24
Source Project: netbeans   Source File: SftpClient.java    License: Apache License 2.0 5 votes vote down vote up
private Session createSftpSession(JSch jsch, boolean withUserInfo) throws JSchException {
    LOGGER.fine("Creating new SFTP session...");
    String host = configuration.getHost();
    int port = configuration.getPort();
    int timeout = configuration.getTimeout() * 1000;
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Will connect to {0} [timeout: {1} ms]", new Object[] {host, timeout});
    }
    int keepAliveInterval = configuration.getKeepAliveInterval() * 1000;
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Keep-alive interval is {0} ms", keepAliveInterval);
    }
    String username = configuration.getUserName();
    String password = configuration.getPassword();
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.log(Level.FINE, "Login as {0}", username);
    }
    Session session = jsch.getSession(username, host, port);
    if (StringUtils.hasText(password)) {
        session.setPassword(password);
    }
    // proxy
    setProxy(session, host);
    if (withUserInfo) {
        LOGGER.fine("Setting user info...");
        session.setUserInfo(new SftpUserInfo(configuration));
    }
    session.setTimeout(timeout);
    // keep-alive
    if (keepAliveInterval > 0) {
        session.setServerAliveInterval(keepAliveInterval);
    }
    return session;
}
 
Example 25
Source Project: netbeans   Source File: SftpClient.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String[] promptKeyboardInteractive(String destination, String name, String instruction,
        String[] prompt, boolean[] echo) {

    // diagnostics for #230248
    if (LOGGER.isLoggable(Level.FINE)) {
        LOGGER.fine("promptKeyboardInteractive called with these params:");
        LOGGER.log(Level.FINE, "destination: {0}", destination);
        LOGGER.log(Level.FINE, "name: {0}", name);
        LOGGER.log(Level.FINE, "instruction: {0}", instruction);
        LOGGER.log(Level.FINE, "prompt: {0}", Arrays.toString(prompt));
        LOGGER.log(Level.FINE, "echo: {0}", Arrays.toString(echo));
    }

    // #166555
    if (prompt.length == 1
            && echo.length == 1 && !echo[0]) {
        // ask for password
        passwd = configuration.getPassword();
        if (!StringUtils.hasText(passwd)) {
            passwd = getPasswordForUser(configuration);
        }
        if (StringUtils.hasText(passwd)) {
            return new String[] {passwd};
        }
    }
    return null;
}
 
Example 26
Source Project: netbeans   Source File: CodeceptionPreferences.java    License: Apache License 2.0 5 votes vote down vote up
private static String relativizePath(PhpModule phpModule, String filePath) {
    if (!StringUtils.hasText(filePath)) {
        return ""; // NOI18N
    }
    File file = new File(filePath);
    String path = PropertyUtils.relativizeFile(FileUtil.toFile(phpModule.getProjectDirectory()), file);
    if (path == null) {
        // sorry, cannot be relativized
        path = file.getAbsolutePath();
    }
    return path;
}
 
Example 27
Source Project: netbeans   Source File: RemoteConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Read value of the given key as a number. If number is not found in the given configuration
 * (or value is not a number), the default value is returned (and set in the configuration).
 * @param key key of the number
 * @param defaultValue default value if any error occurs
 * @return value of the given key as a number or defaultValue if any error occurs
 */
protected int readNumber(String key, int defaultValue) {
    String currentValue = cfg.getValue(key);
    if (StringUtils.hasText(currentValue)) {
        try {
            return Integer.parseInt(currentValue);
        } catch (NumberFormatException nfe) {
            LOGGER.log(Level.INFO, "Exception while parsing number of '" + key + "'", nfe);
        }
    }
    cfg.putValue(key, String.valueOf(defaultValue));
    return defaultValue;
}
 
Example 28
Source Project: netbeans   Source File: RemoteConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
protected void savePassword(final String password, final String type) {
    if (password == null) {
        // password not set at all, do nothing
        //  (e.g. when user opens Remote Configurations and clicks OK but not all configs were displayed [= passwords were not fetched from keyring])
        return;
    }
    if (StringUtils.hasText(password)) {
        Keyring.save(passwordKey, password.toCharArray(),
                NbBundle.getMessage(RemoteConfiguration.class, "MSG_PasswordFor", getDisplayName(), type));
        // remove old password key
        Keyring.delete(deprecatedPasswordKey);
    } else {
        deletePassword();
    }
}
 
Example 29
Source Project: netbeans   Source File: DiffPanel.java    License: Apache License 2.0 5 votes vote down vote up
private String getExtension(String filename) {
    List<String> parts = StringUtils.explode(filename, "."); // NOI18N
    if (parts.isEmpty()) {
        return null;
    }
    return parts.get(parts.size() - 1);
}
 
Example 30
Source Project: netbeans   Source File: AnalysisOptionsValidator.java    License: Apache License 2.0 5 votes vote down vote up
private AnalysisOptionsValidator validatePHPStanConfiguration(String configuration) {
    if (!StringUtils.isEmpty(configuration)) {
        String warning = FileUtils.validateFile("Configuration file", configuration, false); // NOI18N
        if (warning != null) {
            result.addWarning(new ValidationResult.Message("phpStan.configuration", warning)); // NOI18N
        }
    }
    return this;
}