use of javax.swing.InputMap in project processdash by dtuma.
the class HierarchyNoteEditorDialog method setupWindowKeyBindings.
private void setupWindowKeyBindings(JComponent c) {
InputMap inputMap = c.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_DOWN_MASK), "saveAndClose");
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.META_DOWN_MASK), "saveAndClose");
c.getActionMap().put("saveAndClose", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
if (isDirty())
saveComment();
close();
}
});
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "confirmClose");
c.getActionMap().put("confirmClose", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
confirmClose(true);
}
});
}
use of javax.swing.InputMap in project processdash by dtuma.
the class AssignedToComboBox method tweakKeyBindings.
private void tweakKeyBindings(JTextComponent textComponent) {
InputMap inputMap = textComponent.getInputMap();
// special handling for backspace
inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), BACKSPACE_ACTION);
// set left and right to move whole words
inputMap.put(KeyStroke.getKeyStroke("LEFT"), MOVE_LEFT_ACTION);
inputMap.put(KeyStroke.getKeyStroke("RIGHT"), MOVE_RIGHT_ACTION);
// ignore CTRL-X and beep instead
inputMap.put(KeyStroke.getKeyStroke("ctrl X"), ERROR_ACTION);
}
use of javax.swing.InputMap in project processdash by dtuma.
the class WBSJTable method buildCustomActionMaps.
/** Populate the <tt>customActions</tt> list with actions for editing
* the work breakdown structure. */
private void buildCustomActionMaps() {
// Map "Tab" and "Shift-Tab" to the demote/promote actions
customActions.add(new WbsActionMapping(KeyEvent.VK_TAB, 0, "Demote", DEMOTE_ACTION));
customActions.add(new WbsActionMapping(KeyEvent.VK_TAB, SHIFT, "Promote", PROMOTE_ACTION));
customActions.add(new ActionMapping(KeyEvent.VK_INSERT, 0, "Insert", INSERT_ACTION));
customActions.add(new ActionMapping(KeyEvent.VK_ENTER, 0, "Enter", ENTER_ACTION));
customActions.add(new ActionMapping(KeyEvent.VK_ENTER, SHIFT, "InsertAfter", INSERT_AFTER_ACTION));
customActions.add(new ActionMapping("collapseTree", COLLAPSE_ACTION));
customActions.add(new ActionMapping("expandTree", EXPAND_ACTION));
customActions.add(new ActionMapping("moveTreeUp", MOVEUP_ACTION));
customActions.add(new ActionMapping("moveTreeDown", MOVEDOWN_ACTION));
// Find the default row navigation actions for the table, and replace
// them with new actions which (1) perform the original action, then
// (2) restart editing on the newly selected cell.
InputMap inputMap = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = getActionMap();
List filter = Arrays.asList(new String[] { "selectPreviousRow", "selectNextRow", "selectFirstRow", "selectLastRow", "scrollUpChangeSelection", "scrollDownChangeSelection" });
KeyStroke[] keys = inputMap.allKeys();
for (int i = 0; i < keys.length; i++) {
Object actionKey = inputMap.get(keys[i]);
if (!filter.contains(actionKey))
continue;
Action action = actionMap.get(actionKey);
if (action == null)
continue;
customActions.add(new ActionMapping(keys[i], actionKey + "-WBS", new DelegateActionRestartEditing(action, actionKey)));
}
}
use of javax.swing.InputMap in project processdash by dtuma.
the class WBSJTable method installTableActions.
/** Install actions that are appropriate only for the table (not for any
* other component). */
void installTableActions() {
InputMap inputMap = getInputMap();
InputMap inputMap2 = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
InputMap inputMap3 = getInputMap(WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = getActionMap();
ClipboardBridge clipboardBridge = new ClipboardBridge(this);
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, CTRL), "Cut");
actionMap.put("Cut", new WbsNodeKeystrokeDelegatingAction(CUT_ACTION, null));
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, CTRL), "Copy");
actionMap.put("Copy", new WbsNodeKeystrokeDelegatingAction(COPY_ACTION, clipboardBridge.getCopyAction()));
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, CTRL), "Paste");
inputMap2.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, CTRL), "Paste");
actionMap.put("Paste", new WbsNodeKeystrokeDelegatingAction(PASTE_ACTION, clipboardBridge.getPasteAction()));
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "Delete");
actionMap.put("Delete", new WbsNodeKeystrokeDelegatingAction(DELETE_ACTION, TABLE_DELETE_ACTION));
// the expand/collapse icons have accelerators assigned for the plus
// and minus keys. Register some additional accelerator keys based on
// other places where plus and minus appear on the keyboard.
inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, ALT), "collapseTree");
inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, ALT), "expandTree");
inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ALT), "expandTree");
inputMap3.put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, ALT | SHIFT), "expandTree");
}
Aggregations