Search in sources :

Example 6 with ZyLabelContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.

the class CDefaultNodePressedLeftAction method execute.

@Override
public void execute(final CNodePressedLeftState<NodeType, EdgeType> state, final MouseEvent event) {
    final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
    final NodeType draggedNode = graph.getNode(state.getNode());
    if (draggedNode != null) {
        final ZyLabelContent labelContent = draggedNode.getRealizer().getNodeContent();
        if (graph.getEditMode().getLabelEventHandler().isActiveLabel(labelContent)) {
            CEditNodeHelper.setCaretStart(graph, state.getNode(), event);
            CEditNodeHelper.setCaretEnd(graph, state.getNode(), event);
        } else {
            CEditNodeHelper.removeCaret(graph);
        }
    } else {
        CEditNodeHelper.removeCaret(graph);
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)

Example 7 with ZyLabelContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.

the class ClipboardCopier method copyToClipboard.

/**
   * Copies the text content of a node to the clip board.
   * 
   * @param node The node to copy to the clip board.
   */
public static void copyToClipboard(final ZyGraphNode<?> node) {
    Preconditions.checkNotNull(node, "Error: Node argument can not be null");
    final IZyNodeRealizer realizer = node.getRealizer();
    final ZyLabelContent content = realizer.getNodeContent();
    if (content.isSelectable()) {
        final ZyLabelContent zyContent = content;
        final StringBuilder textBuilder = new StringBuilder();
        for (final ZyLineContent zyLineContent : zyContent) {
            textBuilder.append(zyLineContent.getText());
            //$NON-NLS-1$
            textBuilder.append("\n");
        }
        ClipboardHelpers.copyToClipboard(textBuilder.toString());
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 8 with ZyLabelContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.

the class CEndKeyBehavior method updateCaret.

@Override
protected void updateCaret() {
    if (!isShiftPressed() && !isCtrlPressed()) {
        final int yPos = getCaretMouseReleasedY();
        final int lastXPos = getLastLineXPos(yPos);
        setCaret(lastXPos, lastXPos, yPos, lastXPos, lastXPos, yPos);
    } else if (isShiftPressed() && !isCtrlPressed()) {
        final int ypos = getCaretMouseReleasedY();
        final int lastXPos = getLineContent(ypos).getTextLayout().getCharacterCount();
        int mouseReleased_X = lastXPos;
        final ZyLineContent lineContent = getLineContent(getCaretMouseReleasedY());
        final boolean noReturn = getCaretEndPosX() == lineContent.getText().length();
        final boolean withReturn = lineContent.getText().endsWith("\n") && (getCaretEndPosX() == (lineContent.getText().length() - 1));
        final boolean withCReturn = lineContent.getText().endsWith("\r") && (getCaretEndPosX() == (lineContent.getText().length() - 1));
        if (noReturn || withReturn || withCReturn) {
            mouseReleased_X = getMaxLineLength(getCaretMousePressedY(), getCaretMouseReleasedY());
        }
        if ((lineContent.getText().endsWith("\n") || lineContent.getText().endsWith("\r")) && (mouseReleased_X > 0)) {
            mouseReleased_X -= 1;
        }
        setCaret(getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), lastXPos, mouseReleased_X, ypos);
    } else if (!isShiftPressed() && isCtrlPressed()) {
        final ZyLabelContent labelContent = getLabelContent();
        final int lastXPos = labelContent.getLineContent(labelContent.getLineCount() - 1).getText().length();
        final int lastYPos = labelContent.getLineCount() - 1;
        setCaret(lastXPos, lastXPos, lastYPos, lastXPos, lastXPos, lastYPos);
    } else if (isShiftPressed() && isCtrlPressed()) {
        final int lastYPos = getLabelContent().getLineCount() - 1;
        final int lastXPos = getLabelContent().getLineContent(lastYPos).getText().length();
        setCaret(getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), lastXPos, lastXPos, lastYPos);
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 9 with ZyLabelContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.

the class View2DTest method setUp.

@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, FileReadException {
    ConfigManager.instance().read();
    final MockDatabase database = new MockDatabase();
    final CModule module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, new MockSqlProvider());
    database.getContent().addModule(module);
    manager.addDatabase(database);
    module.load();
    m_view = module.getContent().getViewContainer().createView("name", "description");
    final ZyGraphViewSettings settings = new ZyGraphViewSettings(new CallGraphSettingsConfigItem());
    settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
    final ZyGraph2DView g2dView = new ZyGraph2DView();
    final LinkedHashMap<Node, NaviNode> nodeMap = new LinkedHashMap<Node, NaviNode>();
    final LinkedHashMap<Edge, NaviEdge> edgeMap = new LinkedHashMap<Edge, NaviEdge>();
    final Node node1 = g2dView.getGraph2D().createNode();
    final CTextNode rawNode1 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT NODE ")));
    nodeMap.put(node1, new NaviNode(node1, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode1));
    final Node node2 = g2dView.getGraph2D().createNode();
    final CTextNode rawNode2 = m_view.getContent().createTextNode(Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, " TEXT COMMENT ")));
    nodeMap.put(node2, new NaviNode(node2, new ZyNormalNodeRealizer<NaviNode>(new ZyLabelContent(null)), rawNode2));
    final Edge edge = g2dView.getGraph2D().createEdge(node1, node2);
    final INaviEdge rawEdge = m_view.getContent().createEdge(rawNode1, rawNode2, com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType.JUMP_CONDITIONAL_FALSE);
    edgeMap.put(edge, new NaviEdge(nodeMap.get(node1), nodeMap.get(node2), edge, new ZyEdgeRealizer<NaviEdge>(new ZyLabelContent(null), null), rawEdge));
    final ZyGraph graph = new ZyGraph(m_view, nodeMap, edgeMap, settings, g2dView);
    m_view2d = new View2D(database, new CModuleContainer(database, module), graph, pluginInterface);
}
Also used : ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) CallGraphSettingsConfigItem(com.google.security.zynamics.binnavi.config.CallGraphSettingsConfigItem) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) CModuleContainer(com.google.security.zynamics.binnavi.disassembly.Modules.CModuleContainer) Date(java.util.Date) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) LinkedHashMap(java.util.LinkedHashMap) View2D(com.google.security.zynamics.binnavi.yfileswrap.API.disassembly.View2D) CComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.CComment) ZyEdgeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) CTextNode(com.google.security.zynamics.binnavi.disassembly.CTextNode) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Edge(y.base.Edge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Before(org.junit.Before)

Example 10 with ZyLabelContent

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent in project binnavi by google.

the class ProximityNodeCreator method insertProximityEdge.

/**
   * Inserts a proximity edge between two nodes. One of the two input nodes must be a proximity
   * browsing node or an exception is thrown.
   * 
   * @param graph The graph where the node is inserted.
   * @param sourceNode The source node of the edge.
   * @param targetNode The target node of the edge.
   * 
   * @return The inserted edge.
   */
public static ZyInfoEdge insertProximityEdge(final Graph2D graph, final ZyGraphNode<?> sourceNode, final ZyGraphNode<?> targetNode) {
    Preconditions.checkNotNull(graph, "Graph argument can not be null");
    Preconditions.checkNotNull(sourceNode, "Source node argument can not be null");
    Preconditions.checkNotNull(targetNode, "Target node argument can not be null");
    Preconditions.checkArgument((sourceNode instanceof ZyProximityNode<?>) || (targetNode instanceof ZyProximityNode<?>), "One of the two arguments must be a proximity browsing node");
    final ZyEdgeRealizer<ZyInfoEdge> r = new ZyEdgeRealizer<ZyInfoEdge>(new ZyLabelContent(null), null);
    r.setLineType(LineType.LINE_2);
    final Edge edge = graph.createEdge(sourceNode.getNode(), targetNode.getNode(), r);
    final ZyInfoEdge infoEdge = new ZyInfoEdge(sourceNode, targetNode, edge, r);
    final ZyEdgeData<ZyInfoEdge> data = new ZyEdgeData<ZyInfoEdge>(infoEdge);
    r.setUserData(data);
    return infoEdge;
}
Also used : ZyEdgeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer) ZyInfoEdge(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.edges.ZyInfoEdge) ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyEdgeData(com.google.security.zynamics.zylib.gui.zygraph.edges.ZyEdgeData) ZyInfoEdge(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.edges.ZyInfoEdge) Edge(y.base.Edge)

Aggregations

ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)33 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)10 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)6 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)5 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)5 ZyEdgeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer)5 Edge (y.base.Edge)4 Node (y.base.Node)4 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)3 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)3 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)3 CDefaultLabelEventHandler (com.google.security.zynamics.zylib.gui.zygraph.CDefaultLabelEventHandler)3 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)2 CallGraphSettingsConfigItem (com.google.security.zynamics.binnavi.config.CallGraphSettingsConfigItem)2 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)2 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)2 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)2