Search in sources :

Example 11 with CheckedTreeNode

use of com.intellij.ui.CheckedTreeNode in project intellij-community by JetBrains.

the class BreakpointItemsTreeController method buildTree.

public void buildTree(@NotNull Collection<? extends BreakpointItem> breakpoints) {
    final TreeState state = TreeState.createOn(myTreeView, myRoot);
    myRoot.removeAllChildren();
    myNodes.clear();
    myGroups.clear();
    for (BreakpointItem breakpoint : breakpoints) {
        BreakpointItemNode node = new BreakpointItemNode(breakpoint);
        CheckedTreeNode parent = getParentNode(breakpoint);
        parent.add(node);
        myNodes.put(breakpoint, node);
    }
    TreeUtil.sortRecursively(myRoot, myComparator);
    myInBuild = true;
    ((DefaultTreeModel) (myTreeView.getModel())).nodeStructureChanged(myRoot);
    state.applyTo(myTreeView, myRoot);
    myInBuild = false;
}
Also used : TreeState(com.intellij.ide.util.treeView.TreeState) BreakpointItem(com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 12 with CheckedTreeNode

use of com.intellij.ui.CheckedTreeNode in project android by JetBrains.

the class ModuleVariantsInfoDialog method createDependentsTree.

@NotNull
private static JTree createDependentsTree(@NotNull Module module, @NotNull AndroidModuleModel androidModel) {
    VariantCheckboxTreeCellRenderer renderer = new VariantCheckboxTreeCellRenderer() {

        @Override
        public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (value instanceof DefaultMutableTreeNode) {
                Object data = ((DefaultMutableTreeNode) value).getUserObject();
                if (data instanceof String) {
                    appendVariant((String) data);
                } else if (data instanceof DependentTreeElement) {
                    DependentTreeElement dependent = (DependentTreeElement) data;
                    String variant = null;
                    if (!dependent.myVariants.isEmpty()) {
                        variant = Joiner.on(", ").join(dependent.myVariants);
                    }
                    appendModule(dependent.myModule, variant);
                }
            }
        }
    };
    //noinspection ConstantConditions
    CheckedTreeNode root = new CheckedTreeNode(null);
    AndroidProject androidProject = GradleUtil.getAndroidProject(module);
    assert androidProject != null;
    String gradlePath = GradleUtil.getGradlePath(module);
    assert gradlePath != null;
    Multimap<String, DependentTreeElement> dependentsByVariant = HashMultimap.create();
    ModuleManager moduleManager = ModuleManager.getInstance(module.getProject());
    for (Module dependent : moduleManager.getModuleDependentModules(module)) {
        AndroidProject dependentProject = GradleUtil.getAndroidProject(dependent);
        if (dependentProject == null) {
            continue;
        }
        DependentTreeElement element = new DependentTreeElement(dependent);
        for (Variant variant : dependentProject.getVariants()) {
            for (AndroidLibrary library : GradleUtil.getDirectLibraryDependencies(variant, androidModel)) {
                if (gradlePath.equals(library.getProject())) {
                    element.addVariant(variant.getName());
                    String projectVariant = library.getProjectVariant();
                    if (StringUtil.isNotEmpty(projectVariant)) {
                        dependentsByVariant.put(projectVariant, element);
                    }
                }
            }
        }
    }
    List<String> variantNames = Lists.newArrayList(dependentsByVariant.keySet());
    Collections.sort(variantNames);
    for (String variantName : variantNames) {
        Collection<DependentTreeElement> dependents = dependentsByVariant.get(variantName);
        if (!dependents.isEmpty()) {
            List<DependentTreeElement> sortedDependents = Lists.newArrayList(dependents);
            Collections.sort(sortedDependents);
            DefaultMutableTreeNode variantNode = new DefaultMutableTreeNode(variantName);
            for (DependentTreeElement dependent : dependents) {
                variantNode.add(new DefaultMutableTreeNode(dependent));
            }
            root.add(variantNode);
        }
    }
    CheckboxTree tree = new CheckboxTree(renderer, root);
    tree.setRootVisible(false);
    TreeUtil.expandAll(tree);
    return tree;
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) CheckboxTree(com.intellij.ui.CheckboxTree) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) AndroidProject(com.android.builder.model.AndroidProject) ModuleManager(com.intellij.openapi.module.ModuleManager) Variant(com.android.builder.model.Variant) AndroidLibrary(com.android.builder.model.AndroidLibrary) Module(com.intellij.openapi.module.Module) VariantCheckboxTreeCellRenderer(com.android.tools.idea.gradle.variant.ui.VariantCheckboxTreeCellRenderer) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with CheckedTreeNode

use of com.intellij.ui.CheckedTreeNode in project intellij-plugins by JetBrains.

the class FlexBCTree method iterateRecursively.

private static void iterateRecursively(final CheckedTreeNode node, final boolean iterateChecked, final Consumer<Pair<Module, FlexBuildConfiguration>> consumer) {
    if (node.isLeaf()) {
        if (node.isChecked() == iterateChecked && node.getParent() instanceof CheckedTreeNode) {
            final Object userObject = node.getUserObject();
            final Object parentUserObject = ((CheckedTreeNode) node.getParent()).getUserObject();
            if (userObject instanceof FlexBuildConfiguration && parentUserObject instanceof Module) {
                consumer.consume(Pair.create((Module) parentUserObject, (FlexBuildConfiguration) userObject));
            }
        }
    } else {
        // do not try to optimize asking non-leaf node about its checked status - it may give unexpected result!
        final Enumeration children = node.children();
        while (children.hasMoreElements()) {
            iterateRecursively((CheckedTreeNode) children.nextElement(), iterateChecked, consumer);
        }
    }
}
Also used : Enumeration(java.util.Enumeration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) Module(com.intellij.openapi.module.Module)

Example 14 with CheckedTreeNode

use of com.intellij.ui.CheckedTreeNode in project intellij-plugins by JetBrains.

the class FlexBCTree method installSpeedSearch.

protected void installSpeedSearch() {
    new TreeSpeedSearch(this, path -> {
        final CheckedTreeNode node = (CheckedTreeNode) path.getLastPathComponent();
        final Object userObject = node.getUserObject();
        if (userObject instanceof Project) {
            return ((Project) userObject).getName();
        } else if (userObject instanceof Module) {
            return ((Module) userObject).getName();
        } else if (userObject instanceof FlexBuildConfiguration) {
            return ((FlexBuildConfiguration) userObject).getName();
        }
        return null;
    });
}
Also used : Project(com.intellij.openapi.project.Project) TreeSpeedSearch(com.intellij.ui.TreeSpeedSearch) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) Module(com.intellij.openapi.module.Module)

Example 15 with CheckedTreeNode

use of com.intellij.ui.CheckedTreeNode in project intellij-plugins by JetBrains.

the class FlexBCTree method getBCNode.

private CheckedTreeNode getBCNode(final String moduleName, final String bcName) {
    final Enumeration moduleNodes = ((CheckedTreeNode) getModel().getRoot()).children();
    while (moduleNodes.hasMoreElements()) {
        final CheckedTreeNode moduleNode = (CheckedTreeNode) moduleNodes.nextElement();
        final Object userObject = moduleNode.getUserObject();
        if (userObject instanceof Module && ((Module) userObject).getName().equals(moduleName)) {
            final Enumeration bcNodes = moduleNode.children();
            while (bcNodes.hasMoreElements()) {
                final CheckedTreeNode bcNode = (CheckedTreeNode) bcNodes.nextElement();
                final Object bcUserObject = bcNode.getUserObject();
                if (bcUserObject instanceof FlexBuildConfiguration && ((FlexBuildConfiguration) bcUserObject).getName().equals(bcName)) {
                    return bcNode;
                }
            }
            return null;
        }
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) FlexBuildConfiguration(com.intellij.lang.javascript.flex.projectStructure.model.FlexBuildConfiguration) CheckedTreeNode(com.intellij.ui.CheckedTreeNode) Module(com.intellij.openapi.module.Module)

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