public static CellAppearance forContentEntry(ContentEntry contentEntry) {
return forVirtualFilePointer(new LightFilePointer(contentEntry.getUrl()));
}
public static SimpleTextCellAppearance formatRelativePath(ContentFolder folder, Icon icon) {
VirtualFilePointer contentFile = new LightFilePointer(folder.getContentEntry().getUrl());
VirtualFilePointer folderFile = new LightFilePointer(folder.getUrl());
if (!contentFile.isValid()) return forInvalidVirtualFilePointer(folderFile);
String contentPath = contentFile.getFile().getPath();
char separator = File.separatorChar;
String relativePath;
SimpleTextAttributes textAttributes;
if (!folderFile.isValid()) {
textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
String absolutePath = folderFile.getPresentableUrl();
relativePath =
absolutePath.startsWith(contentPath) ? absolutePath.substring(contentPath.length()) : absolutePath;
}
else {
relativePath = VfsUtil.getRelativePath(folderFile.getFile(), contentFile.getFile(), separator);
textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
if (relativePath == null) relativePath = "";
relativePath = relativePath.length() == 0 ? "." + File.separatorChar : relativePath;
return new SimpleTextCellAppearance(relativePath, icon, textAttributes);