本文整理匯總了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);
}