@Override protected boolean showHint(final JComponent component) { boolean result = super.showHint(component); if (result && getType() == ValueHintType.MOUSE_OVER_HINT) { myDisposable = Disposer.newDisposable(); ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet(); new DumbAwareAction() { @Override public void actionPerformed(@NotNull AnActionEvent e) { hideHint(); final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight()); new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint(); } }.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable); } if (result) { XValueHint prev = getEditor().getUserData(HINT_KEY); if (prev != null) { prev.hideHint(); } getEditor().putUserData(HINT_KEY, this); } return result; }
@Override protected boolean showHint(final JComponent component) { boolean result = super.showHint(component); if (result && getType() == ValueHintType.MOUSE_OVER_HINT) { myDisposable = Disposer.newDisposable(); ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet(); new DumbAwareAction() { @Override public void actionPerformed(@Nonnull AnActionEvent e) { hideHint(); final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight()); new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint(); } }.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable); } if (result) { XValueHint prev = getEditor().getUserData(HINT_KEY); if (prev != null) { prev.hideHint(); } getEditor().putUserData(HINT_KEY, this); } return result; }
protected void overrideShortcut(final JComponent forComponent, final String actionId, final ShortcutSet shortcutSet) { final AnAction action = ActionManager.getInstance().getAction(actionId); action.registerCustomShortcutSet(shortcutSet, forComponent); registerDisposable(new Disposable() { public void dispose() { action.unregisterCustomShortcutSet(forComponent); } }); }
public NavigateAction(@NotNull String text, @NotNull LineMarkerInfo<T> info, @Nullable String originalActionId) { super(text); myInfo = info; if (originalActionId != null) { ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet(); setShortcutSet(set); } }
public NavigateAction(@Nonnull String text, @Nonnull LineMarkerInfo<T> info, @Nullable String originalActionId) { super(text); myInfo = info; if (originalActionId != null) { ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet(); setShortcutSet(set); } }
private void registerForEveryKeyboardShortcut(ActionListener action, @NotNull ShortcutSet shortcuts) { for (Shortcut shortcut : shortcuts.getShortcuts()) { if (shortcut instanceof KeyboardShortcut) { KeyboardShortcut ks = (KeyboardShortcut) shortcut; KeyStroke first = ks.getFirstKeyStroke(); KeyStroke second = ks.getSecondKeyStroke(); if (second == null) { getRootPane().registerKeyboardAction(action, first, JComponent.WHEN_IN_FOCUSED_WINDOW); } } } }
protected void overrideShortcut(final JComponent forComponent, final String actionId, final ShortcutSet shortcutSet) { final AnAction action = ActionManager.getInstance().getAction(actionId); action.registerCustomShortcutSet(shortcutSet, forComponent); registerDisposable(new Disposable() { @Override public void dispose() { action.unregisterCustomShortcutSet(forComponent); } }); }
@Override public ShortcutSet getShortcut() { return REFRESH_SHORTCUT; }
@Override public ShortcutSet getShortcut() { return CustomShortcutSet.fromString(mySelectedOnly ? "ENTER" : SystemInfo.isMac ? "meta ENTER" : "control ENTER"); }
@Nullable @Override public ShortcutSet getShortcut() { return getShortcutSet(); }
public void registerShortcut(JComponent textField) { ShortcutSet shiftEnter = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)); registerCustomShortcutSet(shiftEnter, textField); myBrowseButton.setToolTipText(KeymapUtil.getShortcutsText(shiftEnter.getShortcuts())); }
protected ListScrollAction(final ShortcutSet shortcutSet, final JComponent component) { registerCustomShortcutSet(shortcutSet, component); }
@Override protected void customizeComponent(JList list, Object value, boolean isSelected) { ListPopupStep<Object> step = myPopup.getListStep(); boolean isSelectable = step.isSelectable(value); myTextLabel.setEnabled(isSelectable); if (!isSelected && step instanceof BaseListPopupStep) { Color bg = ((BaseListPopupStep)step).getBackgroundFor(value); Color fg = ((BaseListPopupStep)step).getForegroundFor(value); if (fg != null) myTextLabel.setForeground(fg); if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg); } if (step.isMnemonicsNavigationEnabled()) { final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value); if (pos != -1) { String text = myTextLabel.getText(); text = text.substring(0, pos) + text.substring(pos + 1); myTextLabel.setText(text); myTextLabel.setDisplayedMnemonicIndex(pos); } } else { myTextLabel.setDisplayedMnemonicIndex(-1); } if (step.hasSubstep(value) && isSelectable) { myNextStepLabel.setVisible(true); final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground()); myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted : AllIcons.Icons.Ide.NextStep : AllIcons.Icons.Ide.NextStepGrayed); } else { myNextStepLabel.setVisible(false); //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON); } setSelected(myNextStepLabel, isSelected); if (myShortcutLabel != null) { myShortcutLabel.setText(""); if (value instanceof ShortcutProvider) { ShortcutSet set = ((ShortcutProvider)value).getShortcut(); if (set != null) { Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts()); if (shortcut != null) { myShortcutLabel.setText(" " + KeymapUtil.getShortcutText(shortcut)); } } } setSelected(myShortcutLabel, isSelected); myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground")); } }
@Nullable @Override public ShortcutSet getShortcut() { return myAction instanceof ShortcutProvider ? ((ShortcutProvider)myAction).getShortcut() : null; }
@Nullable ShortcutSet getShortcut(@NotNull DataContext context);
public void registerShortcut(JComponent textField) { ShortcutSet shiftEnter = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)); registerCustomShortcutSet(shiftEnter, textField); myBrowseButton.setToolTipText(KeymapUtil.getShortcutsText(shiftEnter.getShortcuts())); }
@Override public ShortcutSet getShortcut() { return CustomShortcutSet.fromString("alt RIGHT"); }
@Override public ShortcutSet getShortcut() { return CustomShortcutSet.fromString("alt EQUALS"); }
@Override public ShortcutSet getShortcut() { return CustomShortcutSet.fromString("alt MINUS"); }
@Override public ShortcutSet getShortcut() { return CustomShortcutSet.fromString("alt LEFT"); }
@javax.annotation.Nullable @Override public ShortcutSet getShortcut() { return getShortcutSet(); }
protected ListScrollAction(final ShortcutSet shortcutSet, final JComponent component) { super(component); registerCustomShortcutSet(shortcutSet, component); }
protected ShortcutSet getNextErrorShortcut() { return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("GotoNextError")); }
protected ShortcutSet getPreviousErrorShortcut() { return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("GotoPreviousError")); }
@Override protected void customizeComponent(JList<? extends E> list, E value, boolean isSelected) { ListPopupStep<Object> step = myPopup.getListStep(); boolean isSelectable = step.isSelectable(value); myTextLabel.setEnabled(isSelectable); if (!isSelected && step instanceof BaseListPopupStep) { Color bg = ((BaseListPopupStep)step).getBackgroundFor(value); Color fg = ((BaseListPopupStep)step).getForegroundFor(value); if (fg != null) myTextLabel.setForeground(fg); if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg); } if (step.isMnemonicsNavigationEnabled()) { final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value); if (pos != -1) { String text = myTextLabel.getText(); text = text.substring(0, pos) + text.substring(pos + 1); myTextLabel.setText(text); myTextLabel.setDisplayedMnemonicIndex(pos); } } else { myTextLabel.setDisplayedMnemonicIndex(-1); } if (step.hasSubstep(value) && isSelectable) { myNextStepLabel.setVisible(true); final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground()); myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted : AllIcons.Icons.Ide.NextStep : AllIcons.Icons.Ide.NextStepGrayed); } else { myNextStepLabel.setVisible(false); //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON); } setSelected(myNextStepLabel, isSelected); if (myShortcutLabel != null) { myShortcutLabel.setEnabled(isSelectable); myShortcutLabel.setText(""); if (value instanceof ShortcutProvider) { ShortcutSet set = ((ShortcutProvider)value).getShortcut(); if (set != null) { Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts()); if (shortcut != null) { myShortcutLabel.setText(" " + KeymapUtil.getShortcutText(shortcut)); } } } setSelected(myShortcutLabel, isSelected); myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground")); } }
@Nullable @Override public ShortcutSet getShortcut() { IntentionAction delegate = getDelegate(); return delegate instanceof ShortcutProvider ? ((ShortcutProvider)delegate).getShortcut() : null; }
@Nullable ShortcutSet getShortcut(@Nonnull DataContext context);
MyAction(String name, TestState changeState, ShortcutSet shortcut, String tooltip) { super(name); this.changeState = changeState; registerForEveryKeyboardShortcut(this, shortcut); putValue(Action.SHORT_DESCRIPTION, tooltip); }