Search in sources :

Example 16 with CheckedTreeNode

use of com.intellij.ui.CheckedTreeNode 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

CheckedTreeNode (com.intellij.ui.CheckedTreeNode)16 Module (com.intellij.openapi.module.Module)6 FlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration)4 Enumeration (java.util.Enumeration)4 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)4 AndroidLibrary (com.android.builder.model.AndroidLibrary)2 AndroidProject (com.android.builder.model.AndroidProject)2 Variant (com.android.builder.model.Variant)2 VariantCheckboxTreeCellRenderer (com.android.tools.idea.gradle.variant.ui.VariantCheckboxTreeCellRenderer)2 Project (com.intellij.openapi.project.Project)2 CheckboxTree (com.intellij.ui.CheckboxTree)2 BreakpointItem (com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem)2 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)2 NotNull (org.jetbrains.annotations.NotNull)2 PostfixTemplate (com.intellij.codeInsight.template.postfix.templates.PostfixTemplate)1 DetectedFrameworkDescription (com.intellij.framework.detection.DetectedFrameworkDescription)1 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)1 TreeState (com.intellij.ide.util.treeView.TreeState)1 Language (com.intellij.lang.Language)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1