Search in sources :

Example 1 with LibraryDependencyNode

use of com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.LibraryDependencyNode in project android by JetBrains.

the class DependenciesTreeRootNode method createChildren.

@Override
@NotNull
protected List<? extends AbstractPsModelNode> createChildren() {
    T model = getFirstModel();
    DependencyCollector collector = myDependencyCollectorFunction.apply(model);
    List<AbstractDependencyNode> children = Lists.newArrayList();
    for (Map.Entry<LibraryDependencySpecs, List<PsLibraryAndroidDependency>> entry : collector.libraryDependenciesBySpec.entrySet()) {
        LibraryDependencyNode child = new LibraryDependencyNode(this, entry.getValue());
        children.add(child);
    }
    for (Map.Entry<String, List<PsModuleAndroidDependency>> entry : collector.moduleDependenciesByGradlePath.entrySet()) {
        ModuleDependencyNode child = new ModuleDependencyNode(this, entry.getValue());
        children.add(child);
    }
    Collections.sort(children, DependencyNodeComparator.INSTANCE);
    return children;
}
Also used : AbstractDependencyNode(com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.AbstractDependencyNode) LibraryDependencyNode(com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.LibraryDependencyNode) ModuleDependencyNode(com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.ModuleDependencyNode) List(java.util.List) Map(java.util.Map) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with LibraryDependencyNode

use of com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.LibraryDependencyNode in project android by JetBrains.

the class DependenciesTreeBuilder method find.

@Nullable
public LibraryDependencyNode find(@NotNull PsArtifactDependencySpec spec) {
    DefaultMutableTreeNode rootNode = getRootNode();
    if (rootNode == null) {
        return null;
    }
    int childCount = rootNode.getChildCount();
    for (int i = 0; i < childCount; i++) {
        TreeNode child = rootNode.getChildAt(i);
        if (!(child instanceof DefaultMutableTreeNode)) {
            continue;
        }
        Object userObject = ((DefaultMutableTreeNode) child).getUserObject();
        if (!(userObject instanceof LibraryDependencyNode)) {
            continue;
        }
        LibraryDependencyNode node = (LibraryDependencyNode) userObject;
        for (PsLibraryAndroidDependency dependency : node.getModels()) {
            if (spec.equals(dependency.getDeclaredSpec())) {
                return node;
            }
        }
    }
    return null;
}
Also used : LibraryDependencyNode(com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.LibraryDependencyNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) PsLibraryAndroidDependency(com.android.tools.idea.gradle.structure.model.android.PsLibraryAndroidDependency) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

LibraryDependencyNode (com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.LibraryDependencyNode)2 AbstractDependencyNode (com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.AbstractDependencyNode)1 ModuleDependencyNode (com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.ModuleDependencyNode)1 PsLibraryAndroidDependency (com.android.tools.idea.gradle.structure.model.android.PsLibraryAndroidDependency)1 List (java.util.List)1 Map (java.util.Map)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreeNode (javax.swing.tree.TreeNode)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1