Search in sources :

Example 1 with CActionSelectSameFunctionType

use of com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectSameFunctionType in project binnavi by google.

the class CMenuBuilder method addSelectionMenus.

/**
 * Adds menus related to node selection to a given node context menu.
 *
 * @param menu The node context menu to extend.
 * @param graph The graph the clicked node belongs to.
 * @param node The clicked node.
 */
public static void addSelectionMenus(final JPopupMenu menu, final ZyGraph graph, final NaviNode node) {
    Preconditions.checkNotNull(menu, "IE02144: Menu argument can not be null");
    Preconditions.checkNotNull(graph, "IE02145: Graph argument can not be null");
    Preconditions.checkNotNull(node, "IE02146: Node argument can not be null");
    final JMenu selectionMenu = new JMenu("Selection");
    selectionMenu.add(CActionProxy.proxy(new CActionSelectNodePredecessors(graph, node)));
    selectionMenu.add(CActionProxy.proxy(new CActionSelectNodeSuccessors(graph, node)));
    if (graph.getSelectedNodes().size() > 0) {
        selectionMenu.add(CActionProxy.proxy(new CGroupAction(graph)));
    }
    if (node.getRawNode() instanceof INaviCodeNode) {
        try {
            final INaviFunction parentFunction = ((INaviCodeNode) node.getRawNode()).getParentFunction();
            selectionMenu.add(CActionProxy.proxy(new CActionSelectSameParentFunction(graph, parentFunction)));
        } catch (final MaybeNullException exception) {
        // Obviously we can not select nodes of the same parent function if there
        // is no parent function.
        }
    } else if (node.getRawNode() instanceof INaviFunctionNode) {
        final INaviFunction function = ((INaviFunctionNode) node.getRawNode()).getFunction();
        selectionMenu.add(CActionProxy.proxy(new CActionSelectSameFunctionType(graph, function.getType())));
    }
    menu.add(selectionMenu);
    menu.addSeparator();
}
Also used : CActionSelectNodeSuccessors(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectNodeSuccessors) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) CActionSelectSameParentFunction(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectSameParentFunction) CGroupAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.Actions.CGroupAction) CActionSelectSameFunctionType(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectSameFunctionType) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) JMenu(javax.swing.JMenu) CActionSelectNodePredecessors(com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectNodePredecessors)

Aggregations

MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 CGroupAction (com.google.security.zynamics.binnavi.Gui.GraphWindows.Actions.CGroupAction)1 CActionSelectNodePredecessors (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectNodePredecessors)1 CActionSelectNodeSuccessors (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectNodeSuccessors)1 CActionSelectSameFunctionType (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectSameFunctionType)1 CActionSelectSameParentFunction (com.google.security.zynamics.binnavi.ZyGraph.Menus.Actions.CActionSelectSameParentFunction)1 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)1 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)1 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)1 JMenu (javax.swing.JMenu)1