use of com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance in project intellij-community by JetBrains.
the class OrderEntryAppearanceServiceImpl method forOrderEntry.
@NotNull
@Override
public CellAppearanceEx forOrderEntry(Project project, @NotNull final OrderEntry orderEntry, final boolean selected) {
if (orderEntry instanceof JdkOrderEntry) {
JdkOrderEntry jdkLibraryEntry = (JdkOrderEntry) orderEntry;
Sdk jdk = jdkLibraryEntry.getJdk();
if (!orderEntry.isValid()) {
final String oldJdkName = jdkLibraryEntry.getJdkName();
return FileAppearanceService.getInstance().forInvalidUrl(oldJdkName != null ? oldJdkName : NO_JDK);
}
return forJdk(jdk, false, selected, true);
} else if (!orderEntry.isValid()) {
return FileAppearanceService.getInstance().forInvalidUrl(orderEntry.getPresentableName());
} else if (orderEntry instanceof LibraryOrderEntry) {
LibraryOrderEntry libraryOrderEntry = (LibraryOrderEntry) orderEntry;
if (!libraryOrderEntry.isValid()) {
//library can be removed
return FileAppearanceService.getInstance().forInvalidUrl(orderEntry.getPresentableName());
}
Library library = libraryOrderEntry.getLibrary();
assert library != null : libraryOrderEntry;
return forLibrary(project, library, !((LibraryEx) library).getInvalidRootUrls(OrderRootType.CLASSES).isEmpty());
} else if (orderEntry.isSynthetic()) {
String presentableName = orderEntry.getPresentableName();
Icon icon = orderEntry instanceof ModuleSourceOrderEntry ? sourceFolderIcon(false) : null;
return new SimpleTextCellAppearance(presentableName, icon, SimpleTextAttributes.SYNTHETIC_ATTRIBUTES);
} else if (orderEntry instanceof ModuleOrderEntry) {
final Icon icon = ModuleType.get(((ModuleOrderEntry) orderEntry).getModule()).getIcon();
return SimpleTextCellAppearance.regular(orderEntry.getPresentableName(), icon);
} else {
return CompositeAppearance.single(orderEntry.getPresentableName());
}
}
use of com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance in project intellij-community by JetBrains.
the class OrderEntryAppearanceServiceImpl method formatRelativePath.
@NotNull
private static CellAppearanceEx formatRelativePath(@NotNull final ContentFolder folder, @NotNull final Icon icon) {
LightFilePointer folderFile = new LightFilePointer(folder.getUrl());
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(folder.getContentEntry().getUrl());
if (file == null)
return FileAppearanceService.getInstance().forInvalidUrl(folderFile.getPresentableUrl());
String contentPath = file.getPath();
String relativePath;
SimpleTextAttributes textAttributes;
VirtualFile folderFileFile = folderFile.getFile();
if (folderFileFile == null) {
String absolutePath = folderFile.getPresentableUrl();
relativePath = absolutePath.startsWith(contentPath) ? absolutePath.substring(contentPath.length()) : absolutePath;
textAttributes = SimpleTextAttributes.ERROR_ATTRIBUTES;
} else {
relativePath = VfsUtilCore.getRelativePath(folderFileFile, file, File.separatorChar);
textAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES;
}
relativePath = StringUtil.isEmpty(relativePath) ? "." + File.separatorChar : relativePath;
return new SimpleTextCellAppearance(relativePath, icon, textAttributes);
}
Aggregations