Search in sources :

Example 36 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 37 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)

Example 38 with InputMap

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

the class CDebuggerToolbar method addHotkey.

/**
   * Assigns a hotkey to an action.
   *
   * @param button The button the action belongs to.
   * @param keyStroke The hotkey.
   * @param action The action to be triggered on the hotkey.
   * @param name The name of the hotkey.
   */
private static void addHotkey(final JButton button, final KeyStroke keyStroke, final Action action, final String name) {
    final InputMap windowImap = button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    windowImap.put(keyStroke, name);
    button.getActionMap().put(name, action);
}
Also used : InputMap(javax.swing.InputMap)

Example 39 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 40 with InputMap

use of javax.swing.InputMap in project adempiere by adempiere.

the class AdempiereButtonListener method updateMnemonicBindingX.

//	propertyChange
/**
	 * 	Update Mnemonic Binding
	 *	@param b button
	 */
void updateMnemonicBindingX(AbstractButton b) {
    int m = b.getMnemonic();
    if (m != 0) {
        InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
        if (map == null) {
            map = new ComponentInputMapUIResource(b);
            SwingUtilities.replaceUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
        }
        map.clear();
        String className = b.getClass().getName();
        //	Default Buttons
        int mask = InputEvent.ALT_MASK;
        if (//	In Tab
        b instanceof JCheckBox || className.indexOf("VButton") != -1)
            mask = InputEvent.SHIFT_MASK + InputEvent.CTRL_MASK;
        map.put(KeyStroke.getKeyStroke(m, mask, false), "pressed");
        map.put(KeyStroke.getKeyStroke(m, mask, true), "released");
        map.put(KeyStroke.getKeyStroke(m, 0, true), "released");
    } else {
        InputMap map = SwingUtilities.getUIInputMap(b, JComponent.WHEN_IN_FOCUSED_WINDOW);
        if (map != null)
            map.clear();
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) ComponentInputMapUIResource(javax.swing.plaf.ComponentInputMapUIResource) InputMap(javax.swing.InputMap)

Aggregations

InputMap (javax.swing.InputMap)69 ActionMap (javax.swing.ActionMap)45 AbstractAction (javax.swing.AbstractAction)37 ActionEvent (java.awt.event.ActionEvent)35 Action (javax.swing.Action)19 JButton (javax.swing.JButton)12 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)11 JTextField (javax.swing.JTextField)10 BorderLayout (java.awt.BorderLayout)9 JPanel (javax.swing.JPanel)9 KeyStroke (javax.swing.KeyStroke)9 JCheckBox (javax.swing.JCheckBox)8 JDialog (javax.swing.JDialog)8 JScrollPane (javax.swing.JScrollPane)8 JComponent (javax.swing.JComponent)7 ActionListener (java.awt.event.ActionListener)6 JRootPane (javax.swing.JRootPane)6 JTable (javax.swing.JTable)5 ComponentInputMapUIResource (javax.swing.plaf.ComponentInputMapUIResource)5 FormBuilder (com.jgoodies.forms.builder.FormBuilder)4