com.intellij.openapi.actionSystem.Shortcut Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.Shortcut.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InplaceRefactoring.java From consulo with Apache License 2.0 | 5 votes |
protected void showDialogAdvertisement(final String actionId) { final Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); final Shortcut[] shortcuts = keymap.getShortcuts(actionId); if (shortcuts.length > 0) { setAdvertisementText("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to show dialog with more options"); } }
Example #2
Source File: HighlightUsagesHandler.java From consulo with Apache License 2.0 | 5 votes |
public static String getShortcutText() { final Shortcut[] shortcuts = ActionManager.getInstance() .getAction(IdeActions.ACTION_HIGHLIGHT_USAGES_IN_FILE) .getShortcutSet() .getShortcuts(); if (shortcuts.length == 0) { return "<no key assigned>"; } return KeymapUtil.getShortcutText(shortcuts[0]); }
Example #3
Source File: TipUIUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static String getShortcutText(String actionId, Keymap keymap) { for (final Shortcut shortcut : keymap.getShortcuts(actionId)) { if (shortcut instanceof KeyboardShortcut) { return KeymapUtil.getShortcutText(shortcut); } } return null; }
Example #4
Source File: KeyPromoterUtils.java From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Uses an actionID to access the key-map of IDEA and find possible short-cuts * @param myIdeaActionID ActionID to look the shortcut up * @return a string combining one or more shortcuts */ static String getKeyboardShortcutsText(String myIdeaActionID) { final Keymap activeKeymap = keyMapManager.getActiveKeymap(); Shortcut[] shortcuts; if (mySettings.isShowKeyboardShortcutsOnly()) { shortcuts = Arrays.stream( activeKeymap.getShortcuts(myIdeaActionID) ).filter(Shortcut::isKeyboard).toArray(Shortcut[]::new); } else { shortcuts = activeKeymap.getShortcuts(myIdeaActionID); } if (shortcuts.length == 0) { return ""; } StringBuilder buffer = new StringBuilder(); for (int i = 0; i < shortcuts.length; i++) { Shortcut shortcut = shortcuts[i]; if (i > 0) { buffer.append(" or "); } buffer.append("'").append(KeymapUtil.getShortcutText(shortcut)).append("'"); } return buffer.toString(); }
Example #5
Source File: PrevOccurrenceAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected List<Shortcut> getSingleLineShortcuts() { if (mySearch) { return ContainerUtil.append(Utils.shortcutsOf(IdeActions.ACTION_EDITOR_MOVE_CARET_UP), new KeyboardShortcut(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK), null)); } else { return Utils.shortcutsOf(IdeActions.ACTION_EDITOR_MOVE_CARET_UP); } }
Example #6
Source File: MacOSDefaultKeymap.java From consulo with Apache License 2.0 | 5 votes |
public static Shortcut convertShortcutFromParent(Shortcut parentShortcut) { if (parentShortcut instanceof MouseShortcut) { return convertMouseShortcut((MouseShortcut)parentShortcut); } KeyboardShortcut key = (KeyboardShortcut)parentShortcut; return new KeyboardShortcut(convertKeyStroke(key.getFirstKeyStroke()), convertKeyStroke(key.getSecondKeyStroke())); }
Example #7
Source File: MacOSDefaultKeymap.java From consulo with Apache License 2.0 | 5 votes |
@Override protected Shortcut[] getParentShortcuts(String actionId) { Shortcut[] parentShortcuts = super.getParentShortcuts(actionId); Shortcut[] macShortcuts = new Shortcut[parentShortcuts.length]; for (int i = 0; i < parentShortcuts.length; i++) { macShortcuts[i] = convertShortcutFromParent(parentShortcuts[i]); } return macShortcuts; }
Example #8
Source File: NextOccurrenceAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected List<Shortcut> getSingleLineShortcuts() { if (mySearch) { return ContainerUtil.append(Utils.shortcutsOf(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN), CommonShortcuts.ENTER.getShortcuts()); } else { return Utils.shortcutsOf(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN); } }
Example #9
Source File: JumpToSourceAction.java From MavenHelper with Apache License 2.0 | 5 votes |
@NotNull private static String getLabel() { Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts("EditSource"); if (shortcuts.length > 0) { Shortcut shortcut = shortcuts[0]; if (shortcut.isKeyboard()) { KeyboardShortcut key = (KeyboardShortcut) shortcut; String s = KeyStrokeAdapter.toString(key.getFirstKeyStroke()); if (s != null) { return "Jump To Source [" + s.toUpperCase() + "]"; } } } return "Jump To Source"; }
Example #10
Source File: GotoTestOrCodeHandler.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override protected String getAdText(PsiElement source, int length) { if (length > 0 && !TestFinderHelper.isTest(source)) { final Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); final Shortcut[] shortcuts = keymap.getShortcuts(DefaultRunExecutor.getRunExecutorInstance().getContextActionId()); if (shortcuts.length > 0) { return ("Press " + KeymapUtil.getShortcutText(shortcuts[0]) + " to run selected tests"); } } return null; }
Example #11
Source File: AbstractSlingServerNodeDescriptor.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public static boolean addShortcutText(String actionId, CompositeAppearance appearance) { Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap(); Shortcut[] shortcuts = activeKeymap.getShortcuts(actionId); if (shortcuts != null && shortcuts.length > 0) { appearance.getEnding().addText(" (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); return true; } else return false; }
Example #12
Source File: Utils.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static CustomShortcutSet shortcutSetOf(@Nonnull List<Shortcut> shortcuts) { return new CustomShortcutSet(shortcuts.toArray(new Shortcut[shortcuts.size()])); }
Example #13
Source File: NextOccurrenceAction.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override protected List<Shortcut> getDefaultShortcuts() { return Utils.shortcutsOf(IdeActions.ACTION_FIND_NEXT); }
Example #14
Source File: PrevNextOccurrenceAction.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected abstract List<Shortcut> getSingleLineShortcuts();
Example #15
Source File: PrevNextOccurrenceAction.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull protected abstract List<Shortcut> getDefaultShortcuts();
Example #16
Source File: Utils.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public static List<Shortcut> shortcutsOf(@Nonnull String actionId) { AnAction action = ActionManager.getInstance().getAction(actionId); return action == null ? ContainerUtil.<Shortcut>emptyList() : ContainerUtil.immutableList(action.getShortcutSet().getShortcuts()); }
Example #17
Source File: InheritedMembersNodeProvider.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Shortcut[] getShortcut() { throw new IncorrectOperationException("see getActionIdForShortcut()"); }
Example #18
Source File: PopupListElementRenderer.java From consulo with Apache License 2.0 | 4 votes |
@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 (step instanceof BaseListPopupStep) { Color bg = ((BaseListPopupStep<E>)step).getBackgroundFor(value); Color fg = ((BaseListPopupStep<E>)step).getForegroundFor(value); if (!isSelected && fg != null) myTextLabel.setForeground(fg); if (!isSelected && bg != null) UIUtil.setBackgroundRecursively(myComponent, bg); if (bg != null && mySeparatorComponent.isVisible() && myCurrentIndex > 0) { E prevValue = list.getModel().getElementAt(myCurrentIndex - 1); // separator between 2 colored items shall get color too if (Comparing.equal(bg, ((BaseListPopupStep<E>)step).getBackgroundFor(prevValue))) { myRendererComponent.setBackground(bg); } } } if (step.isMnemonicsNavigationEnabled()) { MnemonicNavigationFilter<Object> filter = step.getMnemonicNavigationFilter(); int pos = filter == null ? -1 : filter.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(myComponent, isSelected && isSelectable); setSelected(myTextLabel, isSelected && isSelectable); setSelected(myNextStepLabel, isSelected && isSelectable); 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 && isSelectable); myShortcutLabel.setForeground(isSelected && isSelectable ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground")); } }
Example #19
Source File: PrevOccurrenceAction.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override protected List<Shortcut> getDefaultShortcuts() { return Utils.shortcutsOf(IdeActions.ACTION_FIND_PREVIOUS); }
Example #20
Source File: ProxyShortcutSet.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public Shortcut[] getShortcuts() { return KeymapManager.getInstance().getActiveKeymap().getShortcuts(myActionId); }
Example #21
Source File: MouseShortcutDialog.java From consulo with Apache License 2.0 | 4 votes |
/** * Updates all UI controls */ private void updatePreviewAndConflicts(){ if(myButton==-1||myModifiers==-1){ return; } myTarConflicts.setText(null); // Set text into preview area // empty string should have same height myLblPreview.setText(KeymapUtil.getMouseShortcutText(myButton,myModifiers,getClickCount()) + " "); // Detect conflicts final MouseShortcut mouseShortcut=new MouseShortcut(myButton,myModifiers,getClickCount()); if (myButton > 3 && getClickCount() == 2) { myTarConflicts.setForeground(JBColor.RED); myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.side.buttons.with.double.click", myButton)); return; } StringBuilder buffer = new StringBuilder(); String[] actionIds = myKeymap.getActionIds(mouseShortcut); for (String actionId : actionIds) { if (actionId.equals(myActionId)) { continue; } String actionPath = myMainGroup.getActionQualifiedPath(actionId); // actionPath == null for editor actions having corresponding $-actions if (actionPath == null) { continue; } Shortcut[] shortcuts = myKeymap.getShortcuts(actionId); for (Shortcut shortcut1 : shortcuts) { if (!(shortcut1 instanceof MouseShortcut)) { continue; } MouseShortcut shortcut = (MouseShortcut)shortcut1; if (shortcut.getButton() != mouseShortcut.getButton() || shortcut.getModifiers() != mouseShortcut.getModifiers()) { continue; } if (buffer.length() > 1) { buffer.append('\n'); } buffer.append('['); buffer.append(actionPath); buffer.append(']'); break; } } if (buffer.length() == 0) { myTarConflicts.setForeground(UIUtil.getTextAreaForeground()); myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.no.conflicts.area")); } else { myTarConflicts.setForeground(JBColor.RED); myTarConflicts.setText(KeyMapBundle.message("mouse.shortcut.dialog.assigned.to.area", buffer.toString())); } }
Example #22
Source File: EditorEmptyTextPainter.java From consulo with Apache License 2.0 | 4 votes |
protected void appendSearchEverywhere(@Nonnull UIUtil.TextPainter painter) { Shortcut[] shortcuts = KeymapManager.getInstance().getActiveKeymap().getShortcuts(IdeActions.ACTION_SEARCH_EVERYWHERE); appendAction(painter, "Search Everywhere", shortcuts.length == 0 ? "Double " + (SystemInfo.isMac ? MacKeymapUtil.SHIFT : "Shift") : KeymapUtil.getShortcutsText(shortcuts)); }
Example #23
Source File: CSharpLambdaNodeProvider.java From consulo-csharp with Apache License 2.0 | 4 votes |
@Override public Shortcut[] getShortcut() { return new Shortcut[]{KeyboardShortcut.fromString(SystemInfo.isMac ? "meta L" : "control L")}; }
Example #24
Source File: MindMapDocumentEditor.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override public void onNonConsumedKeyEvent(@Nonnull final MindMapPanel source, @Nonnull final KeyEvent e, @Nonnull final KeyEventType type) { if (type == KeyEventType.PRESSED) { if (e.getModifiers() == 0) { switch (e.getKeyCode()) { case KeyEvent.VK_UP: case KeyEvent.VK_LEFT: case KeyEvent.VK_RIGHT: case KeyEvent.VK_DOWN: { e.consume(); } break; } } } boolean activated = false; final ShortcutSet findAtMindMap = getFindAtMindMapShortcutSet(); if (findAtMindMap != null) { final KeyStroke eventStroke = KeyStroke.getKeyStrokeForEvent(e); for (final Shortcut c : findAtMindMap.getShortcuts()) { if (c instanceof KeyboardShortcut) { final KeyboardShortcut keyboardShortcut = (KeyboardShortcut) c; final KeyStroke firstKeyStroke = keyboardShortcut.getFirstKeyStroke(); final KeyStroke secondKeyStroke = keyboardShortcut.getSecondKeyStroke(); if (firstKeyStroke != null && firstKeyStroke.getModifiers() == eventStroke.getModifiers() && firstKeyStroke.getKeyCode() == eventStroke.getKeyCode() && firstKeyStroke.getKeyChar() == eventStroke.getKeyChar()) { activated = true; break; } if (secondKeyStroke != null && secondKeyStroke.getModifiers() == eventStroke.getModifiers() && secondKeyStroke.getKeyCode() == eventStroke.getKeyCode() && secondKeyStroke.getKeyChar() == eventStroke.getKeyChar()) { activated = true; break; } } } } if (activated) { e.consume(); activateTextSearchPanel(); } if (!e.isConsumed() && e.getModifiers() == 0 && e.getKeyCode() == KeyEvent.VK_ESCAPE) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { findTextPanel.deactivate(); } }); } }
Example #25
Source File: ProtoFieldsNodeProvider.java From protobuf-jetbrains-plugin with Apache License 2.0 | 4 votes |
@NotNull @Override public Shortcut[] getShortcut() { throw new IncorrectOperationException("see getActionIdForShortcut()"); }
Example #26
Source File: Keymap.java From consulo with Apache License 2.0 | 2 votes |
/** * @return all keyboard shortcuts for the action with the specified <code>actionId</code> * or an ampty array if the action doesn't have any keyboard shortcut. */ Shortcut[] getShortcuts(@NonNls String actionId);
Example #27
Source File: Keymap.java From consulo with Apache License 2.0 | votes |
void removeShortcut(String actionId, Shortcut shortcut);
Example #28
Source File: Keymap.java From consulo with Apache License 2.0 | votes |
void addShortcut(String actionId, Shortcut shortcut);
Example #29
Source File: Keymap.java From consulo with Apache License 2.0 | votes |
String[] getActionIds(Shortcut shortcut);
Example #30
Source File: FileStructureFilter.java From consulo with Apache License 2.0 | votes |
Shortcut[] getShortcut();