com.intellij.openapi.actionSystem.CommonShortcuts Java Examples

The following examples show how to use com.intellij.openapi.actionSystem.CommonShortcuts. 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 vote down vote up
@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: FrameWrapper.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void addCloseOnEsc(final RootPaneContainer frame) {
  JRootPane rootPane = frame.getRootPane();
  ActionListener closeAction = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      if (!PopupUtil.handleEscKeyEvent()) {
        // if you remove this line problems will start happen on Mac OS X
        // 2 projects opened, call Cmd+D on the second opened project and then Esc.
        // Weird situation: 2nd IdeFrame will be active, but focus will be somewhere inside the 1st IdeFrame
        // App is unusable until Cmd+Tab, Cmd+tab
        FrameWrapper.this.myFrame.setVisible(false);
        close();
      }
    }
  };
  rootPane.registerKeyboardAction(closeAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
  ActionUtil.registerForEveryKeyboardShortcut(rootPane, closeAction, CommonShortcuts.getCloseActiveWindow());
}
 
Example #3
Source File: DiffWindowBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void init() {
  if (myWrapper != null) return;

  myProcessor = createProcessor();

  String dialogGroupKey = myProcessor.getContextUserData(DiffUserDataKeys.DIALOG_GROUP_KEY);
  if (dialogGroupKey == null) dialogGroupKey = "DiffContextDialog";

  myWrapper = new WindowWrapperBuilder(DiffUtil.getWindowMode(myHints), new MyPanel(myProcessor.getComponent()))
          .setProject(myProject)
          .setParent(myHints.getParent())
          .setDimensionServiceKey(dialogGroupKey)
          .setOnShowCallback(new Runnable() {
            @Override
            public void run() {
              myProcessor.updateRequest();
              myProcessor.requestFocus(); // TODO: not needed for modal dialogs. Make a flag in WindowWrapperBuilder ?
            }
          })
          .build();
  myWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png"));
  Disposer.register(myWrapper, myProcessor);

  new DumbAwareAction() {
    public void actionPerformed(final AnActionEvent e) {
      myWrapper.close();
    }
  }.registerCustomShortcutSet(CommonShortcuts.getCloseActiveWindow(), myProcessor.getComponent());
}
 
Example #4
Source File: RunAnythingScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void installMoveUpAction(@Nonnull JList list, @Nonnull JComponent focusParent, @Nonnull Runnable handleFocusParent, final boolean isCycleScrolling) {
  new ScrollingUtil.ListScrollAction(CommonShortcuts.getMoveUp(), focusParent) {
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      moveUp(list, handleFocusParent, isCycleScrolling);
    }
  };
}
 
Example #5
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void installMoveEndAction(final JList list, @Nullable JComponent focusParent) {
  new ListScrollAction(CommonShortcuts.getMoveEnd(), focusParent == null ? list : focusParent){
    @Override
    public void actionPerformed(AnActionEvent e) {
      moveEnd(list);
    }
  };
}
 
Example #6
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void installMoveHomeAction(final JList list, @Nullable JComponent focusParent) {
  new ListScrollAction(CommonShortcuts.getMoveHome(), focusParent == null ? list : focusParent){
    @Override
    public void actionPerformed(AnActionEvent e) {
      moveHome(list);
    }
  };
}
 
Example #7
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void installMovePageDownAction(final JList list, @Nullable JComponent focusParent) {
  new ListScrollAction(CommonShortcuts.getMovePageDown(), focusParent == null ? list : focusParent){
    @Override
    public void actionPerformed(AnActionEvent e) {
      movePageDown(list);
    }
  };
}
 
Example #8
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void installMovePageUpAction(final JList list, @Nullable JComponent focusParent) {
  new ListScrollAction(CommonShortcuts.getMovePageUp(), focusParent == null ? list : focusParent){
    @Override
    public void actionPerformed(AnActionEvent e) {
      movePageUp(list);
    }
  };
}
 
Example #9
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void installMoveDownAction(final JList list, @Nullable JComponent focusParent) {
  new ListScrollAction(CommonShortcuts.getMoveDown(), focusParent == null ? list : focusParent){
    @Override
    public void actionPerformed(AnActionEvent e) {
      moveDown(list, 0);
    }
  };
}
 
Example #10
Source File: ScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void installMoveUpAction(final JList list, @Nullable JComponent focusParent) {
  new ListScrollAction(CommonShortcuts.getMoveUp(), focusParent == null ? list : focusParent) {
    @Override
    public void actionPerformed(AnActionEvent e) {
      moveUp(list, 0);
    }
  };
}
 
Example #11
Source File: RunAnythingScrollingUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void installMoveDownAction(@Nonnull JList list, @Nonnull JComponent focusParent, @Nonnull Runnable handleFocusParent, final boolean isCycleScrolling) {
  new ScrollingUtil.ListScrollAction(CommonShortcuts.getMoveDown(), focusParent) {
    @Override
    public void actionPerformed(@Nonnull AnActionEvent e) {
      moveDown(list, handleFocusParent, isCycleScrolling);
    }
  };
}
 
Example #12
Source File: TaskDefaultFavoriteListProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #13
Source File: NextOccurrenceAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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 #14
Source File: BuildUtils.java    From CppTools with Apache License 2.0 4 votes vote down vote up
public RerunAction(final ConsoleView consoleView, OSProcessHandler processHandler, Runnable rerun) {
  super(CommonBundle.message("action.rerun"),CommonBundle.message("action.rerun"),
        IconLoader.getIcon("/actions/refreshUsages.png"), consoleView, processHandler, rerun);
  registerCustomShortcutSet(CommonShortcuts.getRerun(),consoleView.getComponent());
}
 
Example #15
Source File: MoveBookmarkUpAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
MoveBookmarkUpAction(Project project, JList list) {
  super("Up", "Move current bookmark up", AllIcons.Actions.PreviousOccurence);
  myProject = project;
  myList = list;
  registerCustomShortcutSet(CommonShortcuts.MOVE_UP, list);
}
 
Example #16
Source File: MoveBookmarkDownAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
MoveBookmarkDownAction(Project project, JList list) {
  super("Down", "Move current bookmark down", AllIcons.Actions.NextOccurence);
  myProject = project;
  myList = list;
  registerCustomShortcutSet(CommonShortcuts.MOVE_DOWN, list);
}
 
Example #17
Source File: RenamePackagingElementAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RenamePackagingElementAction(ArtifactEditorEx artifactEditor) {
  super(ProjectBundle.message("action.name.rename.packaging.element"));
  registerCustomShortcutSet(CommonShortcuts.getRename(), artifactEditor.getLayoutTreeComponent().getTreePanel());
  myArtifactEditor = artifactEditor;
}
 
Example #18
Source File: ArtifactEditorNavigateActionBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ArtifactEditorNavigateActionBase(JComponent contextComponent) {
  super(ProjectBundle.message("action.name.facet.navigate"));
  registerCustomShortcutSet(CommonShortcuts.getEditSource(), contextComponent);
}
 
Example #19
Source File: DualView.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void installDoubleClickHandler(AnAction action) {
  action.registerCustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1, myFlatView);
  action.registerCustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1, myTreeView);
}
 
Example #20
Source File: NamedItemsListEditor.java    From consulo with Apache License 2.0 4 votes vote down vote up
public AddAction() {
    super("Add", "Add", IconUtil.getAddIcon());
    registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}
 
Example #21
Source File: RemoteServerListConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
private AddRemoteServerGroup() {
  super("Add", "", IconUtil.getAddIcon());
  registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}