Search in sources :

Example 11 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class CBreakpointTable method showPopupMenu.

/**
   * Displays the popup menu at the location specified by the click event.
   * 
   * @param event The click event.
   */
private void showPopupMenu(final MouseEvent event) {
    final int row = rowAtPoint(event.getPoint());
    final int column = columnAtPoint(event.getPoint());
    int[] rows = getSelectedRows();
    if ((rows.length == 0) || (rows.length == 1)) {
        changeSelection(row, column, false, false);
        rows = getSelectedRows();
    }
    final JPopupMenu menu = new JPopupMenu();
    menu.add(new JMenuItem(CActionProxy.proxy(new CDeleteAction(m_debuggerProvider, rows))));
    if (CBreakpointFunctions.allDisabled(m_debuggerProvider, rows)) {
        menu.add(new JMenuItem(CActionProxy.proxy(new CEnableAction(m_debuggerProvider, rows))));
    } else if (CBreakpointFunctions.allNotDisabled(m_debuggerProvider, rows)) {
        menu.add(new JMenuItem(CActionProxy.proxy(new CDisableAction(m_debuggerProvider, rows))));
    }
    if (rows.length == 1) {
        menu.addSeparator();
        final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(m_debuggerProvider, rows[0]);
        final BreakpointManager manager = breakpoint.first().getBreakpointManager();
        final int breakpointIndex = breakpoint.second();
        final BreakpointAddress address = manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getAddress();
        menu.add(new JMenuItem(CActionProxy.proxy(new CZoomBreakpointAction(SwingUtilities.windowForComponent(this), m_graph, m_viewContainer, address))));
    }
    menu.show(event.getComponent(), event.getX(), event.getY());
}
Also used : CZoomBreakpointAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CZoomBreakpointAction) CDeleteAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CDeleteAction) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) JPopupMenu(javax.swing.JPopupMenu) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) CDisableAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CDisableAction) JMenuItem(javax.swing.JMenuItem) CEnableAction(com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.Actions.CEnableAction) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 12 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class CProjectTree method showPopupMenu.

/**
   * Shows a popup menu that depends on the node that was clicked.
   * 
   * @param event The event to handle.
   */
private void showPopupMenu(final MouseEvent event) {
    final IProjectTreeNode selectedNode = (IProjectTreeNode) TreeHelpers.getNodeAt(this, event.getX(), event.getY());
    if (selectedNode == null) {
        // Show the default menu
        m_popup.show(this, event.getX(), event.getY());
    } else {
        setSelectionPath(new TreePath(((DefaultMutableTreeNode) selectedNode).getPath()));
        final JPopupMenu menu = selectedNode.getPopupMenu();
        if (menu != null) {
            menu.show(this, event.getX(), event.getY());
        }
    }
}
Also used : TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) IProjectTreeNode(com.google.security.zynamics.binnavi.Gui.MainWindow.ProjectTree.Nodes.IProjectTreeNode) JPopupMenu(javax.swing.JPopupMenu)

Example 13 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class CAbstractMenuBuilder method createMenus.

/**
   * Creates all menus.
   */
private void createMenus() {
    // TODO: Old menus must be disposed before creating new ones
    m_mainMenu = new JMenuBar();
    m_mainMenu.add(createBinNaviMenu());
    final JMenu menu = getMenu();
    if (menu != null) {
        createMenu(menu);
        m_mainMenu.add(menu);
    }
    m_mainMenu.add(createPluginsMenu());
    m_mainMenu.add(createSettingsMenu());
    m_mainMenu.add(createAboutMenu());
    m_popupMenu = new JPopupMenu();
    createMenu(m_popupMenu);
}
Also used : JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu) JPopupMenu(javax.swing.JPopupMenu)

Example 14 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class MemberTableMouseListener method showPopup.

private void showPopup(final MouseEvent event) {
    final JPopupMenu popupMenu = new JPopupMenu();
    popupMenu.add(new AddMemberAction());
    final int selectedRow = table.getSelectedRow();
    if (selectedRow != -1) {
        final MemberTableRowData row = table.getModel().getRow(selectedRow);
        popupMenu.add(new InsertMemberBeforeAction(selectedRow, row.getName()));
        popupMenu.add(new InsertMemberAfterAction(selectedRow, row.getName()));
        popupMenu.add(new DeleteMemberAction(selectedRow, row.getName()));
    }
    popupMenu.show(event.getComponent(), event.getX(), event.getY());
}
Also used : JPopupMenu(javax.swing.JPopupMenu)

Example 15 with JPopupMenu

use of javax.swing.JPopupMenu in project binnavi by google.

the class CTagsTree method showPopupMenu.

/**
   * Shows the context menu for a given mouse event.
   *
   * @param event The mouse event that triggered the popup menu.
   */
private void showPopupMenu(final MouseEvent event) {
    final ITagTreeNode selectedNode = (ITagTreeNode) TreeHelpers.getNodeAt(this, event.getX(), event.getY());
    if (selectedNode == null) {
        // Show the default menu
        final JPopupMenu popupMenu = new JPopupMenu();
        popupMenu.add(CActionProxy.proxy(new CAddRootTagNodeAction(m_parent, m_tagManager, m_rootNode.getTag())));
        popupMenu.show(this, event.getX(), event.getY());
    } else {
        final JPopupMenu menu = selectedNode.getPopupMenu();
        if (menu != null) {
            menu.show(this, event.getX(), event.getY());
        }
    }
}
Also used : CAddRootTagNodeAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Actions.CAddRootTagNodeAction) ITagTreeNode(com.google.security.zynamics.binnavi.Gui.GraphWindows.NodeTaggingTree.Nodes.ITagTreeNode) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

JPopupMenu (javax.swing.JPopupMenu)128 JMenuItem (javax.swing.JMenuItem)56 ActionEvent (java.awt.event.ActionEvent)34 ActionListener (java.awt.event.ActionListener)20 JMenu (javax.swing.JMenu)19 Component (java.awt.Component)17 JButton (javax.swing.JButton)16 JScrollPane (javax.swing.JScrollPane)15 AbstractAction (javax.swing.AbstractAction)14 JLabel (javax.swing.JLabel)14 MouseEvent (java.awt.event.MouseEvent)13 Point (java.awt.Point)11 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)11 JSeparator (javax.swing.JSeparator)11 JPanel (javax.swing.JPanel)10 JTable (javax.swing.JTable)10 Dimension (java.awt.Dimension)7 ArrayList (java.util.ArrayList)7 JTextArea (javax.swing.JTextArea)7 JCheckBox (javax.swing.JCheckBox)6