Search in sources :

Example 26 with InputMap

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

the class CGraphHotkeys method registerHotKeys.

/**
   * Register the default hotkeys of a graph view.
   * 
   * @param parent Parent window used for dialogs.
   * @param panel The panel where the view is shown.
   * @param debuggerProvider Provides the debugger used by some hotkeys.
   * @param searchField The search field that is shown in the graph panel.
   * @param addressField The address field that is shown in the graph panel.
   */
public static void registerHotKeys(final JFrame parent, final CGraphPanel panel, final IFrontEndDebuggerProvider debuggerProvider, final CGraphSearchField searchField, final CGotoAddressField addressField) {
    Preconditions.checkNotNull(parent, "IE01606: Parent argument can not be null");
    Preconditions.checkNotNull(panel, "IE01607: Panel argument can not be null");
    Preconditions.checkNotNull(searchField, "IE01608: Search field argument can not be null");
    Preconditions.checkNotNull(addressField, "IE01609: Address field argument can not be null");
    final InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap actionMap = panel.getActionMap();
    inputMap.put(HotKeys.GRAPH_GOTO_ADDRESS_FIELD_KEY.getKeyStroke(), "GOTO_ADDRESS_FIELD");
    actionMap.put("GOTO_ADDRESS_FIELD", new AbstractAction() {

        /**
       * Used for serialization.
       */
        private static final long serialVersionUID = -8994014581850287793L;

        @Override
        public void actionPerformed(final ActionEvent event) {
            addressField.requestFocusInWindow();
        }
    });
    inputMap.put(HotKeys.GRAPH_SHOW_HOTKEYS_ACCELERATOR_KEY.getKeyStroke(), "SHOW_HOTKEYS");
    actionMap.put("SHOW_HOTKEYS", new CShowHotkeysAction(parent));
    registerSearchKeys(panel.getModel().getGraph().getView(), searchField, inputMap, actionMap);
    registerDebuggerKeys(panel.getModel().getParent(), panel.getModel().getGraph(), debuggerProvider, inputMap, actionMap);
}
Also used : ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) CShowHotkeysAction(com.google.security.zynamics.binnavi.Gui.GraphWindows.Actions.CShowHotkeysAction) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 27 with InputMap

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

the class CRegisterHotKeys method register.

public static <NodeType extends ZyGraphNode<?>> void register(final AbstractZyGraph<NodeType, ?> graph) {
    final Graph2DView view = graph.getView();
    final Graph2DViewActions actions = new Graph2DViewActions(view);
    final ActionMap amap = actions.createActionMap();
    final InputMap imap = actions.createDefaultInputMap(amap);
    view.setActionMap(amap);
    view.setInputMap(JComponent.WHEN_FOCUSED, imap);
    view.getCanvasComponent().setActionMap(amap);
    view.getCanvasComponent().setInputMap(JComponent.WHEN_FOCUSED, imap);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "DOWN");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "UP");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "LEFT");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "RIGHT");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), "+");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), "-");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, 0), "m");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S, 0), "s");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LESS, 0), "<");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK), "SELECT_VISIBLE_NODES");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK), "COPY_CONTENT_FROM_SELECTED_NODES");
    amap.remove(Graph2DViewActions.DELETE_SELECTION);
    amap.remove(Graph2DViewActions.EDIT_LABEL);
    registerActions(graph);
}
Also used : Graph2DView(y.view.Graph2DView) ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) Graph2DViewActions(y.view.Graph2DViewActions)

Example 28 with InputMap

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

the class CMemoryPanel method initHotkeys.

/**
   * Initialize some hotkeys for easy access to functions of the debug panel.
   */
private void initHotkeys() {
    final InputMap imap = m_hexView.getInputMap();
    final InputMap windowImap = m_hexView.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    windowImap.put(HotKeys.GOTO_HK.getKeyStroke(), "GOTO");
    m_hexView.getActionMap().put("GOTO", m_gotoAction);
    imap.put(HotKeys.SEARCH_HK.getKeyStroke(), "SEARCH");
    m_hexView.getActionMap().put("SEARCH", m_searchAction);
}
Also used : InputMap(javax.swing.InputMap)

Example 29 with InputMap

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

the class CDatabaseSettingsPanel method setupHotkeys.

/**
   * Sets up the hotkeys of the panel.
   */
private void setupHotkeys() {
    final InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    final ActionMap actionMap = getActionMap();
    inputMap.put(HotKeys.DATABASE_SETTINGS_TEST_CONNECTION_KEY.getKeyStroke(), "TEST_CONNECTION");
    actionMap.put("TEST_CONNECTION", new AbstractAction() {

        @Override
        public void actionPerformed(final ActionEvent event) {
            if (testButton.isEnabled()) {
                testConnection();
            }
        }
    });
    inputMap.put(HotKeys.DATABASE_SETTINGS_SAVE_CONNECTION_KEY.getKeyStroke(), "SAVE_CONNECTION");
    actionMap.put("SAVE_CONNECTION", new AbstractAction() {

        @Override
        public void actionPerformed(final ActionEvent event) {
            saveConnection();
        }
    });
}
Also used : ActionMap(javax.swing.ActionMap) ActionEvent(java.awt.event.ActionEvent) InputMap(javax.swing.InputMap) AbstractAction(javax.swing.AbstractAction)

Example 30 with InputMap

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

the class CGraphSearchField method registerHotkeys.

/**
   * Registers all hotkeys processed by the graph search field.
   */
private void registerHotkeys() {
    final ActionMap actionMap = ((JTextField) getEditor().getEditorComponent()).getActionMap();
    final InputMap imap = ((JTextField) getEditor().getEditorComponent()).getInputMap();
    setActionMap(actionMap);
    setInputMap(JComponent.WHEN_FOCUSED, imap);
    imap.put(HotKeys.GRAPH_SEARCH_NEXT_KEY.getKeyStroke(), "NEXT");
    imap.put(HotKeys.GRAPH_SEARCH_NEXT_ZOOM_KEY.getKeyStroke(), "NEXT_ZOOM");
    imap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_KEY.getKeyStroke(), "PREVIOUS");
    imap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_ZOOM_KEY.getKeyStroke(), "PREVIOUS_ZOOM");
    actionMap.put("NEXT", CActionProxy.proxy(new CActionHotKey("NEXT")));
    actionMap.put("NEXT_ZOOM", CActionProxy.proxy(new CActionHotKey("NEXT_ZOOM")));
    actionMap.put("PREVIOUS", CActionProxy.proxy(new CActionHotKey("PREVIOUS")));
    actionMap.put("PREVIOUS_ZOOM", CActionProxy.proxy(new CActionHotKey("PREVIOUS_ZOOM")));
}
Also used : ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) JTextField(javax.swing.JTextField)

Aggregations

InputMap (javax.swing.InputMap)59 ActionMap (javax.swing.ActionMap)38 AbstractAction (javax.swing.AbstractAction)32 ActionEvent (java.awt.event.ActionEvent)30 Action (javax.swing.Action)18 JButton (javax.swing.JButton)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 BorderLayout (java.awt.BorderLayout)9 JPanel (javax.swing.JPanel)9 JCheckBox (javax.swing.JCheckBox)8 JDialog (javax.swing.JDialog)8 JScrollPane (javax.swing.JScrollPane)8 JTextField (javax.swing.JTextField)7 KeyStroke (javax.swing.KeyStroke)7 JComponent (javax.swing.JComponent)6 JRootPane (javax.swing.JRootPane)6 FormBuilder (com.jgoodies.forms.builder.FormBuilder)5 FormLayout (com.jgoodies.forms.layout.FormLayout)5 ComponentInputMapUIResource (javax.swing.plaf.ComponentInputMapUIResource)5 Insets (java.awt.Insets)4