Search in sources :

Example 66 with VirtualFilePointer

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

the class StrutsFilesTree method updateFileSet.

public void updateFileSet(final StrutsFileSet fileSet) {
    final Set<VirtualFile> configured = new HashSet<>();
    TreeUtil.traverse((TreeNode) getModel().getRoot(), node -> {
        final CheckedTreeNode checkedTreeNode = (CheckedTreeNode) node;
        if (!checkedTreeNode.isChecked()) {
            return true;
        }
        final Object object = checkedTreeNode.getUserObject();
        VirtualFile virtualFile = null;
        if (object instanceof XmlFile) {
            virtualFile = ((XmlFile) object).getVirtualFile();
        } else if (object instanceof VirtualFile) {
            virtualFile = (VirtualFile) object;
        }
        if (virtualFile != null) {
            if (!fileSet.hasFile(virtualFile)) {
                fileSet.addFile(virtualFile);
            }
            configured.add(virtualFile);
        }
        return true;
    });
    for (Iterator<VirtualFilePointer> i = fileSet.getFiles().iterator(); i.hasNext(); ) {
        final VirtualFilePointer pointer = i.next();
        final VirtualFile file = pointer.getFile();
        if (file == null || !configured.contains(file)) {
            i.remove();
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) XmlFile(com.intellij.psi.xml.XmlFile) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) VirtualFilePointer(com.intellij.openapi.vfs.pointers.VirtualFilePointer) HashSet(java.util.HashSet)

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