com.intellij.openapi.actionSystem.CustomShortcutSet Java Examples
The following examples show how to use
com.intellij.openapi.actionSystem.CustomShortcutSet.
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: AbstractFieldPanel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected JComponent createCenterPanel() { myTextArea = new JTextArea(10, 50); myTextArea.setText(getText()); myTextArea.setWrapStyleWord(true); myTextArea.setLineWrap(true); myTextArea.getDocument().addDocumentListener(new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { if (myChangeListener != null) { myChangeListener.run(); } } }); new AnAction() { @Override public void actionPerformed(AnActionEvent e) { doOKAction(); } }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), myTextArea); return ScrollPaneFactory.createScrollPane(myTextArea); }
Example #2
Source File: RecentLocationsAction.java From consulo with Apache License 2.0 | 6 votes |
private static void initSearchActions(@Nonnull Project project, @Nonnull RecentLocationsDataModel data, @Nonnull ListWithFilter<RecentLocationItem> listWithFilter, @Nonnull JBList<RecentLocationItem> list, @Nonnull JBCheckBox checkBox, @Nonnull JBPopup popup, @Nonnull Ref<? super Boolean> navigationRef) { listWithFilter.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { int clickCount = event.getClickCount(); if (clickCount > 1 && clickCount % 2 == 0) { event.consume(); navigateToSelected(project, list, popup, navigationRef); } } }); DumbAwareAction.create(e -> navigateToSelected(project, list, popup, navigationRef)).registerCustomShortcutSet(CustomShortcutSet.fromString("ENTER"), listWithFilter, popup); DumbAwareAction.create(e -> removePlaces(project, listWithFilter, list, data, checkBox.isSelected())) .registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), listWithFilter, popup); }
Example #3
Source File: ExtendableTextField.java From consulo with Apache License 2.0 | 5 votes |
/** * Temporary solution to support icons in the text component for different L&F. * This method replaces non-supported UI with Darcula UI. * * @param ui an object to paint this text component */ //@Override //@Deprecated //public void setUI(TextUI ui) { // TextUI suggested = ui; // try { // if (ui == null || !Class.forName("com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI_New").isAssignableFrom(ui.getClass())) { // ui = (TextUI)Class.forName("com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI_New").getDeclaredMethod("createUI", JComponent.class).invoke(null, this); // } // } // catch (Exception ignore) { // } // // super.setUI(ui); // if (ui != suggested) { // try { // setBorder((Border)Class.forName("com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder_New").newInstance()); // } // catch (Exception ignore) { // } // } //} public ExtendableTextField addBrowseExtension(@Nonnull Runnable action, @Nullable Disposable parentDisposable) { KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK); String tooltip = UIBundle.message("component.with.browse.button.browse.button.tooltip.text") + " (" + KeymapUtil.getKeystrokeText(keyStroke) + ")"; ExtendableTextComponent.Extension browseExtension = ExtendableTextComponent.Extension.create(AllIcons.Nodes.TreeOpen, AllIcons.Nodes.TreeOpen, tooltip, action); new DumbAwareAction() { @Override public void actionPerformed(@Nonnull AnActionEvent e) { action.run(); } }.registerCustomShortcutSet(new CustomShortcutSet(keyStroke), this, parentDisposable); addExtension(browseExtension); return this; }
Example #4
Source File: TemplateKindCombo.java From consulo with Apache License 2.0 | 5 votes |
public void registerUpDownHint(JComponent component) { new AnAction() { @Override public void actionPerformed(AnActionEvent e) { if (e.getInputEvent() instanceof KeyEvent) { final int code = ((KeyEvent)e.getInputEvent()).getKeyCode(); scrollBy(code == KeyEvent.VK_DOWN ? 1 : code == KeyEvent.VK_UP ? -1 : 0); } } }.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_UP, KeyEvent.VK_DOWN), component); }
Example #5
Source File: ImportUsageFilteringRuleProvider.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public AnAction[] createFilteringActions(@Nonnull final UsageView view) { if (view.getPresentation().isCodeUsages()) { final JComponent component = view.getComponent(); final ShowImportsAction showImportsAction = new ShowImportsAction(view); showImportsAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)), component, view); return new AnAction[] { showImportsAction }; } else { return AnAction.EMPTY_ARRAY; } }
Example #6
Source File: UsageGroupingRuleProviderImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public AnAction[] createGroupingActions(UsageView view) { final UsageViewImpl impl = (UsageViewImpl)view; final JComponent component = impl.getComponent(); final GroupByModuleTypeAction groupByModuleTypeAction = new GroupByModuleTypeAction(impl); groupByModuleTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)), component, impl); final GroupByFileStructureAction groupByFileStructureAction = createGroupByFileStructureAction(impl); final GroupByScopeAction groupByScopeAction = new GroupByScopeAction(impl); final GroupByPackageAction groupByPackageAction = new GroupByPackageAction(impl); groupByPackageAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)), component, impl); if(view.getPresentation().isCodeUsages()) { final GroupByUsageTypeAction groupByUsageTypeAction = new GroupByUsageTypeAction(impl); groupByUsageTypeAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK)), component, impl); return new AnAction[] { groupByUsageTypeAction, groupByScopeAction, groupByModuleTypeAction, groupByPackageAction, groupByFileStructureAction, }; } else { return new AnAction[] { groupByScopeAction, groupByModuleTypeAction, groupByPackageAction, groupByFileStructureAction, }; } }
Example #7
Source File: UsageGroupingRuleProviderImpl.java From consulo with Apache License 2.0 | 5 votes |
public static GroupByFileStructureAction createGroupByFileStructureAction(UsageViewImpl impl) { final JComponent component = impl.getComponent(); final GroupByFileStructureAction groupByFileStructureAction = new GroupByFileStructureAction(impl); groupByFileStructureAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK)), component, impl); return groupByFileStructureAction; }
Example #8
Source File: EditBookmarkDescriptionAction.java From consulo with Apache License 2.0 | 5 votes |
EditBookmarkDescriptionAction(Project project, JList list) { super(IdeBundle.message("action.bookmark.edit.description"), IdeBundle.message("action.bookmark.edit.description.description"), AllIcons.Actions.Edit); myProject = project; myList = list; registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(SystemInfo.isMac ? "meta ENTER" : "control ENTER")), list); }
Example #9
Source File: DocumentationOrderRootTypeUIFactory.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void addToolbarButtons(ToolbarDecorator toolbarDecorator) { AnActionButton specifyUrlButton = new AnActionButton(ProjectBundle.message("sdk.paths.specify.url.button"), IconUtil.getAddLinkIcon()) { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { onSpecifyUrlButtonClicked(); } }; specifyUrlButton.setShortcut(CustomShortcutSet.fromString("alt S")); specifyUrlButton.addCustomUpdater(e -> myEnabled); toolbarDecorator.addExtraAction(specifyUrlButton); }
Example #10
Source File: QuickFixAction.java From consulo with Apache License 2.0 | 5 votes |
protected QuickFixAction(String text, Image icon, KeyStroke keyStroke, @Nonnull InspectionToolWrapper toolWrapper) { super(text, null, icon); myToolWrapper = toolWrapper; if (keyStroke != null) { registerCustomShortcutSet(new CustomShortcutSet(keyStroke), null); } }
Example #11
Source File: Updater.java From consulo with Apache License 2.0 | 4 votes |
protected ShortcutSet getNextErrorShortcut() { return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("GotoNextError")); }
Example #12
Source File: DeleteBookmarkAction.java From consulo with Apache License 2.0 | 4 votes |
DeleteBookmarkAction(Project project, JList list) { super("Delete", "Delete current bookmark", AllIcons.General.Remove); myProject = project; myList = list; registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), list); }
Example #13
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 #14
Source File: SurroundElementWithAction.java From consulo with Apache License 2.0 | 4 votes |
public SurroundElementWithAction(ArtifactEditorEx artifactEditor) { super("Surround With...", artifactEditor); final CustomShortcutSet shortcutSet = new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("SurroundWith")); registerCustomShortcutSet(shortcutSet, artifactEditor.getLayoutTreeComponent().getLayoutTree()); }
Example #15
Source File: Updater.java From consulo with Apache License 2.0 | 4 votes |
protected ShortcutSet getPreviousErrorShortcut() { return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("GotoPreviousError")); }
Example #16
Source File: OCamlBinaryRootEditHandler.java From reasonml-idea-plugin with MIT License | 4 votes |
@Nullable @Override public CustomShortcutSet getMarkRootShortcutSet() { return null; }
Example #17
Source File: ComponentWithBrowseButton.java From consulo with Apache License 2.0 | 4 votes |
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())); }
Example #18
Source File: NamedItemsListEditor.java From consulo with Apache License 2.0 | 4 votes |
public CopyAction() { super("Copy", "Copy", AllIcons.Actions.Copy); registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_MASK)), myTree); }
Example #19
Source File: SynchronizeDiff.java From consulo with Apache License 2.0 | 4 votes |
@Override public ShortcutSet getShortcut() { return CustomShortcutSet.fromString(mySelectedOnly ? "ENTER" : SystemInfo.isMac ? "meta ENTER" : "control ENTER"); }
Example #20
Source File: ColorField.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ColorField(PropertyEditorPanel panel, String name, FlutterWidgetProperty property, Disposable parentDisposable) { super("", 1); this.name = name; final String expression = property.getExpression(); if (expression != null) { setText(expression); } this.originalExpression = expression; currentColor = parseColorExpression(expression); final ColorIconMaker maker = new ColorIconMaker(); // InputEvent.SHIFT_DOWN_MASK ? final KeyStroke keyStroke = KeyStroke.getKeyStroke(10, 64); setColorExtension = new Extension() { @Override public boolean isIconBeforeText() { return true; } public Icon getIcon(boolean hovered) { if (currentColor == null) { return AllIcons.Actions.Colors; } return maker.getCustomIcon(currentColor); } public String getTooltip() { return "Edit color"; } public Runnable getActionOnClick() { return () -> showColorFieldPopup(); } }; (new DumbAwareAction() { public void actionPerformed(@NotNull AnActionEvent e) { showColorFieldPopup(); } }).registerCustomShortcutSet(new CustomShortcutSet(keyStroke), this, parentDisposable); addExtension(setColorExtension); panel.addTextFieldListeners(name, this); this.panel = panel; }
Example #21
Source File: ColorField.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 4 votes |
public ColorField(PropertyEditorPanel panel, String name, FlutterWidgetProperty property, Disposable parentDisposable) { super("", 1); this.name = name; final String expression = property.getExpression(); if (expression != null) { setText(expression); } this.originalExpression = expression; currentColor = parseColorExpression(expression); final ColorIconMaker maker = new ColorIconMaker(); // InputEvent.SHIFT_DOWN_MASK ? final KeyStroke keyStroke = KeyStroke.getKeyStroke(10, 64); setColorExtension = new Extension() { @Override public boolean isIconBeforeText() { return true; } public Icon getIcon(boolean hovered) { if (currentColor == null) { return AllIcons.Actions.Colors; } return maker.getCustomIcon(currentColor); } public String getTooltip() { return "Edit color"; } public Runnable getActionOnClick() { return () -> showColorFieldPopup(); } }; (new DumbAwareAction() { public void actionPerformed(@NotNull AnActionEvent e) { showColorFieldPopup(); } }).registerCustomShortcutSet(new CustomShortcutSet(keyStroke), this, parentDisposable); addExtension(setColorExtension); panel.addTextFieldListeners(name, this); this.panel = panel; }
Example #22
Source File: MnemonicHelper.java From consulo with Apache License 2.0 | 2 votes |
/** * Creates shortcut for mnemonic replacing standard Alt+Letter to Ctrl+Alt+Letter on Mac with jdk version newer than 6 * * @param ch mnemonic letter * @return shortcut for mnemonic */ public static CustomShortcutSet createShortcut(char ch) { Character mnemonic = Character.valueOf(ch); return CustomShortcutSet.fromString("alt " + (SystemInfo.isMac ? "released" : "pressed") + " " + mnemonic); }