Java Code Examples for com.intellij.util.PathUtil#toPresentableUrl()

The following examples show how to use com.intellij.util.PathUtil#toPresentableUrl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleLibraryOrderEntryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public String getPresentableName() {
  final String name = myLibrary.getName();
  if (name != null) {
    return name;
  }
  else {
    if (myLibrary instanceof LibraryEx && ((LibraryEx)myLibrary).isDisposed()) {
      return "<unknown>";
    }

    final String[] urls = myLibrary.getUrls(BinariesOrderRootType.getInstance());
    if (urls.length > 0) {
      String url = urls[0];
      return PathUtil.toPresentableUrl(url);
    }
    else {
      return ProjectBundle.message("library.empty.library.item");
    }
  }
}
 
Example 2
Source File: VirtualFilePointerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public String getPresentableUrl() {
  FilePointerPartNode node = checkDisposed(myNode);
  if (node == null) return "";
  Pair<VirtualFile, String> result = node.update();
  return result == null ? "" : PathUtil.toPresentableUrl(result.second);
}
 
Example 3
Source File: AnalyzeDependenciesComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public CellAppearanceEx getAppearance(boolean selected, final boolean isBold) {
  return new CellAppearanceEx() {
    @Override
    public void customize(@Nonnull SimpleColoredComponent component) {
      component.setIcon(getIcon());
      final Font font = UIUtil.getTreeFont();
      if (isBold) {
        component.setFont(font.deriveFont(Font.BOLD));
      }
      else {
        component.setFont(font.deriveFont(Font.PLAIN));
      }
      final String p = PathUtil.toPresentableUrl(getEditableObject().url());
      component.append(PathUtil.getFileName(p),
                       isBold ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      component.append(" (" + PathUtil.getParentPath(p) + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
    }

    @Nonnull
    @Override
    public String getText() {
      return getDisplayName();
    }
  };
}
 
Example 4
Source File: BaseProjectViewDirectoryHelper.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
@RequiredReadAction
public static String getLocationString(@Nonnull PsiDirectory psiDirectory) {
  PsiPackage aPackage = PsiPackageManager.getInstance(psiDirectory.getProject()).findAnyPackage(psiDirectory);
  if (ProjectRootsUtil.isSourceRoot(psiDirectory) && aPackage != null) {
    return aPackage.getQualifiedName();
  }

  final VirtualFile directory = psiDirectory.getVirtualFile();
  final VirtualFile contentRootForFile = ProjectRootManager.getInstance(psiDirectory.getProject()).getFileIndex().getContentRootForFile(directory);
  if (Comparing.equal(contentRootForFile, psiDirectory)) {
    return PathUtil.toPresentableUrl(directory.getUrl());
  }
  return null;
}
 
Example 5
Source File: VfsUtilCore.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static File virtualToIoFile(@Nonnull VirtualFile file) {
  return new File(PathUtil.toPresentableUrl(file.getUrl()));
}