Example usage for javax.swing.tree DefaultMutableTreeNode getUserObject

List of usage examples for javax.swing.tree DefaultMutableTreeNode getUserObject

Introduction

In this page you can find the example usage for javax.swing.tree DefaultMutableTreeNode getUserObject.

Prototype

public Object getUserObject() 

Source Link

Document

Returns this node's user object.

Usage

From source file:com.pironet.tda.SunJDKParser.java

private void renormalizeMonitorDepth(DefaultMutableTreeNode monitorNode, int index) {
    // First, remove all duplicates of the item at index "index"
    DefaultMutableTreeNode threadNode1 = (DefaultMutableTreeNode) monitorNode.getChildAt(index);
    ThreadInfo mi1 = (ThreadInfo) threadNode1.getUserObject();
    int i = index + 1;
    while (i < monitorNode.getChildCount()) {
        DefaultMutableTreeNode threadNode2 = (DefaultMutableTreeNode) monitorNode.getChildAt(i);
        ThreadInfo mi2 = (ThreadInfo) threadNode2.getUserObject();
        if (mi1.getName().equals(mi2.getName())) {
            if (threadNode2.getChildCount() > 0) {
                threadNode1.add((DefaultMutableTreeNode) threadNode2.getFirstChild());
                monitorNode.remove(i);/*from  w  ww . j av  a 2s.  co  m*/
                continue;
            }
        }
        i++;
    }

    // Second, recurse into item "index"
    renormalizeThreadDepth(threadNode1);
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public void updateGavs(DefaultMutableTreeNode node) {
    Project project = (Project) node.getUserObject();
    if (project.getNewGav() != null) {
        project.setGav(project.getNewGav());
    }//w w w  . j  a v  a  2s  .  c om
    Enumeration<?> children = node.children();
    while (children.hasMoreElements()) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
        Project childProject = (Project) child.getUserObject();
        String oldParentVersion = childProject.getParent().getVersion();
        String newParentVersion = getVersion(node);
        if (!oldParentVersion.equals(newParentVersion)) {
            childProject.getParent().setVersion(newParentVersion);
        }
        updateGavs(child);
    }
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public String getDisplayString(DefaultMutableTreeNode node) {
    Project project = (Project) node.getUserObject();
    GAV gav = project.getGav();/*  ww  w. jav a2 s.  co  m*/
    GAV parent = project.getParent();
    int level = node.getLevel();
    StringBuilder sb = new StringBuilder();
    sb.append(StringUtils.repeat(" ", level));
    sb.append(toString(parent));
    sb.append(" -> ");
    sb.append(toString(gav));
    sb.append("\n");
    Enumeration<?> children = node.children();
    while (children.hasMoreElements()) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
        sb.append(getDisplayString(child));
    }
    return sb.toString();
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public void updateXml(DefaultMutableTreeNode node) {
    Project project = (Project) node.getUserObject();
    String version = project.getGav().getVersion();
    if (!StringUtils.isBlank(version)) {
        String oldXml = project.getPomContents();
        String newXml = pomUtils.updateVersion(oldXml, version);
        project.setPomContents(newXml);/*w  ww .  j a v a2 s.com*/
    }
    String parentVersion = project.getParent().getVersion();
    String oldXml = project.getPomContents();
    String newXml = pomUtils.updateParentVersion(oldXml, parentVersion);
    project.setPomContents(newXml);
    Enumeration<?> children = node.children();
    while (children.hasMoreElements()) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement();
        updateXml(child);
    }
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public void incrementVersions(DefaultMutableTreeNode node) {
    Project project = (Project) node.getUserObject();
    GAV gav = project.getGav();//from w  w w  . j a  v  a 2 s  .com
    String oldVersion = gav.getVersion();
    if (!StringUtils.isBlank(oldVersion)) {
        String newVersion = getNextVersion(oldVersion);
        GAV newGav = new GAV();
        newGav.setGroupId(gav.getGroupId());
        newGav.setArtifactId(gav.getArtifactId());
        newGav.setVersion(newVersion);
        project.setNewGav(newGav);
        logger.info(StringUtils.repeat("  ", node.getLevel()) + gav.getArtifactId() + ":" + gav.getArtifactId()
                + ":" + oldVersion + "->" + newVersion);
    }
    List<DefaultMutableTreeNode> children = getChildren(node);
    for (DefaultMutableTreeNode child : children) {
        incrementVersions(child);
    }
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public void fillInGavs(DefaultMutableTreeNode node) {
    Project project = (Project) node.getUserObject();
    GAV gav = project.getGav();//from  www.  j a va 2  s  .co m
    String groupId = getGroupId(node);
    String version = getVersion(node);
    if (gav.getGroupId() == null) {
        gav.setGroupId(groupId);
        logger.debug("Update " + gav.getArtifactId() + "->" + groupId);
    }
    if (gav.getVersion() == null) {
        gav.setVersion(version);
        logger.debug("Update " + gav.getArtifactId() + "->" + version);
    }
    Enumeration<?> e = node.children();
    while (e.hasMoreElements()) {
        DefaultMutableTreeNode child = (DefaultMutableTreeNode) e.nextElement();
        fillInGavs(child);
    }
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public Map<String, DefaultMutableTreeNode> getMap(List<DefaultMutableTreeNode> nodes) {
    Map<String, DefaultMutableTreeNode> map = new HashMap<String, DefaultMutableTreeNode>();
    for (DefaultMutableTreeNode node : nodes) {
        Project project = (Project) node.getUserObject();
        File file = project.getPom();
        map.put(file.getAbsolutePath(), node);
    }//from  ww  w. j a v a2s . c o m
    return map;
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

protected DefaultMutableTreeNode findNode(List<DefaultMutableTreeNode> nodes, String artifactId) {
    for (DefaultMutableTreeNode node : nodes) {
        Project project = (Project) node.getUserObject();
        if (project.getGav().getArtifactId().equals(artifactId)) {
            return node;
        }/*ww  w .  j  a va 2  s. c  om*/
    }
    throw new IllegalStateException("Unable to locate " + artifactId);
}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public DefaultMutableTreeNode addNode(QueryInstanceData node, DefaultMutableTreeNode parent) {
    QueryMasterData logicdata = (QueryMasterData) parent.getUserObject();
    logicdata.runs.add(node);/* w  w w  . ja  v a  2  s.  c  o m*/

    DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(node);

    QueryInstanceData tmpData = new QueryInstanceData();
    tmpData.name("working ......");
    tmpData.tooltip("A tmp node");
    tmpData.visualAttribute("LAO");
    DefaultMutableTreeNode tmpNode = new DefaultMutableTreeNode(tmpData);

    treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
    if (!(node.visualAttribute().startsWith("L") || node.visualAttribute().equalsIgnoreCase("MA"))) {
        treeModel.insertNodeInto(tmpNode, childNode, childNode.getChildCount());
    }
    //Make sure the user can see the lovely new node.
    jTree1.scrollPathToVisible(new TreePath(childNode.getPath()));

    DefaultMutableTreeNode tmpnode = (DefaultMutableTreeNode) parent.getChildAt(0);
    QueryData tmpdata = (QueryData) tmpnode.getUserObject();
    if (tmpdata.name().equalsIgnoreCase("working ......")) {
        treeModel.removeNodeFromParent(tmpnode);
    }

    return childNode;
}

From source file:org.kuali.maven.plugins.externals.MojoHelper.java

public void updateScm(DefaultMutableTreeNode root, String scmUrlPrefix) {
    Project project = (Project) root.getUserObject();
    BuildTag buildTag = project.getBuildTag();
    String url = buildTag.getTagUrl();
    String oldXml = project.getPomContents();
    String newXml = pomUtils.updateScm(oldXml, scmUrlPrefix, url);
    project.setPomContents(newXml);/*from  w  w w.ja v a 2 s . c o m*/
}