Search in sources :

Example 1 with CTagTreeNode

use of com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTagTreeNode 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)

Example 2 with CTagTreeNode

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

the class CTagSortingHandler method drop.

@Override
public void drop(final DNDTree target, final DefaultMutableTreeNode parentNode, final DefaultMutableTreeNode draggedNode) {
    final ITagManager tagManager = ((CTagTreeNode) parentNode).getTagManager();
    final ITreeNode<CTag> parentNodeNode = ((CTagTreeNode) parentNode).getTag();
    final ITreeNode<CTag> draggedNodeNode = ((CTagTreeNode) draggedNode).getTag();
    try {
        tagManager.moveTag(parentNodeNode, draggedNodeNode);
    } catch (final CouldntSaveDataException e) {
        // TODO: Improve this
        CUtilityFunctions.logException(e);
    }
}
Also used : ITagManager(com.google.security.zynamics.binnavi.Tagging.ITagManager) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTagTreeNode)

Aggregations

CTagTreeNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTagTreeNode)2 CouldntSaveDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException)1 CTaggedGraphNodesContainerNode (com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.CTaggedGraphNodesContainerNode)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 ITagManager (com.google.security.zynamics.binnavi.Tagging.ITagManager)1 ArrayList (java.util.ArrayList)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 TreePath (javax.swing.tree.TreePath)1