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();
}
Aggregations