Search in sources :

Example 1 with IGroupNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode in project binnavi by google.

the class CDefaultNodeClickedLeftAction method execute.

@Override
public void execute(final CNodeClickedLeftState<NodeType, EdgeType> state, final MouseEvent event) {
    CMouseCursorHelper.setDefaultCursor(state.getGraph());
    final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
    final Node n = state.getNode();
    final NodeType node = graph.getNode(n);
    final double x = graph.getEditMode().translateX(event.getX());
    final double y = graph.getEditMode().translateY(event.getY());
    final CStateFactory<NodeType, EdgeType> factory = state.getStateFactory();
    if (ProximityHelper.isProximityNode(state.getGraph().getGraph(), n)) {
        CEditNodeHelper.removeCaret(graph);
        final ZyProximityNode<?> proximityNode = ProximityHelper.getProximityNode(graph.getGraph(), n);
        for (final IZyEditModeListener<NodeType, EdgeType> listener : factory.getListeners()) {
            try {
                listener.proximityBrowserNodeClicked(proximityNode, event, x, y);
            } catch (final Exception exception) {
            // TODO: (timkornau): implement logging here.
            }
        }
    } else if ((node != null) && (node.getRawNode() instanceof IGroupNode)) {
        CEditNodeHelper.removeCaret(graph);
        final GroupNodeRealizer gnr = (GroupNodeRealizer) graph.getGraph().getRealizer(node.getNode());
        final NodeLabel handle = gnr.getStateLabel();
        if (handle.getBox().contains(x, y)) {
            // Clicks on the X in the group node corner
            toggleGroup(node);
        } else if (SwingUtilities.isLeftMouseButton(event)) {
            if ((event.getClickCount() == 2) && event.isControlDown()) {
                // CTRL-LEFT-DOUBLECLICK
                toggleGroup(node);
            } else if (event.getClickCount() == 1) {
                CGraphSelector.selectNode(graph, node, event.isShiftDown());
            }
        }
    } else {
        if (node != null) {
            if (graph.getEditMode().getLabelEventHandler().isActiveLabel(node.getRealizer().getNodeContent())) {
                CEditNodeHelper.setCaretEnd(graph, state.getNode(), event);
            } else {
                if (graph.getEditMode().getLabelEventHandler().isActive()) {
                    CEditNodeHelper.removeCaret(graph);
                }
                final Set<NodeType> selectedNodes = graph.getSelectedNodes();
                if (event.isShiftDown() && (selectedNodes.size() >= 1)) {
                    CGraphSelector.selectPath(graph, new ArrayList<NodeType>(selectedNodes), node);
                } else if (event.isControlDown()) {
                    graph.selectNode(node, !node.isSelected());
                } else {
                    final Collection<NodeType> toUnselect = new ArrayList<NodeType>(graph.getNodes());
                    toUnselect.remove(node);
                    final Collection<NodeType> toSelect = new ArrayList<NodeType>();
                    toSelect.add(node);
                    graph.selectNodes(toSelect, toUnselect);
                }
            }
            for (final IZyEditModeListener<NodeType, EdgeType> listener : factory.getListeners()) {
                // ESCA-JAVA0166: Catch Exception because we are calling a listener function
                try {
                    listener.nodeClicked(node, event, x, y);
                } catch (final Exception exception) {
                // TODO: (timkornau): implement logging here.
                }
            }
        }
    }
}
Also used : GroupNodeRealizer(y.view.hierarchy.GroupNodeRealizer) Set(java.util.Set) IGroupNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node) IGroupNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode) ZyProximityNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode) ArrayList(java.util.ArrayList) IZyEditModeListener(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.IZyEditModeListener) NodeLabel(y.view.NodeLabel)

Example 2 with IGroupNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode in project binnavi by google.

the class ProximityRangeCalculator method getSuccessorsInternal.

private static void getSuccessorsInternal(final ViewNodeAdapter node, final int depth, final Set<ViewNodeAdapter> nodes, final HashSet<ViewNodeAdapter> visited) {
    for (final ViewNodeAdapter child : node.getChildren()) {
        if (/* visited.contains(child) || */
        (depth <= 0) && !(child.getNode() instanceof ITextNode)) {
            continue;
        } else if (child.getNode().getParentGroup() != null) {
            IGroupNode<?, ?> previousNode = child.getNode().getParentGroup();
            while (previousNode != null) {
                if (!visited(visited, previousNode)) {
                    final ViewNodeAdapter groupNodeAdapter = new ViewNodeAdapter(previousNode);
                    visited.add(groupNodeAdapter);
                    nodes.add(groupNodeAdapter);
                    previousNode = previousNode.getParentGroup();
                } else {
                    previousNode = null;
                }
            }
        }
        if (NodeHelpers.getVisibleNode(child.getNode()) != child.getNode()) {
            continue;
        }
        visited.add(child);
        nodes.add(child);
        // Silly trick to make attached text nodes visible.
        getPredecessorsInternal(child, -1, nodes, new HashSet<ViewNodeAdapter>());
        getSuccessorsInternal(child, depth - 1, nodes, visited);
    }
}
Also used : ITextNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ITextNode) IGroupNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode) ViewNodeAdapter(com.google.security.zynamics.zylib.gui.zygraph.wrappers.ViewNodeAdapter)

Example 3 with IGroupNode

use of com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode in project binnavi by google.

the class ProximityRangeCalculator method getPredecessorsInternal.

private static void getPredecessorsInternal(final ViewNodeAdapter node, final int depth, final Set<ViewNodeAdapter> nodes, final Set<ViewNodeAdapter> visited) {
    for (final ViewNodeAdapter parent : node.getParents()) {
        if (/* visited.contains(parent) || */
        (depth <= 0) && !(parent.getNode() instanceof ITextNode)) {
            // NH: see getSuccessorsInternal for comment
            continue;
        } else if (parent.getNode().getParentGroup() != null) {
            IGroupNode<?, ?> previousNode = parent.getNode().getParentGroup();
            while (previousNode != null) {
                if (!visited(visited, previousNode)) {
                    final ViewNodeAdapter groupNodeAdapter = new ViewNodeAdapter(previousNode);
                    visited.add(groupNodeAdapter);
                    nodes.add(groupNodeAdapter);
                    previousNode = previousNode.getParentGroup();
                } else {
                    previousNode = null;
                }
            }
        }
        visited.add(parent);
        nodes.add(parent);
        // Silly trick to make the attached text nodes visible
        getSuccessorsInternal(parent, -1, nodes, new HashSet<ViewNodeAdapter>());
        getPredecessorsInternal(parent, depth - 1, nodes, visited);
    }
}
Also used : ITextNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ITextNode) IGroupNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode) ViewNodeAdapter(com.google.security.zynamics.zylib.gui.zygraph.wrappers.ViewNodeAdapter)

Aggregations

IGroupNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode)3 ITextNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.ITextNode)2 ViewNodeAdapter (com.google.security.zynamics.zylib.gui.zygraph.wrappers.ViewNodeAdapter)2 IZyEditModeListener (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.IZyEditModeListener)1 ZyGraphNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode)1 ZyProximityNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.proximity.ZyProximityNode)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 Node (y.base.Node)1 NodeLabel (y.view.NodeLabel)1 GroupNodeRealizer (y.view.hierarchy.GroupNodeRealizer)1