Search in sources :

Example 1 with CTaggedGraphNodesContainerNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTaggedGraphNodesContainerNode in project binnavi by google.

the class CRootTagTreeNode method refreshTree.

/**
   * Rebuilds the entire tree from scratch by filtering over all elements in the graph. This is
   * pretty damn slow for any reasonably-sized graph, and should hence be done only rarely.
   * @deprecated
   */
@Deprecated
@Override
public void refreshTree(final ITreeNode<CTag> tag) {
    final List<DefaultMutableTreeNode> lastNodes = TreeHelpers.getLastExpandedNodes(m_tagsTree);
    final List<Integer> lastNodeIds = new ArrayList<Integer>();
    if ((tag != null) && (tag.getParent() != null)) {
        lastNodeIds.add(tag.getParent().getObject().getId());
    }
    for (final DefaultMutableTreeNode lastNode : lastNodes) {
        if (lastNode.getUserObject() instanceof Integer) {
            final int tagId = (Integer) lastNode.getUserObject();
            lastNodeIds.add(tagId);
        }
    }
    deleteChildren();
    createChildren();
    final Enumeration<?> bfn = breadthFirstEnumeration();
    while (bfn.hasMoreElements()) {
        final Object node = bfn.nextElement();
        int tagId = -1;
        TreePath path = null;
        if (node instanceof CRootTagTreeNode) {
            final CRootTagTreeNode rootNode = (CRootTagTreeNode) node;
            tagId = m_rootTag.getObject().getId();
            path = new TreePath(rootNode.getPath());
        } else if (node instanceof CTagTreeNode) {
            final CTagTreeNode treeNode = (CTagTreeNode) node;
            tagId = treeNode.getTag().getObject().getId();
            path = new TreePath(treeNode.getPath());
        } else if (node instanceof CTaggedGraphNodesContainerNode) {
            final CTaggedGraphNodesContainerNode containerNode = (CTaggedGraphNodesContainerNode) node;
            tagId = -containerNode.getTag().getObject().getId();
            path = new TreePath(containerNode.getPath());
        }
        if (lastNodeIds.contains(tagId)) {
            m_tagsTree.expandPath(path);
        }
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) ArrayList(java.util.ArrayList) CTagTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTagTreeNode) CTaggedGraphNodesContainerNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTaggedGraphNodesContainerNode)

Aggregations

CTagTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTagTreeNode)1 CTaggedGraphNodesContainerNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTaggedGraphNodesContainerNode)1 ArrayList (java.util.ArrayList)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1