Search in sources :

Example 1 with LightFilePointer

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);
}
Also used : LightFilePointer(com.intellij.openapi.vfs.impl.LightFilePointer)

Example 2 with LightFilePointer

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;
}
Also used : LightFilePointer(com.intellij.openapi.vfs.impl.LightFilePointer) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with LightFilePointer

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightFilePointer(com.intellij.openapi.vfs.impl.LightFilePointer)

Example 4 with LightFilePointer

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);
}
Also used : StructureConfigurableContext(com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext) LightFilePointer(com.intellij.openapi.vfs.impl.LightFilePointer) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with LightFilePointer

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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) SimpleTextCellAppearance(com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) LightFilePointer(com.intellij.openapi.vfs.impl.LightFilePointer) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LightFilePointer (com.intellij.openapi.vfs.impl.LightFilePointer)6 NotNull (org.jetbrains.annotations.NotNull)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)2 FileEditorProvider (com.intellij.openapi.fileEditor.FileEditorProvider)1 FileEditorState (com.intellij.openapi.fileEditor.FileEditorState)1 StructureConfigurableContext (com.intellij.openapi.roots.ui.configuration.projectRoot.StructureConfigurableContext)1 SimpleTextCellAppearance (com.intellij.openapi.roots.ui.util.SimpleTextCellAppearance)1 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)1