more consistently replace home dir with ~ on Mac/Linux

This commit is contained in:
Dmitry Jemerov
2011-05-18 20:01:52 +02:00
parent f05a17c4cb
commit 9c302eb29b
5 changed files with 12 additions and 7 deletions
@@ -15,6 +15,7 @@
*/
package com.intellij.psi.impl.file;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.roots.ProjectRootManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
@@ -46,7 +47,7 @@ public class PsiJavaDirectoryFactory extends PsiDirectoryFactory {
}
return "";
}
return presentable ? directory.getVirtualFile().getPresentableUrl() : "";
return presentable ? ProjectUtil.getLocationRelativeToUserHome(directory.getVirtualFile().getPresentableUrl()) : "";
}
@Override
@@ -52,6 +52,7 @@ import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.roots.*;
import com.intellij.openapi.roots.ui.configuration.actions.ModuleDeleteProvider;
import com.intellij.openapi.ui.ComboBox;
@@ -859,7 +860,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
if (element != null) {
PsiFile file = element.getContainingFile();
if (file != null) {
title = file.getVirtualFile().getPresentableUrl();
title = ProjectUtil.getLocationRelativeToUserHome(file.getVirtualFile().getPresentableUrl());
}
else if (element instanceof PsiDirectory) {
title = PsiDirectoryFactory.getInstance(myProject).getQualifiedName((PsiDirectory) element, true);
@@ -871,7 +872,7 @@ public final class ProjectViewImpl extends ProjectView implements PersistentStat
else {
title = "";
if (myProject != null) {
title = myProject.getPresentableUrl();
title = ProjectUtil.getLocationRelativeToUserHome(myProject.getPresentableUrl());
}
}
}
@@ -22,6 +22,7 @@ import com.intellij.ide.projectView.ViewSettings;
import com.intellij.ide.util.treeView.AbstractTreeNode;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.util.Iconable;
import com.intellij.openapi.vfs.JarFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
@@ -79,7 +80,7 @@ public class PsiFileNode extends BasePsiNode<PsiFile>{
public String getTitle() {
final PsiFile file = getValue();
if (file != null) {
return file.getVirtualFile().getPresentableUrl();
return ProjectUtil.getLocationRelativeToUserHome(file.getVirtualFile().getPresentableUrl());
}
return super.getTitle();
}
@@ -16,9 +16,11 @@
package com.intellij.psi.impl.file;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.impl.PsiManagerImpl;
import com.intellij.util.PlatformUtils;
import org.jetbrains.annotations.NotNull;
/**
@@ -37,7 +39,7 @@ public class PsiDirectoryFactoryImpl extends PsiDirectoryFactory {
@NotNull
public String getQualifiedName(@NotNull final PsiDirectory directory, final boolean presentable) {
if (presentable) {
return directory.getVirtualFile().getPresentableUrl();
return ProjectUtil.getLocationRelativeToUserHome(directory.getVirtualFile().getPresentableUrl());
}
return "";
}
@@ -43,12 +43,12 @@ public class PlatformFrameTitleBuilder extends FrameTitleBuilder {
if (file instanceof VirtualFilePathWrapper) {
return ((VirtualFilePathWrapper)file).getPresentablePath();
}
String url = file.getPresentableUrl();
String url = ProjectUtil.getLocationRelativeToUserHome(file.getPresentableUrl());
VirtualFile baseDir = ProjectBaseDirectory.getInstance(project).getBaseDir();
if (baseDir == null) baseDir = project.getBaseDir();
if (baseDir != null) {
//noinspection ConstantConditions
final String projectHomeUrl = baseDir.getPresentableUrl();
final String projectHomeUrl = ProjectUtil.getLocationRelativeToUserHome(baseDir.getPresentableUrl());
if (url.startsWith(projectHomeUrl)) {
url = "..." + url.substring(projectHomeUrl.length());
}