本文整理汇总了Java中com.intellij.util.PathUtil.isValidFileName方法的典型用法代码示例。如果您正苦于以下问题:Java PathUtil.isValidFileName方法的具体用法?Java PathUtil.isValidFileName怎么用?Java PathUtil.isValidFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.PathUtil
的用法示例。
在下文中一共展示了PathUtil.isValidFileName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateOKButton
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
private void validateOKButton() {
if (myShowDirectoryField) {
if (myTargetDirectoryField.getChildComponent().getText().length() == 0) {
setOKActionEnabled(false);
return;
}
}
if (myShowNewNameField) {
final String newName = getNewName();
if (newName.length() == 0 || myFileCopy && !PathUtil.isValidFileName(newName)) {
setOKActionEnabled(false);
return;
}
}
setOKActionEnabled(true);
}
示例2: isPath
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public static boolean isPath(@Nullable String s) {
if (!StringUtil.isEmpty(s)) {
s = ObjectUtils.assertNotNull(s);
s = FileUtil.toSystemIndependentName(s);
final List<String> components = StringUtil.split(s, "/");
for (String name : components) {
if (name == components.get(0) && SystemInfo.isWindows && name.endsWith(":")) {
continue;
}
if (!PathUtil.isValidFileName(name)) {
return false;
}
}
return true;
}
return false;
}
示例3: checkInput
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
public boolean checkInput(String inputString) {
final List<String> fileNames = StringUtil.split(FileUtil.toSystemIndependentName(inputString), "/");
if (fileNames.isEmpty()) {
return false;
}
for (String fileName : fileNames) {
if (!PathUtil.isValidFileName(fileName)) {
return false;
}
}
return true;
}
示例4: guessFileName
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@NotNull
private String guessFileName(@NotNull URLConnection connection, @NotNull File file) throws IOException {
String fileName = null;
final String contentDisposition = connection.getHeaderField("Content-Disposition");
LOG.debug("header: " + contentDisposition);
if (contentDisposition != null && contentDisposition.contains(FILENAME)) {
final int startIdx = contentDisposition.indexOf(FILENAME);
final int endIdx = contentDisposition.indexOf(';', startIdx);
fileName = contentDisposition.substring(startIdx + FILENAME.length(), endIdx > 0 ? endIdx : contentDisposition.length());
if (StringUtil.startsWithChar(fileName, '\"') && StringUtil.endsWithChar(fileName, '\"')) {
fileName = fileName.substring(1, fileName.length() - 1);
}
}
if (fileName == null) {
// try to find a filename in an URL
final String usedURL = connection.getURL().toString();
fileName = usedURL.substring(usedURL.lastIndexOf('/') + 1);
if (fileName.length() == 0 || fileName.contains("?")) {
fileName = myPluginUrl.substring(myPluginUrl.lastIndexOf('/') + 1);
}
}
if (!PathUtil.isValidFileName(fileName)) {
FileUtil.delete(file);
throw new IOException("Invalid filename returned by a server");
}
return fileName;
}
示例5: checkValid
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
protected void checkValid() {
final String projectName = myName.getText();
final File destFile = new File(getDestination());
if (destFile.exists()) {
final String[] content = destFile.list();
if (content != null && content.length != 0) {
setOKActionEnabled(false);
setErrorText(PyBundle.message("sdk.create.venv.dialog.error.not.empty.directory"));
return;
}
}
if (StringUtil.isEmptyOrSpaces(projectName)) {
setOKActionEnabled(false);
setErrorText(PyBundle.message("sdk.create.venv.dialog.error.empty.venv.name"));
return;
}
if (!PathUtil.isValidFileName(projectName)) {
setOKActionEnabled(false);
setErrorText(PyBundle.message("sdk.create.venv.dialog.error.invalid.directory.name"));
return;
}
if (StringUtil.isEmptyOrSpaces(myDestination.getText())) {
setOKActionEnabled(false);
setErrorText(PyBundle.message("sdk.create.venv.dialog.error.empty.venv.location"));
return;
}
setOKActionEnabled(true);
setErrorText(null);
}
示例6: doValidate
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@Nullable
@Override
protected ValidationInfo doValidate() {
for (String fileName : myComponent.getFileNamesToCreate()) {
if (!PathUtil.isValidFileName(fileName)) {
return new ValidationInfo(String.format("File name for properties file '%s' is invalid", fileName));
} else {
if (myDirectory.findFile(fileName) != null) {
return new ValidationInfo(String.format("File with name '%s' already exist", fileName));
}
}
}
return null;
}
示例7: doOKAction
import com.intellij.util.PathUtil; //导入方法依赖的package包/类
@Override
protected void doOKAction() {
if (myShowNewNameField) {
String newName = getNewName();
if (newName.length() == 0) {
Messages.showErrorDialog(myProject, RefactoringBundle.message("no.new.name.specified"), RefactoringBundle.message("error.title"));
return;
}
if (myFileCopy && !PathUtil.isValidFileName(newName)) {
Messages.showErrorDialog(myNewNameField, "Name is not a valid file name");
return;
}
}
saveOpenInEditorState(myOpenFilesInEditor.isSelected());
if (myShowDirectoryField) {
final String targetDirectoryName = myTargetDirectoryField.getChildComponent().getText();
if (targetDirectoryName.length() == 0) {
Messages.showErrorDialog(myProject, RefactoringBundle.message("no.target.directory.specified"),
RefactoringBundle.message("error.title"));
return;
}
RecentsManager.getInstance(myProject).registerRecentEntry(RECENT_KEYS, targetDirectoryName);
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
myTargetDirectory =
DirectoryUtil.mkdirs(PsiManager.getInstance(myProject), targetDirectoryName.replace(File.separatorChar, '/'));
}
catch (IncorrectOperationException ignored) { }
}
});
}
}, RefactoringBundle.message("create.directory"), null);
if (myTargetDirectory == null) {
Messages.showErrorDialog(myProject, RefactoringBundle.message("cannot.create.directory"), RefactoringBundle.message("error.title"));
return;
}
}
super.doOKAction();
}