当前位置: 首页>>代码示例>>Java>>正文


Java FileUtil.getLocationRelativeToUserHome方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PlatformFrameTitleBuilder.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PySdkListCellRenderer.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PythonSdkType.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:IdeaFrameTitleBuilder.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:RecentProjectPanel.java

示例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) + "]";
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PlatformFrameTitleBuilder.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ReopenProjectAction.java

示例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 "";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PsiDirectoryFactoryImpl.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PsiFileNode.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:ConfigImportSettings.java

示例11: getFileTooltipText

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
public String getFileTooltipText(@NotNull VirtualFile file) {
  return FileUtil.getLocationRelativeToUserHome(file.getPresentableUrl());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:FileEditorManagerImpl.java

示例12: getProjectLocationString

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
public static String getProjectLocationString(@NotNull final Project project) {
  return FileUtil.getLocationRelativeToUserHome(project.getBasePath());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:ProjectUtil.java

示例13: getTooltipText

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
@Override
public String getTooltipText() {
  return FileUtil.getLocationRelativeToUserHome(myLocation);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:PyPackage.java


注:本文中的com.intellij.openapi.util.io.FileUtil.getLocationRelativeToUserHome方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。