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