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