org.apache.maven.shared.dependency.tree.DependencyNode Java Examples

The following examples show how to use org.apache.maven.shared.dependency.tree.DependencyNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TarsBuildMojo.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void collect(final DependencyNode root, final Set<Artifact> artifacts) {
    Stack<DependencyNode> stack = new Stack<DependencyNode>();
    stack.push(root);
    while (!stack.isEmpty()) {
        DependencyNode node = stack.pop();
        if (node.getState() == DependencyNode.INCLUDED) {
            final Artifact artifact = node.getArtifact();
            if (includedScope(artifact.getScope())) {
                getLog().info("Adding Artefact: " + artifact.toString());
                artifacts.add(artifact);
                // check children 
                if (!node.getChildren().isEmpty()) {
                    stack.addAll(node.getChildren());
                }
            }
        }
    }
}
 
Example #2
Source File: DialogFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Messages("TIT_Exclude=Add Dependency Excludes")
public static Map<Artifact, List<Artifact>> showDependencyExcludeDialog(Project prj) {
    NbMavenProject nbproj = prj.getLookup().lookup(NbMavenProject.class);
    final ExcludeDependencyPanel pnl = new ExcludeDependencyPanel(nbproj.getMavenProject());
    DialogDescriptor dd = new DialogDescriptor(pnl, TIT_Exclude());
    pnl.setStatusDisplayer(dd.createNotificationLineSupport());
    Object ret = DialogDisplayer.getDefault().notify(dd);
    if (ret == DialogDescriptor.OK_OPTION) {
        Map<Artifact, List<DependencyNode>> dependencyExcludes = pnl.getDependencyExcludes();
        Map<Artifact, List<Artifact>> toRet = new HashMap<Artifact, List<Artifact>>();
        for (Artifact exclude : dependencyExcludes.keySet()) {
            List<DependencyNode> directs = dependencyExcludes.get(exclude);
            List<Artifact> dirArts = new ArrayList<Artifact>();
            for (DependencyNode nd : directs) {
                dirArts.add(nd.getArtifact());
            }
            if (dirArts.size() > 0) {
                toRet.put(exclude, dirArts);
            }
        }
        return toRet;
    }
    return null;
}
 
Example #3
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Children createTreeChildren(final DependencyNode dn, final Lookup tcLookup) {
    if (!dn.hasChildren()) {
        return Children.LEAF;
    }
    return Children.create(new ChildFactory<DependencyNode>() {

        @Override
        protected Node createNodeForKey(DependencyNode key) {
            return new TreeNode(key, tcLookup);
        }

        @Override
        protected boolean createKeys(List<DependencyNode> toPopulate) {
            toPopulate.addAll(dn.getChildren());
            return true;
        }
    }, false);
}
 
Example #4
Source File: ExcludeDependencyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private TreeNode createReferenceModel(Set<DependencyNode> nds, CheckNode trans) {
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(null, true);
    ChangeListener list = new Listener();
    List<CheckNode> s = new ArrayList<CheckNode>();
    Icon icn = ImageUtilities.image2Icon(ImageUtilities.loadImage(IconResources.DEPENDENCY_ICON, true)); //NOI18N
    change2Trans.put(list, trans);
    change2Refs.put(list, s);
    for (DependencyNode nd : nds) {
        String label = nd.getArtifact().getGroupId() + ":" + nd.getArtifact().getArtifactId();
        CheckNode child = new CheckNode(nd, label, icn);
        child.setSelected(isSingle);
        child.addChangeListener(list);
        s.add(child);
        root.add(child);
    }
    return root;
}
 
Example #5
Source File: ExcludeDependencyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void setReferenceTree(CheckNode mtb) {
    Artifact art = (Artifact) mtb.getUserObject();
    if (modelCache.containsKey(art)) {
        trRef.setModel(modelCache.get(art));
    } else {
        if (rootnode == null) {
            trRef.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
        } else {
            DependencyExcludeNodeVisitor nv = new DependencyExcludeNodeVisitor(art.getGroupId(), art.getArtifactId(), art.getType());
            rootnode.accept(nv);
            Set<DependencyNode> nds = nv.getDirectDependencies();
            DefaultTreeModel dtm = new DefaultTreeModel(createReferenceModel(nds, mtb));
            trRef.setModel(dtm);
            modelCache.put(art, dtm);
        }
    }
}
 
Example #6
Source File: DependencyExcludeNodeVisitor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public boolean visit(DependencyNode node) {
    if (root == null) {
        root = node;
        directs = new HashSet<DependencyNode>();
        path = new Stack<DependencyNode>();
        allPaths = new HashSet<Stack<DependencyNode>>();
        return true;
    }
    path.push(node);
    Artifact artifact = node.getArtifact();
    if (key.equals(artifact.getDependencyConflictId())) {
        if (!path.isEmpty()) {
            directs.add(path.firstElement());
            Stack<DependencyNode> copy = new Stack<DependencyNode>();
            copy.addAll(path);
            allPaths.add(copy);
        }
        return false;
    }
    return true;
}
 
Example #7
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "TIP_Included=Is included",
    "TIP_Conflict=Is omitted for conflict, version used is {0}",
    "TIP_Duplicate=Is omitted for duplicate with the same version",
    "TIP_Cycle=Is omitted for cycle"
})
private static String calculateStateTipPart(DependencyNode node) {
        int s = node.getState();
        if (s == DependencyNode.INCLUDED) {
            return Bundle.TIP_Included();
        } else if (s == DependencyNode.OMITTED_FOR_CONFLICT) {
            return Bundle.TIP_Conflict(node.getRelatedArtifact().getVersion());
        } else if (s == DependencyNode.OMITTED_FOR_DUPLICATE) {
            return Bundle.TIP_Duplicate();
        } else if (s == DependencyNode.OMITTED_FOR_CYCLE) {
            return Bundle.TIP_Cycle();
        }
        throw new IllegalStateException("illegal state:" + s);
    }
 
Example #8
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void populateFields() {
    Iterator<? extends DependencyNode> iter = result.allInstances().iterator();
    if (iter.hasNext()) {
        final DependencyNode root = iter.next();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                NodeVisitor vis = new NodeVisitor(Arrays.asList(new String[]{ Artifact.SCOPE_COMPILE, Artifact.SCOPE_PROVIDED, Artifact.SCOPE_RUNTIME, Artifact.SCOPE_TEST}));
                root.accept(vis);
                vis.getListOfDependencies();
                explorerManager.setRootContext(new AbstractNode(createListChildren(vis.getListOfDependencies(), getLookup())));
                treeExplorerManager.setRootContext(new AbstractNode(createTreeChildren(root, getLookup())));
                ((BeanTreeView)tvTree).expandAll();

            }
        });
    } else {

    }
}
 
Example #9
Source File: DependencyTreeFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static DependencyNode createDependencyTree(MavenProject project,
        DependencyTreeBuilder dependencyTreeBuilder, ArtifactRepository localRepository,
        ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource,
        ArtifactCollector artifactCollector,
        String scope) {
    ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope);

    try {
        // TODO: note that filter does not get applied due to MNG-3236
        return dependencyTreeBuilder.buildDependencyTree(project,
                localRepository, artifactFactory,
                artifactMetadataSource, artifactFilter, artifactCollector);
    } catch (DependencyTreeBuilderException exception) {
    }
    return null;
}
 
Example #10
Source File: MavenActionsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static boolean isFixCandidate (GraphNode<MavenDependencyNode> node) {
    Set<MavenDependencyNode> conf = node.getDuplicatesOrConflicts();
    for (MavenDependencyNode dn : conf) {
        if (dn.getState() == DependencyNode.OMITTED_FOR_CONFLICT) {
            if (node.getImpl().compareVersions(dn) < 0) {
                return true;
            }
        }
    }
    return false;
}
 
Example #11
Source File: HuntBugsMojo.java    From huntbugs with Apache License 2.0 5 votes vote down vote up
private Repository constructRepository() throws IOException {
    Repository repo = new DirRepository(classesDirectory.toPath());
    
    if (!quiet) {
        getLog().info("HuntBugs: +dir " + classesDirectory);
    }

    // collecting project dependencies including pom and transitive dependencies
    ArtifactFilter artifactFilter = new ScopeArtifactFilter("compile");
    DependencyNode rootNode;
    try {
        rootNode = treeBuilder.buildDependencyTree(project, session.getLocalRepository(), artifactFilter);
    } catch (DependencyTreeBuilderException e) {
        throw new RuntimeException(e);
    }
    CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor();
    rootNode.accept(visitor);

    // converting dependencies to type loaders
    List<DependencyNode> nodes = visitor.getNodes();
    List<ITypeLoader> deps = new ArrayList<>();
    for (DependencyNode dependencyNode : nodes) {
        int state = dependencyNode.getState();

        // checking that transitive dependency is NOT excluded
        if (state == DependencyNode.INCLUDED) {
            Artifact artifact = dependencyNode.getArtifact();
            addDependency(artifact, deps);
        }
    }
    
    if (deps.isEmpty()) {
        return repo;
    }
    
    return new CompositeRepository(
        Arrays.asList(repo, new AuxRepository(new CompositeTypeLoader(deps.toArray(new ITypeLoader[0])))));
}
 
Example #12
Source File: DependencyGraphTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override public void componentOpened() {
    super.componentOpened();
    pane.setWheelScrollingEnabled(true);
    add(pane, BorderLayout.CENTER);
    result = getLookup().lookupResult(org.apache.maven.shared.dependency.tree.DependencyNode.class);
    result.addLookupListener(this);
    result2 = getLookup().lookupResult(MavenProject.class);
    result2.addLookupListener(this);
    result3 = getLookup().lookupResult(POMModel.class);
    result3.addLookupListener(this);
    waitForApproval();
}
 
Example #13
Source File: DependencyExcludeNodeVisitor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean endVisit(DependencyNode node) {
    if (root == node) {
        root = null;
        path = null;
        return true;
    }
    path.pop();
    return true;
}
 
Example #14
Source File: AbstractResolveDependencies.java    From extra-enforcer-rules with Apache License 2.0 5 votes vote down vote up
private Set<Artifact> getDependenciesToCheck( MavenProject project, ArtifactRepository localRepository )
{
    Set<Artifact> dependencies = null;
    try
    {
        DependencyNode node = treeBuilder.buildDependencyTree( project, localRepository, null );
        
        if( isSearchTransitive() )
        {
            dependencies  = getAllDescendants( node );
        }
        else if ( node.getChildren() != null )
        {
            dependencies = new HashSet<Artifact>();
            for( DependencyNode depNode : node.getChildren() )
            {
                dependencies.add( depNode.getArtifact() );
            }
        }
    }
    catch ( DependencyTreeBuilderException e )
    {
        // otherwise we need to change the signature of this protected method
        throw new RuntimeException( e );
    }
    return dependencies;
}
 
Example #15
Source File: DependencyResolverVisitor.java    From dependency-mediator with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(final DependencyNode node) {
    final Artifact at = node.getArtifact();
    final int state = node.getState();
    final String key = getQualifiedName(at);
    switch (state) {
        case DependencyNode.INCLUDED:
            resolvedDependenciesByName.put(key, at);
            break;
        case DependencyNode.OMITTED_FOR_CONFLICT:
            DefaultArtifactVersion dav1 = new DefaultArtifactVersion(node.getArtifact()
                    .getVersion());
            DefaultArtifactVersion dav2 = new DefaultArtifactVersion(node.getRelatedArtifact()
                    .getVersion());
            if (isIncompatible(dav1, dav2)) {
                if (conflictDependencyArtifacts.containsKey(key)) {
                    conflictDependencyArtifacts.get(key).add(at);
                    conflictDependencyArtifacts.get(key).add(node.getRelatedArtifact());
                } else {
                    List<Artifact> ats = new ArrayList<Artifact>();
                    ats.add(at);
                    if (!key.equals(getQualifiedName(node.getRelatedArtifact()))) {
                        ats.add(node.getRelatedArtifact());
                    }
                    conflictDependencyArtifacts.put(key, ats);
                }
            }
        case DependencyNode.OMITTED_FOR_CYCLE:
        case DependencyNode.OMITTED_FOR_DUPLICATE:
        default:
            break;
    }
    return true;
}
 
Example #16
Source File: DependencyMediatorMojo.java    From dependency-mediator with Apache License 2.0 5 votes vote down vote up
private void processPackage() throws MojoExecutionException {
    try {
        //Limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.
        ArtifactFilter artifactFilter = createResolvingArtifactFilter();

        DependencyResolver dependencyResolver = new DefaultDependencyResolver();
        DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(project,
                localRepository, artifactFilter);

        DependencyResolutionResult drr = dependencyResolver.resolve(rootNode);

        Map<String, List<Artifact>> conflictDependencyArtifact = drr
                .getConflictDependencyArtifact();
        Map<String, Artifact> results = drr.getResolvedDependenciesByName();
        if (!conflictDependencyArtifact.isEmpty()) {
            Iterator<Entry<String, List<Artifact>>> iter = conflictDependencyArtifact
                    .entrySet().iterator();
            while (iter.hasNext()) {
                Entry<String, List<Artifact>> conflictEntries = iter.next();
                StringBuilder sb = new StringBuilder("Founded conflicting dependency component:");
                List<Artifact> conflictArtifacts = conflictEntries.getValue();
                sb.append(conflictEntries.getKey())
                        .append("\n Resolved version is "
                                + results.get(conflictEntries.getKey()))
                        .append("\n But found conflicting artifact ");
                for (Artifact at : conflictArtifacts) {
                    sb.append(String.format("%s:%s:%s,", at.getGroupId(), at.getArtifactId(),
                            at.getVersion()));
                }
                getLog().warn(sb.subSequence(0, sb.length() - 1));
            }
        }
    } catch (DependencyTreeBuilderException e) {
        throw new MojoExecutionException("Cannot build project dependency ", e);
    }
}
 
Example #17
Source File: ExcludeDependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Map<Artifact, List<DependencyNode>> getDependencyExcludes() {
    Map<Artifact, List<DependencyNode>> toRet = new HashMap<Artifact, List<DependencyNode>>();
    for (ChangeListener list : change2Trans.keySet()) {
        CheckNode trans = change2Trans.get(list);
        List<CheckNode> refs = change2Refs.get(list);
        List<DependencyNode> nds = new ArrayList<DependencyNode>();
        for (CheckNode ref : refs) {
            if (ref.isSelected()) {
                nds.add((DependencyNode)ref.getUserObject());
            }
        }
        toRet.put((Artifact)trans.getUserObject(), nds);
    }
    return toRet;
}
 
Example #18
Source File: DefaultDependencyResolver.java    From dependency-mediator with Apache License 2.0 5 votes vote down vote up
@Override
public DependencyResolutionResult resolve(final DependencyNode rootNode) {
    DependencyResolverVisitor nodeVisitor = new DependencyResolverVisitor();
    rootNode.accept(nodeVisitor);
    return new DefaultDependencyResolutionResult(nodeVisitor.getResolvedDependenciesByName(),
            nodeVisitor.getConflictDependencyArtifacts());
}
 
Example #19
Source File: CreateLibraryPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override boolean endVisit(DependencyNode node) {
    if (root == node) {
        root = null;
        path = null;
        return true;
    }
    path.pop();
    return true;
}
 
Example #20
Source File: CreateLibraryPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("NAME_Library=Library Name")
CreateLibraryPanel(DependencyNode root) {
    initComponents();
    DefaultComboBoxModel mdl = new DefaultComboBoxModel();
    SwingValidationGroup.setComponentName(txtName, NAME_Library());

    for (LibraryManager manager : LibraryManager.getOpenManagers()) {
        mdl.addElement(manager);
    }
    comManager.setModel(mdl);
    comManager.addActionListener(new ActionListener() {
        public @Override void actionPerformed(ActionEvent e) {
            if (vg != null) {
                vg.performValidation();
            }
        }

    });
    comManager.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            LibraryManager man = (LibraryManager) value;
            return super.getListCellRendererComponent(list, man.getDisplayName(), index, isSelected, cellHasFocus);
        }

    });
    trDeps.setCellRenderer(new CheckRenderer(false));
    CheckNodeListener l = new CheckNodeListener(false);
    trDeps.addMouseListener(l);
    trDeps.addKeyListener(l);
    trDeps.setToggleClickCount(0);
    trDeps.setRootVisible(false);
    trDeps.setModel(new DefaultTreeModel(new DefaultMutableTreeNode()));
    rootnode = root;
    trDeps.setModel(new DefaultTreeModel(createDependenciesList()));
    setLibraryName();
}
 
Example #21
Source File: CreateLibraryAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("LBL_CreateLibrary=Create a NetBeans Library from Maven metadata")
public @Override void actionPerformed(ActionEvent e) {
    Iterator<? extends DependencyNode> roots = result.allInstances().iterator();
    if (!roots.hasNext()) {
        return;
    }
    final DependencyNode root = roots.next();
    final MavenProject project = lookup.lookup(MavenProject.class);
    final CreateLibraryPanel pnl = new CreateLibraryPanel(root);
    DialogDescriptor dd = new DialogDescriptor(pnl,  LBL_CreateLibrary());
    pnl.createValidations(dd);

    if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) {
        createRunning = true;
        setEnabled();
        RequestProcessor.getDefault().post(new Runnable() {
            public @Override void run() {
                try {
                    Library lib = createLibrary(pnl.getLibraryManager(), pnl.getLibraryName(), pnl.getIncludeArtifacts(), pnl.isAllSourceAndJavadoc(), project, pnl.getCopyDirectory());
                    if (lib != null) {
                        LibrariesCustomizer.showCustomizer(lib, pnl.getLibraryManager());
                    }
                } finally {
                    createRunning = false;
                    setEnabled();
                }
            }
        });
    }
}
 
Example #22
Source File: CreateLibraryAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Messages("ACT_Library=Create Library")
@java.lang.SuppressWarnings("LeakingThisInConstructor")
public CreateLibraryAction(Lookup lkp) {
    this.lookup = lkp;
    putValue(NAME, ACT_Library());
    //TODO proper icon
    putValue(SMALL_ICON, ImageUtilities.image2Icon(ImageUtilities.loadImage(LIBRARIES_ICON, true))); //NOI18N
    putValue("iconBase", "org/netbeans/modules/maven/actions/libraries.gif"); //NOI18N
    result = lookup.lookupResult(DependencyNode.class);
    setEnabled(result.allInstances().size() > 0);
    result.addLookupListener(this);

}
 
Example #23
Source File: NodeAdapterCollector.java    From Decca with MIT License 5 votes vote down vote up
public boolean visit(DependencyNode node) {

		MavenUtil.i().getLog().debug(node.toNodeString() + " type:" + node.getArtifact().getType() + " version"
				+ node.getArtifact().getVersionRange() + " selected:" + (node.getState() == DependencyNode.INCLUDED));
		
		if(Conf.DEL_LONGTIME) {
			if (longTimeLib.contains(node.getArtifact().getGroupId() + ":" + node.getArtifact().getArtifactId())) {
				return false;
			}
		}
		
		if (Conf.DEL_OPTIONAL) {
			if (node.getArtifact().isOptional()) {
				return false;
			}
		}
		if (MavenUtil.i().getMojo().ignoreProvidedScope) {
			if ("provided".equals(node.getArtifact().getScope())) {
				return false;
			}
		}
		if (MavenUtil.i().getMojo().ignoreTestScope) {
			if ("test".equals(node.getArtifact().getScope())) {
				return false;
			}
		}
		if (MavenUtil.i().getMojo().ignoreRuntimeScope) {
			if ("runtime".equals(node.getArtifact().getScope())) {
				return false;
			}
		}

		nodeAdapters.addNodeAapter(new NodeAdapter(node));
		return true;
	}
 
Example #24
Source File: NodeAdapters.java    From Decca with MIT License 5 votes vote down vote up
/**
 * 根据node获得对应的adapter
 * 
 * @param node
 */
public NodeAdapter getNodeAdapter(DependencyNode node) {
	for (NodeAdapter nodeAdapter : container) {
		if (nodeAdapter.isSelf(node))
			return nodeAdapter;
	}
	MavenUtil.i().getLog().warn("cant find nodeAdapter for node:" + node.toNodeString());
	return null;
}
 
Example #25
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Children createListChildren(final Collection<DependencyNode> dns, final Lookup tcLookup) {
    return Children.create(new ChildFactory<DependencyNode>() {

        @Override
        protected Node createNodeForKey(DependencyNode key) {
            return new ListNode(key, tcLookup);
        }

        @Override
        protected boolean createKeys(List<DependencyNode> toPopulate) {
            toPopulate.addAll(dns);
            return true;
        }
    }, false);
}
 
Example #26
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({"TIP_listNode=<html><i>GroupId:</i> <b>{0}</b><br/><i>ArtifactId:</i> <b>{1}</b><br/><i>Version:</i> <b>{2}</b><br/><i>State:</i> <b>{3}</b><br/></html>"})
public ListNode(DependencyNode node, final Lookup tcLookup) {
    super(Children.LEAF, Lookups.fixed(node));
    this.tcLookup = tcLookup;
    this.node = node;
    final Artifact artifact = node.getArtifact();
    setName(artifact.getId());
    setDisplayName(artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension());
    if (node.getDepth() > 1) {
        setIconBaseWithExtension(IconResources.TRANSITIVE_DEPENDENCY_ICON);
    } else {
        setIconBaseWithExtension(IconResources.ICON_DEPENDENCY_JAR);
    }
    setShortDescription(Bundle.TIP_listNode(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), calculateStateTipPart(node)));
}
 
Example #27
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public String getHtmlDisplayName() {
    if (node.getState() == DependencyNode.OMITTED_FOR_DUPLICATE) {
        return "<html><s>" + getDisplayName() + "</s></html>";
    }
    if (node.getState() == DependencyNode.OMITTED_FOR_CONFLICT) {
        return "<html><font color=\"!nb.errorForeground\"><s>" + getDisplayName() + "</s></font></html>";
    }
    return super.getHtmlDisplayName(); //To change body of generated methods, choose Tools | Templates.
}
 
Example #28
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TreeNode(DependencyNode node, final Lookup tcLookup) {
    super(createTreeChildren(node, tcLookup), Lookups.fixed(node));
    this.tcLookup = tcLookup;
    final Artifact artifact = node.getArtifact();
    setName(artifact.getId());
    this.node = node;
    setDisplayName(artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getArtifactHandler().getExtension());
    if (node.getDepth() > 1) {
        setIconBaseWithExtension(IconResources.TRANSITIVE_DEPENDENCY_ICON);
    } else {
        setIconBaseWithExtension(IconResources.ICON_DEPENDENCY_JAR);
    }
    setShortDescription(Bundle.TIP_listNode(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), calculateStateTipPart(node)));
}
 
Example #29
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean endVisit(DependencyNode node) {
    if (root == node) {
        root = null;
        return true;
    }
    return true;
}
 
Example #30
Source File: DependencyPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(DependencyNode node) {
    if (root == null) {
        root = node;
        lst = new ArrayList<DependencyNode>();
    }
    for (DependencyNode ch : node.getChildren()) {
        if (ch.getState() == DependencyNode.INCLUDED &&
                scopes.contains(ch.getArtifact().getScope())) {
            lst.add(ch);
        }
    }
    return true;
}