use of com.intellij.openapi.vfs.impl.LightFilePointer in project intellij-community by JetBrains.
the class NewLibraryEditor method removeRoot.
@Override
public void removeRoot(String url, OrderRootType rootType) {
myRoots.remove(rootType, new LightFilePointer(url));
Iterator<LightFilePointer> iterator = myExcludedRoots.iterator();
while (iterator.hasNext()) {
LightFilePointer pointer = iterator.next();
if (!isUnderRoots(pointer.getUrl())) {
iterator.remove();
}
}
myJarDirectories.remove(rootType, url);
}
use of com.intellij.openapi.vfs.impl.LightFilePointer in project intellij-community by JetBrains.
the class HistoryEntry method createLight.
@NotNull
static HistoryEntry createLight(@NotNull VirtualFile file, @NotNull FileEditorProvider[] providers, @NotNull FileEditorState[] states, @NotNull FileEditorProvider selectedProvider) {
VirtualFilePointer pointer = new LightFilePointer(file);
HistoryEntry entry = new HistoryEntry(pointer, selectedProvider, null);
for (int i = 0; i < providers.length; i++) {
entry.putState(providers[i], states[i]);
}
return entry;
}
use of com.intellij.openapi.vfs.impl.LightFilePointer in project intellij-community by JetBrains.
the class NewLibraryEditor method getFiles.
@Override
public VirtualFile[] getFiles(OrderRootType rootType) {
List<VirtualFile> result = new ArrayList<>();
for (LightFilePointer pointer : myRoots.get(rootType)) {
final VirtualFile file = pointer.getFile();
if (file == null) {
continue;
}
if (file.isDirectory()) {
final String url = file.getUrl();
if (myJarDirectories.contains(rootType, url)) {
LibraryImpl.collectJarFiles(file, result, myJarDirectories.isRecursive(rootType, url));
continue;
}
}
result.add(file);
}
return VfsUtilCore.toVirtualFileArray(result);
}
use of com.intellij.openapi.vfs.impl.LightFilePointer in project intellij-community by JetBrains.
the class OrderEntryAppearanceServiceImpl method forLibrary.
@NotNull
@Override
public CellAppearanceEx forLibrary(Project project, @NotNull final Library library, final boolean hasInvalidRoots) {
final StructureConfigurableContext context = ProjectStructureConfigurable.getInstance(project).getContext();
final Icon icon = LibraryPresentationManager.getInstance().getCustomIcon(library, context);
final String name = library.getName();
if (name != null) {
return normalOrRedWaved(name, (icon != null ? icon : PlatformIcons.LIBRARY_ICON), hasInvalidRoots);
}
final String[] files = library.getUrls(OrderRootType.CLASSES);
if (files.length == 0) {
return SimpleTextCellAppearance.invalid(ProjectBundle.message("library.empty.library.item"), PlatformIcons.LIBRARY_ICON);
} else if (files.length == 1) {
return forVirtualFilePointer(new LightFilePointer(files[0]));
}
final String url = StringUtil.trimEnd(files[0], JarFileSystem.JAR_SEPARATOR);
String text = ProjectBundle.message("library.unnamed.text", PathUtil.getFileName(url), files.length - 1);
return SimpleTextCellAppearance.regular(text, PlatformIcons.LIBRARY_ICON);
}
use of com.intellij.openapi.vfs.impl.LightFilePointer 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