Search in sources :

Example 31 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class FileAssociationsManagerImpl method removeAssociation.

public void removeAssociation(PsiFile file, PsiFile assoc) {
    final VirtualFile virtualFile = file.getVirtualFile();
    if (virtualFile == null)
        return;
    if (assoc.getVirtualFile() == null)
        return;
    for (VirtualFilePointer pointer : myAssociations.keySet()) {
        if (pointer.getUrl().equals(virtualFile.getUrl())) {
            VirtualFilePointerContainer container = myAssociations.get(pointer);
            if (container != null) {
                //noinspection ConstantConditions
                final VirtualFilePointer p = container.findByUrl(assoc.getVirtualFile().getUrl());
                if (p != null) {
                    container.remove(p);
                    if (container.size() == 0) {
                        myAssociations.remove(pointer);
                    }
                    touch();
                }
            }
            return;
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 32 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class FileAssociationsManagerImpl method copy.

private static HashMap<VirtualFilePointer, VirtualFilePointerContainer> copy(FileAssociationsManagerImpl other) {
    final HashMap<VirtualFilePointer, VirtualFilePointerContainer> hashMap = new LinkedHashMap<>();
    final Set<VirtualFilePointer> virtualFilePointers = other.myAssociations.keySet();
    for (VirtualFilePointer pointer : virtualFilePointers) {
        final VirtualFilePointerContainer container = other.myFilePointerManager.createContainer(other.myProject);
        container.addAll(other.myAssociations.get(pointer));
        hashMap.put(other.myFilePointerManager.duplicate(pointer, other.myProject, null), container);
    }
    return hashMap;
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Example 33 with VirtualFilePointerContainer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer in project intellij-community by JetBrains.

the class FileAssociationsManagerImpl method writeExternal.

public void writeExternal(Element element) throws WriteExternalException {
    for (VirtualFilePointer pointer : myAssociations.keySet()) {
        final Element e = new Element("file");
        e.setAttribute("url", pointer.getUrl());
        final VirtualFilePointerContainer container = myAssociations.get(pointer);
        container.writeExternal(e, "association");
        element.addContent(e);
    }
}
Also used : Element(org.jdom.Element) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) VirtualFilePointerContainer(com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)

Aggregations

VirtualFilePointerContainer (com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)33 VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)11 Element (org.jdom.Element)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 OrderRootType (com.intellij.openapi.roots.OrderRootType)4 NotNull (org.jetbrains.annotations.NotNull)4 HashMap (com.intellij.util.containers.HashMap)2 PsiFile (com.intellij.psi.PsiFile)1 PsiManager (com.intellij.psi.PsiManager)1 SmartList (com.intellij.util.SmartList)1 THashSet (gnu.trove.THashSet)1 JpsLibraryRoot (org.jetbrains.jps.model.library.JpsLibraryRoot)1