private void putActionDelegate(InputMap map, KeyStroke ks) { String binding = COPY_ACTION_DELEGATE+ks.toString(); Action action = getCopyActionDelegate(map, ks); if (action != null) { getActionMap().put(binding, action); map.put(ks, binding); } }
public OutlineViewOutline(final OutlineModel mdl, PropertiesRowModel rowModel) { super(mdl); this.rowModel = rowModel; setSelectVisibleColumnsLabel(NbBundle.getMessage(OutlineView.class, "CTL_ColumnsSelector")); //NOI18N // fix for #198694 // default action map for JTable defines these shortcuts // but we use our own mechanism for handling them // following lines disable default L&F handling (if it is // defined on Ctrl-c, Ctrl-v and Ctrl-x) removeDefaultCutCopyPaste(getInputMap(WHEN_FOCUSED)); removeDefaultCutCopyPaste(getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)); KeyStroke ctrlSpace; if (Utilities.isMac()) { ctrlSpace = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.META_MASK, false); } else { ctrlSpace = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, KeyEvent.CTRL_DOWN_MASK, false); } Object ctrlSpaceActionBind = getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).get(ctrlSpace); if (ctrlSpaceActionBind != null) { getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ctrlSpace, "invokeCustomEditor"); //NOI18N Action invokeCustomEditorAction = new InvokeCustomEditorAction(ctrlSpaceActionBind); getActionMap().put("invokeCustomEditor", invokeCustomEditorAction); } }
@Override public void actionPerformed(ActionEvent e) { if (!openCustomEditor(e)) { Action a = getActionMap().get(delegateActionBind); if (a != null && a.isEnabled()) { a.actionPerformed(e); } } }
private Action getCopyActionDelegate(InputMap map, KeyStroke ks) { ActionMap am = getActionMap(); if(map != null && am != null && isEnabled()) { Object binding = map.get(ks); final Action action = (binding == null) ? null : am.get(binding); if (action != null) { return new CopyToClipboardAction(action); } } return null; }