public void actionPerformed(final ActionEvent e) { final boolean newAcceleratorOnNextClickEnabled = AccelerateableAction.isNewAcceleratorOnNextClickEnabled(); final KeyStroke newAccelerator = acceleratorForNextClickedAction; if (newAcceleratorOnNextClickEnabled) { getAcceleratorOnNextClickActionDialog().setVisible(false); } final Object source = e.getSource(); if ((newAcceleratorOnNextClickEnabled || 0 != (e.getModifiers() & ActionEvent.CTRL_MASK)) && source instanceof IKeyBindingManager && !((IKeyBindingManager) source).isKeyBindingProcessed() && source instanceof JMenuItem) { final JMenuItem item = (JMenuItem) source; newAccelerator(item, newAccelerator); return; } originalAction.actionPerformed(e); }
static void setNewAcceleratorOnNextClick(KeyStroke accelerator) { if (AccelerateableAction.isNewAcceleratorOnNextClickEnabled()) { return; } acceleratorForNextClickedAction = accelerator; String title = TextUtils.getText("SetAccelerator.dialogTitle"); String text = TextUtils.getText(SET_ACCELERATOR_ON_NEXT_CLICK_ACTION); if (accelerator != null) text = TextUtils.format("SetAccelerator.keystrokeDetected", toString(accelerator)) + "\n" + text; final Frame frame = Controller.getCurrentController().getViewController().getFrame(); setAcceleratorOnNextClickActionDialog = UITools.createCancelDialog(frame, title, text); getAcceleratorOnNextClickActionDialog() .addComponentListener( new ComponentAdapter() { @Override public void componentHidden(final ComponentEvent e) { setAcceleratorOnNextClickActionDialog = null; acceleratorForNextClickedAction = null; } }); getAcceleratorOnNextClickActionDialog().setVisible(true); }