Search in sources :

Example 6 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CSelectionTreeCellRenderer method buildToolTip.

/**
   * Builds the tooltip for used for nodes that represent multiple graph nodes.
   *
   * @param nodes The graph nodes that provide the tooltip content.
   *
   * @return The generated tooltip.
   */
private String buildToolTip(final List<NaviNode> nodes) {
    final StringBuilder tooltip = new StringBuilder("<html>");
    boolean first = true;
    for (final NaviNode graphNode : nodes) {
        if (!first) {
            tooltip.append("<br>");
        }
        tooltip.append(CNodesDisplayString.getDisplayString(graphNode));
        first = false;
    }
    return tooltip + "</html>";
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)

Example 7 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CGraphGrouper method getCommonParent.

/**
   * Finds the common parent group of a list of nodes.
   * 
   * @param nodes The list of nodes whose parent group is determined.
   * 
   * @return The common parent group of the nodes or null if there is no such group.
   */
private static INaviGroupNode getCommonParent(final List<NaviNode> nodes) {
    INaviGroupNode parent = null;
    boolean first = true;
    for (final NaviNode node : nodes) {
        if (first) {
            parent = node.getRawNode().getParentGroup();
            first = false;
        } else {
            if (parent != node.getRawNode().getParentGroup()) {
                return null;
            }
        }
    }
    return parent;
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)

Example 8 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CSearchExecuter method startNewSearch.

/**
   * Cycles through an existing search operation.
   *
   * @param parent Parent window used for dialogs.
   * @param editor Combobox editor whose color is changed depending on the search result.
   * @param graph Graph to search through.
   * @param searcher Executes the search over the graph.
   * @param searchString The string to search for.
   * @param zoomToResult True, to zoom to a result. False, to move without zooming.
   */
private static void startNewSearch(final Window parent, final ComboBoxEditor editor, final ZyGraph graph, final GraphSearcher searcher, final String searchString, final boolean zoomToResult) {
    try {
        // Search for all occurrences
        searcher.search(GraphHelpers.getNodes(graph), GraphHelpers.getEdges(graph), searchString);
        if (searcher.getResults().isEmpty()) {
            editor.getEditorComponent().setBackground(BACKGROUND_COLOR_FAIL);
        } else {
            editor.getEditorComponent().setBackground(BACKGROUND_COLOR_SUCCESS);
        }
        // Immediately display all search occurrences
        for (final SearchResult result : searcher.getResults()) {
            if (result.getObject() instanceof NaviNode) {
                final NaviNode node = (NaviNode) result.getObject();
                node.setBackgroundColor(result.getLine(), result.getPosition(), result.getLength(), Color.YELLOW);
            } else if (result.getObject() instanceof NaviEdge) {
                final NaviEdge edge = (NaviEdge) result.getObject();
                edge.getLabelContent().getLineContent(result.getLine()).setBackgroundColor(result.getPosition(), result.getLength(), Color.YELLOW);
            }
        }
        final SearchResult result = searcher.getCursor().current();
        if (result != null) {
            if (result.getObject() instanceof NaviNode) {
                ZyGraphHelpers.centerNode(graph, (NaviNode) result.getObject(), zoomToResult);
            } else if (result.getObject() instanceof NaviEdge) {
                ZyGraphHelpers.centerEdgeLabel(graph, (NaviEdge) result.getObject(), zoomToResult);
            }
        }
        graph.updateGraphViews();
    } catch (final PatternSyntaxException exception) {
        // Do not bother to log this
        CMessageBox.showInformation(parent, String.format("Invalid Regular Expression '%s'", searchString));
    }
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) SearchResult(com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 9 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CTaggedGraphNodesContainerNode method toString.

@Override
public String toString() {
    int selected = 0;
    int visible = 0;
    int invisible = 0;
    for (final NaviNode n : getGraphNodes()) {
        if (n.getRawNode().isSelected()) {
            selected++;
        }
        if (n.getRawNode().isVisible()) {
            visible++;
        } else {
            invisible++;
        }
    }
    return String.format("Tagged Nodes (%d/%d/%d/%d)", selected, visible, invisible, visible + invisible);
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)

Example 10 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CNodeDeleter method removeSelectedNodesKeepEdges.

/**
   * Removes the selected nodes from the graph and adds edges between the children of the selected
   * nodes and their parents.
   *
   * @param graph The graph from which the selected nodes are deleted.
   */
public static void removeSelectedNodesKeepEdges(final ZyGraph graph) {
    Preconditions.checkNotNull(graph, "IE01733: Graph argument can not be null");
    final List<NaviNode> selectedNodes = filterHiddenNodes(graph.getSelectedNodes());
    for (final NaviNode naviNode : selectedNodes) {
        connectParentsWithChildren(graph.getRawView(), naviNode.getRawNode());
    }
    graph.deleteNodes(selectedNodes);
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)

Aggregations

NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)60 Test (org.junit.Test)29 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)19 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)11 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)9 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)9 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)8 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)7 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)6 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)6 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)5 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)5 ArrayList (java.util.ArrayList)5 Node (y.base.Node)5 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)4 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)4 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Edge (y.base.Edge)4