本文整理匯總了Java中com.intellij.openapi.vfs.VfsUtil.getUserHomeDir方法的典型用法代碼示例。如果您正苦於以下問題:Java VfsUtil.getUserHomeDir方法的具體用法?Java VfsUtil.getUserHomeDir怎麽用?Java VfsUtil.getUserHomeDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.vfs.VfsUtil
的用法示例。
在下文中一共展示了VfsUtil.getUserHomeDir方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionPerformed
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
protected void actionPerformed(final FileSystemTree fileSystemTree, final AnActionEvent e) {
final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
if (userHomeDir != null) {
fileSystemTree.select(userHomeDir, new Runnable() {
public void run() {
fileSystemTree.expand(userHomeDir, null);
}
});
}
}
示例2: update
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
protected void update(final FileSystemTree fileSystemTree, final AnActionEvent e) {
final Presentation presentation = e.getPresentation();
if (!presentation.isEnabled()) return;
final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
presentation.setEnabled(userHomeDir != null && fileSystemTree.isUnderRoots(userHomeDir));
}
示例3: getFileToSelect
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
public static VirtualFile getFileToSelect(@NotNull FileChooserDescriptor descriptor, @Nullable Project project,
@Nullable VirtualFile toSelect, @Nullable VirtualFile lastPath) {
boolean chooseDir = descriptor instanceof FileSaverDescriptor;
VirtualFile result;
if (toSelect == null && lastPath == null) {
result = project == null? null : project.getBaseDir();
}
else if (toSelect != null && lastPath != null) {
if (Boolean.TRUE.equals(descriptor.getUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT))) {
result = lastPath;
}
else {
result = toSelect;
}
}
else if (toSelect == null) {
result = lastPath;
}
else {
result = toSelect;
}
if (result != null) {
if (chooseDir && !result.isDirectory()) {
result = result.getParent();
}
}
else if (SystemInfo.isUnix) {
result = VfsUtil.getUserHomeDir();
}
return result;
}
示例4: canInspectDirectory
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private static boolean canInspectDirectory(VirtualFile file) {
VirtualFile home = VfsUtil.getUserHomeDir();
if (home == null || VfsUtilCore.isAncestor(file, home, false)) {
return false;
}
if (ourCanInspectDirs || VfsUtilCore.isAncestor(home, file, true)) {
return true;
}
return false;
}
示例5: MkDirs
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public MkDirs(@NotNull String newName, @NotNull PsiDirectory directory) {
if (SystemInfo.isWindows) {
newName = newName.replace('\\', '/');
}
if (newName.contains("/")) {
final List<String> subDirs = StringUtil.split(newName, "/");
newName = subDirs.remove(subDirs.size() - 1);
boolean firstToken = true;
for (String dir : subDirs) {
if (firstToken && "~".equals(dir)) {
final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
if (userHomeDir == null) throw new IncorrectOperationException("User home directory not found");
final PsiDirectory directory1 = directory.getManager().findDirectory(userHomeDir);
if (directory1 == null) throw new IncorrectOperationException("User home directory not found");
directory = directory1;
}
else if ("..".equals(dir)) {
final PsiDirectory parentDirectory = directory.getParentDirectory();
if (parentDirectory == null) throw new IncorrectOperationException("Not a valid directory");
directory = parentDirectory;
}
else if (!".".equals(dir)){
final PsiDirectory sub = directory.findSubdirectory(dir);
directory = sub == null ? directory.createSubdirectory(dir) : sub;
}
firstToken = false;
}
}
this.newName = newName;
this.directory = directory;
}
示例6: createSubdirectories
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
public static PsiDirectory createSubdirectories(final String subDirName, PsiDirectory baseDirectory, final String delim) throws IncorrectOperationException {
StringTokenizer tokenizer = new StringTokenizer(subDirName, delim);
PsiDirectory dir = baseDirectory;
boolean firstToken = true;
while (tokenizer.hasMoreTokens()) {
String dirName = tokenizer.nextToken();
if (tokenizer.hasMoreTokens()) {
if (firstToken && "~".equals(dirName)) {
final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
if (userHomeDir == null) throw new IncorrectOperationException("User home directory not found");
final PsiDirectory directory1 = baseDirectory.getManager().findDirectory(userHomeDir);
if (directory1 == null) throw new IncorrectOperationException("User home directory not found");
dir = directory1;
continue;
}
else if ("..".equals(dirName)) {
dir = dir.getParentDirectory();
if (dir == null) throw new IncorrectOperationException("Not a valid directory");
continue;
}
else if (".".equals(dirName)) {
continue;
}
PsiDirectory existingDir = dir.findSubdirectory(dirName);
if (existingDir != null) {
dir = existingDir;
continue;
}
}
dir = dir.createSubdirectory(dirName);
firstToken = false;
}
return dir;
}
示例7: tryNotNullizeDirectory
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Nullable
private static PsiDirectory tryNotNullizeDirectory(@NotNull Project project, @Nullable PsiDirectory defaultTargetDirectory) {
if (defaultTargetDirectory == null) {
VirtualFile root = ArrayUtil.getFirstElement(ProjectRootManager.getInstance(project).getContentRoots());
if (root == null) root = project.getBaseDir();
if (root == null) root = VfsUtil.getUserHomeDir();
defaultTargetDirectory = root != null ? PsiManager.getInstance(project).findDirectory(root) : null;
if (defaultTargetDirectory == null) {
LOG.warn("No directory found for project: " + project.getName() +", root: " + root);
}
}
return defaultTargetDirectory;
}
示例8: actionPerformed
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
String path = myTextField.getText().trim();
if (path.length() == 0) {
String defaultLocation = getDefaultLocation();
path = defaultLocation != null && defaultLocation.length() > 0
? defaultLocation
: SystemProperties.getUserHome();
}
File file = new File(path);
if (!file.exists()) {
path = SystemProperties.getUserHome();
}
FileSaverDescriptor descriptor = new FileSaverDescriptor(myDialogTitle, "Save as *." + myExtension, myExtension);
FileSaverDialog saveFileDialog = FileChooserFactory.getInstance().createSaveFileDialog(descriptor, myContentPanel);
VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(file.exists() ? file : new File(path));
if (vf == null) {
vf = VfsUtil.getUserHomeDir();
}
VirtualFileWrapper result = saveFileDialog.save(vf, null);
if (result == null || result.getFile() == null) {
return;
}
myTextField.setText(result.getFile().getPath());
}
示例9: pullRecording
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
private void pullRecording() {
FileSaverDescriptor descriptor = new FileSaverDescriptor("Save As", "", "mp4");
FileSaverDialog saveFileDialog = FileChooserFactory.getInstance().createSaveFileDialog(descriptor, myProject);
VirtualFile baseDir = ourLastSavedFolder != null ? ourLastSavedFolder : VfsUtil.getUserHomeDir();
VirtualFileWrapper fileWrapper = saveFileDialog.save(baseDir, getDefaultFileName());
if (fileWrapper == null) {
return;
}
File f = fileWrapper.getFile();
//noinspection AssignmentToStaticFieldFromInstanceMethod
ourLastSavedFolder = VfsUtil.findFileByIoFile(f.getParentFile(), false);
new PullRecordingTask(myProject, myDevice, f.getAbsolutePath()).queue();
}
示例10: checkInput
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public boolean checkInput(String inputString) {
final StringTokenizer tokenizer = new StringTokenizer(inputString, myDelimiters);
VirtualFile vFile = myDirectory.getVirtualFile();
boolean firstToken = true;
while (tokenizer.hasMoreTokens()) {
final String token = tokenizer.nextToken();
if (!tokenizer.hasMoreTokens() && (token.equals(".") || token.equals(".."))) {
myErrorText = "Can't create a directory with name '" + token + "'";
return false;
}
if (vFile != null) {
if (firstToken && "~".equals(token)) {
final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
if (userHomeDir == null) {
myErrorText = "User home directory not found";
return false;
}
vFile = userHomeDir;
}
else if ("..".equals(token)) {
vFile = vFile.getParent();
if (vFile == null) {
myErrorText = "Not a valid directory";
return false;
}
}
else if (!".".equals(token)){
final VirtualFile child = vFile.findChild(token);
if (child != null) {
if (!child.isDirectory()) {
myErrorText = "A file with name '" + token + "' already exists";
return false;
}
else if (!tokenizer.hasMoreTokens()) {
myErrorText = "A directory with name '" + token + "' already exists";
return false;
}
}
vFile = child;
}
}
if (FileTypeManager.getInstance().isFileIgnored(token)) {
myErrorText = "Trying to create a " + (myIsDirectory ? "directory" : "package") +
" with an ignored name, the result will not be visible";
return true;
}
if (!myIsDirectory && token.length() > 0 && !PsiDirectoryFactory.getInstance(myProject).isValidPackageName(token)) {
myErrorText = "Not a valid package name, it will not be possible to create a class inside";
return true;
}
firstToken = false;
}
myErrorText = null;
return true;
}
示例11: checkInput
import com.intellij.openapi.vfs.VfsUtil; //導入方法依賴的package包/類
@Override
public boolean checkInput(String inputString) {
final StringTokenizer tokenizer = new StringTokenizer(inputString, "\\/");
VirtualFile vFile = getDirectory().getVirtualFile();
boolean firstToken = true;
while (tokenizer.hasMoreTokens()) {
final String token = tokenizer.nextToken();
if ((token.equals(".") || token.equals("..")) && !tokenizer.hasMoreTokens()) {
myErrorText = "Can't create file with name '" + token + "'";
return false;
}
if (vFile != null) {
if (firstToken && "~".equals(token)) {
final VirtualFile userHomeDir = VfsUtil.getUserHomeDir();
if (userHomeDir == null) {
myErrorText = "User home directory not found";
return false;
}
vFile = userHomeDir;
}
else if ("..".equals(token)) {
vFile = vFile.getParent();
if (vFile == null) {
myErrorText = "Not a valid directory";
return false;
}
}
else if (!".".equals(token)){
final VirtualFile child = vFile.findChild(token);
if (child != null) {
if (!child.isDirectory()) {
myErrorText = "A file with name '" + token + "' already exists";
return false;
}
else if (!tokenizer.hasMoreTokens()) {
myErrorText = "A directory with name '" + token + "' already exists";
return false;
}
}
vFile = child;
}
}
if (FileTypeManager.getInstance().isFileIgnored(getFileName(token))) {
myErrorText = "'" + token + "' is an ignored name (Settings | Editor | File Types | Ignore files and folders)";
return true;
}
firstToken = false;
}
myErrorText = null;
return true;
}