當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。