本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.getLocationRelativeToUserHome方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.getLocationRelativeToUserHome方法的具体用法?Java FileUtil.getLocationRelativeToUserHome怎么用?Java FileUtil.getLocationRelativeToUserHome使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.io.FileUtil
的用法示例。
在下文中一共展示了FileUtil.getLocationRelativeToUserHome方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFileTitle
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public String getFileTitle(@NotNull final Project project, @NotNull final VirtualFile file) {
String fileTitle = EditorTabbedContainer.calcTabTitle(project, file);
if (SystemInfo.isMac) return fileTitle;
VirtualFile parent = file.getParent();
if (parent == null || !fileTitle.endsWith(file.getPresentableName())) return fileTitle;
String url = FileUtil.getLocationRelativeToUserHome(parent.getPresentableUrl() + File.separator + file.getName());
VirtualFile baseDir = ProjectBaseDirectory.getInstance(project).getBaseDir();
if (baseDir == null) baseDir = project.getBaseDir();
if (baseDir != null) {
final String projectHomeUrl = FileUtil.getLocationRelativeToUserHome(baseDir.getPresentableUrl());
if (url.startsWith(projectHomeUrl)) {
url = "..." + url.substring(projectHomeUrl.length());
}
}
return url;
}
示例2: shortenName
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private String shortenName(@NotNull String name) {
final Matcher matcher = PYTHON_PATTERN.matcher(name);
if (matcher.matches()) {
String path = matcher.group(2);
if (path != null) {
name = matcher.group(1) + " at " + path;
}
else {
path = matcher.group(4);
final int index = path.lastIndexOf(File.separator);
if (index > 0) {
path = path.substring(index);
}
name = matcher.group(3) + " at ..." + path;
}
}
else if (new File(name).exists()) {
name = FileUtil.getLocationRelativeToUserHome(name);
}
return name;
}
示例3: suggestSdkNameFromVersion
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static String suggestSdkNameFromVersion(String sdkHome, String version) {
sdkHome = FileUtil.toSystemDependentName(sdkHome);
final String shortHomeName = FileUtil.getLocationRelativeToUserHome(sdkHome);
if (version != null) {
File virtualEnvRoot = getVirtualEnvRoot(sdkHome);
if (virtualEnvRoot != null) {
version += " virtualenv at " + FileUtil.getLocationRelativeToUserHome(virtualEnvRoot.getAbsolutePath());
}
else {
version += " (" + shortHomeName + ")";
}
}
else {
version = "Unknown at " + shortHomeName;
} // last resort
return version;
}
示例4: getFileTitle
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public String getFileTitle(@NotNull final Project project, @NotNull final VirtualFile file) {
String fileTitle = EditorTabbedContainer.calcTabTitle(project, file);
if (SystemInfo.isMac) return fileTitle;
VirtualFile parent = file.getParent();
if (parent == null || !fileTitle.endsWith(file.getPresentableName())) return fileTitle;
String url = FileUtil.getLocationRelativeToUserHome(parent.getPresentableUrl() + File.separator + file.getName());
return ProjectUtilCore.displayUrlRelativeToProject(file, url, project, !SystemInfo.isMac, false);
}
示例5: getTitle2Text
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
protected String getTitle2Text(ReopenProjectAction action, JComponent pathLabel, int leftOffset) {
String fullText = action.getProjectPath();
if (fullText == null || fullText.length() == 0) return " ";
fullText = FileUtil.getLocationRelativeToUserHome(fullText, false);
try {
FontMetrics fm = pathLabel.getFontMetrics(pathLabel.getFont());
int maxWidth = RecentProjectPanel.this.getWidth() - leftOffset;
if (maxWidth > 0 && fm.stringWidth(fullText) > maxWidth) {
int left = 1; int right = 1;
int center = fullText.length() / 2;
String s = fullText.substring(0, center - left) + "..." + fullText.substring(center + right);
while (fm.stringWidth(s) > maxWidth) {
if (left == right) {
left++;
} else {
right++;
}
if (center - left < 0 || center + right >= fullText.length()) {
return "";
}
s = fullText.substring(0, center - left) + "..." + fullText.substring(center + right);
}
return s;
}
} catch (Exception e) {
LOG.error("Path label font: " + pathLabel.getFont());
LOG.error("Panel width: " + RecentProjectPanel.this.getWidth());
LOG.error(e);
}
return fullText;
}
示例6: getProjectTitle
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public String getProjectTitle(@NotNull final Project project) {
final String basePath = project.getBasePath();
if (basePath == null) return project.getName();
if (basePath.equals(project.getName())) {
return "[" + FileUtil.getLocationRelativeToUserHome(basePath) + "]";
}
else {
return project.getName() + " - [" + FileUtil.getLocationRelativeToUserHome(basePath) + "]";
}
}
示例7: ReopenProjectAction
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public ReopenProjectAction(final String projectPath, final String projectName, final String displayName) {
myProjectPath = projectPath;
myProjectName = projectName;
final Presentation presentation = getTemplatePresentation();
String text = projectPath.equals(displayName) ? FileUtil.getLocationRelativeToUserHome(projectPath) : displayName;
presentation.setText(text, false);
presentation.setDescription(projectPath);
}
示例8: getQualifiedName
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
@NotNull
public String getQualifiedName(@NotNull final PsiDirectory directory, final boolean presentable) {
if (presentable) {
return FileUtil.getLocationRelativeToUserHome(directory.getVirtualFile().getPresentableUrl());
}
return "";
}
示例9: getTitle
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public String getTitle() {
VirtualFile file = getVirtualFile();
if (file != null) {
return FileUtil.getLocationRelativeToUserHome(file.getPresentableUrl());
}
return super.getTitle();
}
示例10: getAutoImportLabel
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
protected String getAutoImportLabel(File guessedOldConfig) {
String path = FileUtil.getLocationRelativeToUserHome(guessedOldConfig.getAbsolutePath());
return ApplicationBundle.message("radio.import.auto", path);
}
示例11: getFileTooltipText
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
public String getFileTooltipText(@NotNull VirtualFile file) {
return FileUtil.getLocationRelativeToUserHome(file.getPresentableUrl());
}
示例12: getProjectLocationString
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
public static String getProjectLocationString(@NotNull final Project project) {
return FileUtil.getLocationRelativeToUserHome(project.getBasePath());
}
示例13: getTooltipText
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
@Override
public String getTooltipText() {
return FileUtil.getLocationRelativeToUserHome(myLocation);
}