Java Code Examples for com.intellij.openapi.actionSystem.AnAction#registerCustomShortcutSet()
The following examples show how to use
com.intellij.openapi.actionSystem.AnAction#registerCustomShortcutSet() .
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: MultilinePopupBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull JBPopup createPopup() { JPanel panel = new JPanel(new BorderLayout()); panel.add(myTextField, BorderLayout.CENTER); ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField) .setCancelOnClickOutside(true) .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish") .setRequestFocus(true) .setResizable(true) .setMayBeParent(true); final JBPopup popup = builder.createPopup(); popup.setMinimumSize(new JBDimension(200, 90)); AnAction okAction = new DumbAwareAction() { @Override public void actionPerformed(@Nonnull AnActionEvent e) { unregisterCustomShortcutSet(popup.getContent()); popup.closeOk(e.getInputEvent()); } }; okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent()); return popup; }
Example 2
Source File: UpDownHandler.java From consulo with Apache License 2.0 | 5 votes |
public static void register(final JComponent input, final JComponent affectedComponent, boolean registerOnBothComponents) { final SelectionMover mover = new SelectionMover(affectedComponent); final AnAction up = new UpDownAction(mover, input, true); up.registerCustomShortcutSet(UP_KEY, input); final AnAction down = new UpDownAction(mover, input, false); down.registerCustomShortcutSet(DOWN_KEY, input); if (registerOnBothComponents) { up.registerCustomShortcutSet(UP_KEY, affectedComponent); down.registerCustomShortcutSet(DOWN_KEY, affectedComponent); } }
Example 3
Source File: TaskDefaultFavoriteListProvider.java From consulo with Apache License 2.0 | 5 votes |
private void showNotePopup(Project project, final DnDAwareTree tree, final Consumer<String> after, final String initText) { final JTextArea textArea = new JTextArea(3, 50); textArea.setFont(UIUtil.getTreeFont()); textArea.setText(initText); final JBScrollPane pane = new JBScrollPane(textArea); final ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(pane, textArea) .setCancelOnClickOutside(true) .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish") .setTitle("Comment") .setMovable(true) .setRequestFocus(true).setResizable(true).setMayBeParent(true); final JBPopup popup = builder.createPopup(); final JComponent content = popup.getContent(); final AnAction action = new AnAction() { @Override public void actionPerformed(AnActionEvent e) { popup.closeOk(e.getInputEvent()); unregisterCustomShortcutSet(content); after.consume(textArea.getText()); } }; action.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, content); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { popup.showInCenterOf(tree); } }, ModalityState.NON_MODAL, project.getDisposed()); }
Example 4
Source File: DiffUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void registerAction(@Nonnull AnAction action, @Nonnull JComponent component) { action.registerCustomShortcutSet(action.getShortcutSet(), component); }
Example 5
Source File: DualView.java From consulo with Apache License 2.0 | 4 votes |
public void installDoubleClickHandler(AnAction action) { action.registerCustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1, myFlatView); action.registerCustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1, myTreeView); }
Example 6
Source File: DebuggerUIUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void registerActionOnComponent(String name, JComponent component, Disposable parentDisposable) { AnAction action = ActionManager.getInstance().getAction(name); action.registerCustomShortcutSet(action.getShortcutSet(), component, parentDisposable); }