Search in sources :

Example 61 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer 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 62 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer 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)

Example 63 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-plugins by JetBrains.

the class StrutsModelFactory method computeAllModels.

protected List<StrutsModel> computeAllModels(@NotNull final Module module) {
    final PsiManager psiManager = PsiManager.getInstance(module.getProject());
    final StrutsManager strutsManager = StrutsManager.getInstance(module.getProject());
    final Set<StrutsFileSet> fileSets = strutsManager.getAllConfigFileSets(module);
    final List<StrutsModel> models = new ArrayList<>(fileSets.size());
    for (final StrutsFileSet set : fileSets) {
        if (set.isRemoved()) {
            continue;
        }
        final Set<XmlFile> files = new LinkedHashSet<>(set.getFiles().size());
        for (final VirtualFilePointer filePointer : set.getFiles()) {
            if (!filePointer.isValid())
                continue;
            final VirtualFile file = filePointer.getFile();
            if (file == null) {
                continue;
            }
            final PsiFile psiFile = psiManager.findFile(file);
            if (psiFile instanceof XmlFile) {
                final StrutsRoot strutsRootDom = getDom((XmlFile) psiFile);
                if (strutsRootDom != null) {
                    files.add((XmlFile) psiFile);
                // TODO           addIncludes(files, strutsRootDom);
                }
            }
        }
        if (!files.isEmpty()) {
            final DomFileElement<StrutsRoot> element = createMergedModelRoot(files);
            final StrutsModel model;
            if (element != null) {
                model = new StrutsModelImpl(element, files);
                models.add(model);
            }
        }
    }
    return models;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) ArrayList(java.util.ArrayList) PsiManager(com.intellij.psi.PsiManager) StrutsFileSet(com.intellij.struts2.facet.ui.StrutsFileSet) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) PsiFile(com.intellij.psi.PsiFile) StrutsRoot(com.intellij.struts2.dom.struts.StrutsRoot)

Example 64 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-plugins by JetBrains.

the class StrutsFacetConfiguration method writeExternal.

public void writeExternal(final Element element) throws WriteExternalException {
    for (final StrutsFileSet fileSet : myFileSets) {
        final Element setElement = new Element(FILESET);
        setElement.setAttribute(SET_ID, fileSet.getId());
        setElement.setAttribute(SET_NAME, fileSet.getName());
        setElement.setAttribute(SET_REMOVED, Boolean.toString(fileSet.isRemoved()));
        element.addContent(setElement);
        for (final VirtualFilePointer fileName : fileSet.getFiles()) {
            final Element fileElement = new Element(FILE);
            fileElement.setText(fileName.getUrl());
            setElement.addContent(fileElement);
        }
    }
    final Element propertiesElement = new Element(PROPERTIES_KEYS);
    propertiesElement.setAttribute(PROPERTIES_KEYS_DISABLED, Boolean.toString(myPropertiesKeysDisabled));
    element.addContent(propertiesElement);
}
Also used : Element(org.jdom.Element) StrutsFileSet(com.intellij.struts2.facet.ui.StrutsFileSet) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer)

Example 65 with VirtualFilePointer

use of com.intellij.openapi.vfs.pointers.VirtualFilePointer in project intellij-plugins by JetBrains.

the class StrutsFileSet method addFile.

public void addFile(@NonNls final String url) {
    if (!StringUtil.isEmptyOrSpaces(url)) {
        final VirtualFilePointer filePointer = VirtualFilePointerManager.getInstance().create(url, this, null);
        files.add(filePointer);
    }
}
Also used : VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer)

Aggregations

VirtualFilePointer (com.intellij.openapi.vfs.pointers.VirtualFilePointer)66 MockVirtualFile (com.intellij.mock.MockVirtualFile)23 File (java.io.File)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 NotNull (org.jetbrains.annotations.NotNull)12 VirtualFilePointerContainer (com.intellij.openapi.vfs.pointers.VirtualFilePointerContainer)11 IOException (java.io.IOException)8 Disposable (com.intellij.openapi.Disposable)7 VirtualFilePointerListener (com.intellij.openapi.vfs.pointers.VirtualFilePointerListener)6 ArrayList (java.util.ArrayList)5 Element (org.jdom.Element)5 Nullable (org.jetbrains.annotations.Nullable)4 Job (com.intellij.concurrency.Job)3 FileEditorProvider (com.intellij.openapi.fileEditor.FileEditorProvider)3 FileEditorState (com.intellij.openapi.fileEditor.FileEditorState)3 VirtualFilePointerManager (com.intellij.openapi.vfs.pointers.VirtualFilePointerManager)3 JobLauncher (com.intellij.concurrency.JobLauncher)2 ApplicationManager (com.intellij.openapi.application.ApplicationManager)2 PathManagerEx (com.intellij.openapi.application.ex.PathManagerEx)2 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)2