Search in sources :

Example 1 with GroupNodeRealizer

use of y.view.hierarchy.GroupNodeRealizer 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)

Aggregations

IGroupNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.IGroupNode)1 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