Java Code Examples for com.intellij.openapi.vfs.VirtualFile#getPresentableName()

The following examples show how to use com.intellij.openapi.vfs.VirtualFile#getPresentableName() . 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: ShowFilePathAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static ListPopup createPopup(List<VirtualFile> files, List<Image> icons) {
  final BaseListPopupStep<VirtualFile> step = new BaseListPopupStep<VirtualFile>("File Path", files, icons.stream().map(TargetAWT::to).collect(Collectors.toList())) {
    @Nonnull
    @Override
    public String getTextFor(final VirtualFile value) {
      return value.getPresentableName();
    }

    @Override
    public PopupStep onChosen(final VirtualFile selectedValue, final boolean finalChoice) {
      final File selectedFile = new File(getPresentableUrl(selectedValue));
      if (selectedFile.exists()) {
        Application.get().executeOnPooledThread((Runnable)() -> openFile(selectedFile));
      }
      return FINAL_CHOICE;
    }
  };

  return JBPopupFactory.getInstance().createListPopup(step);
}
 
Example 2
Source File: SyncStatusEditorTabTitleProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public String getEditorTabTitle(Project project, VirtualFile file) {
  SyncStatus status = SyncStatusContributor.getSyncStatus(project, file);
  if (status == SyncStatus.UNSYNCED) {
    return file.getPresentableName() + " (unsynced)";
  }
  if (status == SyncStatus.IN_PROGRESS) {
    return file.getPresentableName() + " (syncing...)";
  }
  return null;
}
 
Example 3
Source File: EditorTabPresentationUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String getEditorTabTitle(@Nonnull Project project, @Nonnull VirtualFile file, @Nullable EditorWindow editorWindow) {
  for (EditorTabTitleProvider provider : DumbService.getDumbAwareExtensions(project, EditorTabTitleProvider.EP_NAME)) {
    String result = provider.getEditorTabTitle(project, file, editorWindow);
    if (StringUtil.isNotEmpty(result)) {
      return result;
    }
  }

  return file.getPresentableName();
}
 
Example 4
Source File: ImplementationViewComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
public String getPresentableName(VirtualFile vFile) {
  final String presentableName = vFile.getPresentableName();
  if (myElementPresentation == null) {
    return presentableName;
  }

  if (Comparing.strEqual(vFile.getName(), myElementPresentation + "." + vFile.getExtension())){
    return presentableName;
  }

  return presentableName + " (" + myElementPresentation + ")";
}
 
Example 5
Source File: DefaultNavBarExtension.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public String getPresentableText(final Object object) {
  if (object instanceof Project) {
    return ((Project)object).getName();
  }
  else if (object instanceof Module) {
    return ((Module)object).getName();
  }
  else if (object instanceof PsiFile) {
    VirtualFile file = ((PsiFile)object).getVirtualFile();
    return file != null ? file.getPresentableName() : ((PsiFile)object).getName();
  }
  else if (object instanceof PsiDirectory) {
    return ((PsiDirectory)object).getVirtualFile().getName();
  }
  else if (object instanceof ModuleExtensionWithSdkOrderEntry) {
    return ((ModuleExtensionWithSdkOrderEntry)object).getSdkName();
  }
  else if (object instanceof LibraryOrderEntry) {
    final String libraryName = ((LibraryOrderEntry)object).getLibraryName();
    return libraryName != null ? libraryName : AnalysisScopeBundle.message("package.dependencies.library.node.text");
  }
  else if (object instanceof ModuleOrderEntry) {
    final ModuleOrderEntry moduleOrderEntry = (ModuleOrderEntry)object;
    return moduleOrderEntry.getModuleName();
  }
  return null;
}
 
Example 6
Source File: UniqueVFilePathBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getUniqueVirtualFilePath(Project project, VirtualFile vFile) {
  return vFile.getPresentableName();
}
 
Example 7
Source File: UniqueVFilePathBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public String getUniqueVirtualFilePathWithinOpenedFileEditors(Project project, VirtualFile vFile) {
  return vFile.getPresentableName();
}