com.intellij.openapi.actionSystem.IdeActions Java Examples

The following examples show how to use com.intellij.openapi.actionSystem.IdeActions. 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: DesktopFileSystemTreeFactoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
@Nonnull
public DefaultActionGroup createDefaultFileSystemActions(FileSystemTree fileSystemTree) {
  DefaultActionGroup group = new DefaultActionGroup();
  final ActionManager actionManager = ActionManager.getInstance();
  group.add(actionManager.getAction("FileChooser.GotoHome"));
  group.add(actionManager.getAction("FileChooser.GotoProject"));
  group.addSeparator();
  group.add(actionManager.getAction("FileChooser.NewFolder"));
  group.add(actionManager.getAction("FileChooser.Delete"));
  group.addSeparator();
  SynchronizeAction action1 = new SynchronizeAction();
  AnAction original = actionManager.getAction(IdeActions.ACTION_SYNCHRONIZE);
  action1.copyFrom(original);
  action1.registerCustomShortcutSet(original.getShortcutSet(), fileSystemTree.getTree());
  group.add(action1);
  group.addSeparator();
  group.add(actionManager.getAction("FileChooser.ShowHiddens"));

  return group;
}
 
Example #2
Source File: JumpHandler.java    From KJump with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void stop() {
    if (isStart) {
        isStart = false;
        EditorActionManager manager = EditorActionManager.getInstance();
        manager.getTypedAction().setupRawHandler(mOldTypedHandler);
        if (mOldEscActionHandler != null) {
            manager.setActionHandler(IdeActions.ACTION_EDITOR_ESCAPE, mOldEscActionHandler);
        }

        Container parent = mMarksCanvas.getParent();
        if (parent != null) {
            parent.remove(mMarksCanvas);
            parent.repaint();
        }

        isCanvasAdded = false;
    }
}
 
Example #3
Source File: CustomActionsSchema.java    From consulo with Apache License 2.0 6 votes vote down vote up
public CustomActionsSchema() {
  myIdToNameList.add(new Pair(IdeActions.GROUP_MAIN_MENU, ActionsTreeUtil.MAIN_MENU_TITLE));
  myIdToNameList.add(new Pair(IdeActions.GROUP_MAIN_TOOLBAR, ActionsTreeUtil.MAIN_TOOLBAR));
  myIdToNameList.add(new Pair(IdeActions.GROUP_EDITOR_POPUP, ActionsTreeUtil.EDITOR_POPUP));
  myIdToNameList.add(new Pair(IdeActions.GROUP_EDITOR_GUTTER, "Editor Gutter Popup Menu"));
  myIdToNameList.add(new Pair(IdeActions.GROUP_EDITOR_TAB_POPUP, ActionsTreeUtil.EDITOR_TAB_POPUP));
  myIdToNameList.add(new Pair(IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionsTreeUtil.PROJECT_VIEW_POPUP));
  myIdToNameList.add(new Pair(IdeActions.GROUP_SCOPE_VIEW_POPUP, "Scope View Popup Menu"));
  myIdToNameList.add(new Pair(IdeActions.GROUP_FAVORITES_VIEW_POPUP, ActionsTreeUtil.FAVORITES_POPUP));
  myIdToNameList.add(new Pair(IdeActions.GROUP_COMMANDER_POPUP, ActionsTreeUtil.COMMANDER_POPUP));
  myIdToNameList.add(new Pair(IdeActions.GROUP_J2EE_VIEW_POPUP, ActionsTreeUtil.J2EE_POPUP));
  myIdToNameList.add(new Pair(IdeActions.GROUP_NAVBAR_POPUP, "Navigation Bar"));
  myIdToNameList.add(new Pair("NavBarToolBar", "Navigation Bar Toolbar"));

  CustomizableActionGroupProvider.CustomizableActionGroupRegistrar registrar = new CustomizableActionGroupProvider.CustomizableActionGroupRegistrar() {
    @Override
    public void addCustomizableActionGroup(@Nonnull String groupId, @Nonnull String groupTitle) {
      myIdToNameList.add(new Pair(groupId, groupTitle));
    }
  };
  for (CustomizableActionGroupProvider provider : CustomizableActionGroupProvider.EP_NAME.getExtensions()) {
    provider.registerGroups(registrar);
  }
}
 
Example #4
Source File: ParameterInfoComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void setShortcutLabel() {
  if (myShortcutLabel != null) remove(myShortcutLabel);

  String upShortcut = KeymapUtil.getFirstKeyboardShortcutText(IdeActions.ACTION_METHOD_OVERLOAD_SWITCH_UP);
  String downShortcut = KeymapUtil.getFirstKeyboardShortcutText(IdeActions.ACTION_METHOD_OVERLOAD_SWITCH_DOWN);
  if (!myAllowSwitchLabel || myObjects.length <= 1 || !myHandler.supportsOverloadSwitching() || upShortcut.isEmpty() && downShortcut.isEmpty()) {
    myShortcutLabel = null;
  }
  else {
    myShortcutLabel = new JLabel(upShortcut.isEmpty() || downShortcut.isEmpty()
                                 ? CodeInsightBundle.message("parameter.info.switch.overload.shortcuts.single", upShortcut.isEmpty() ? downShortcut : upShortcut)
                                 : CodeInsightBundle.message("parameter.info.switch.overload.shortcuts", upShortcut, downShortcut));
    myShortcutLabel.setForeground(CONTEXT_HELP_FOREGROUND);
    Font labelFont = UIUtil.getLabelFont();
    myShortcutLabel.setFont(labelFont.deriveFont(labelFont.getSize2D() - (SystemInfo.isWindows ? 1 : 2)));
    myShortcutLabel.setBorder(JBUI.Borders.empty(6, 10, 0, 10));
    add(myShortcutLabel, BorderLayout.SOUTH);
  }
}
 
Example #5
Source File: HungryBackspaceAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredWriteAction
@Override
public void executeWriteAction(@Nonnull Editor editor, Caret caret, DataContext dataContext) {
  final Document document = editor.getDocument();
  final int caretOffset = editor.getCaretModel().getOffset();
  if (caretOffset < 1) {
    return;
  }

  final SelectionModel selectionModel = editor.getSelectionModel();
  final CharSequence text = document.getCharsSequence();
  final char c = text.charAt(caretOffset - 1);
  if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) {
    int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1;
    document.deleteString(startOffset, caretOffset);
  }
  else {
    final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE);
    handler.execute(editor, caret, dataContext);
  }
}
 
Example #6
Source File: StatusPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private Action createCopyAction() {
  ActionManager actionManager = ActionManager.getInstance();
  if (actionManager == null) return null;
  AnAction action = actionManager.getAction(IdeActions.ACTION_COPY);
  if (action == null) return null;
  return new AbstractAction(action.getTemplatePresentation().getText(), action.getTemplatePresentation().getIcon()) {
    @Override
    public void actionPerformed(ActionEvent e) {
      StringSelection content = new StringSelection(getText());
      ClipboardSynchronizer.getInstance().setContent(content, content);
    }

    @Override
    public boolean isEnabled() {
      return !getText().isEmpty();
    }
  };
}
 
Example #7
Source File: DesktopEditorComposite.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private TabbedPaneWrapper.AsJBTabs createTabbedPaneWrapper(FileEditor[] editors) {
  PrevNextActionsDescriptor descriptor = new PrevNextActionsDescriptor(IdeActions.ACTION_NEXT_EDITOR_TAB, IdeActions.ACTION_PREVIOUS_EDITOR_TAB);
  final TabbedPaneWrapper.AsJBTabs wrapper = new TabbedPaneWrapper.AsJBTabs(myFileEditorManager.getProject(), SwingConstants.BOTTOM, descriptor, this);
  wrapper.getTabs().getPresentation().setPaintBorder(0, 0, 0, 0).setTabSidePaintBorder(1).setGhostsAlwaysVisible(true)
          .setUiDecorator(() -> new UiDecorator.UiDecoration(null, new Insets(0, 8, 0, 8)));
  wrapper.getTabs().getComponent().setBorder(new EmptyBorder(0, 0, 1, 0));

  boolean firstEditor = true;
  for (FileEditor editor : editors) {
    JComponent component = firstEditor && myComponent != null ? (JComponent)myComponent.getComponent(0) : createEditorComponent(editor);
    wrapper.addTab(getDisplayName(editor), component);
    firstEditor = false;
  }
  wrapper.addChangeListener(new MyChangeListener());

  return wrapper;
}
 
Example #8
Source File: CloseTabToolbarAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public CloseTabToolbarAction() {
  copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE_ACTIVE_TAB));
  Presentation presentation = getTemplatePresentation();
  presentation.setIcon(AllIcons.Actions.Cancel);
  presentation.setText(CommonBundle.getCloseButtonText());
  presentation.setDescription(null);
}
 
Example #9
Source File: DefaultKeymapImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void readExternal(Element keymapElement, Keymap[] existingKeymaps) throws InvalidDataException {
  super.readExternal(keymapElement, existingKeymaps);

  if (KeymapManager.DEFAULT_IDEA_KEYMAP.equals(getName()) && !SystemInfo.isXWindow) {
    addShortcut(IdeActions.ACTION_GOTO_DECLARATION, new MouseShortcut(MouseEvent.BUTTON2, 0, 1));
  }
}
 
Example #10
Source File: ActionShortcutRestrictions.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public ShortcutRestrictions getForActionId(String actionId) {
  if (IdeActions.ACTION_EDITOR_ADD_OR_REMOVE_CARET.equals(actionId)) {
    return new ShortcutRestrictions(true, false, false, false);
  }
  return ShortcutRestrictions.NO_RESTRICTIONS;
}
 
Example #11
Source File: TextEditorComponent.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private Editor createEditor() {
  Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject);
  ((EditorMarkupModel)editor.getMarkupModel()).setErrorStripeVisible(true);
  ((EditorEx)editor).getGutterComponentEx().setForceShowRightFreePaintersArea(true);

  ((EditorEx)editor).setFile(myFile);

  ((EditorEx)editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP);

  ((DesktopEditorImpl)editor).setDropHandler(new FileDropHandler(editor));

  TextEditorProvider.putTextEditor(editor, myTextEditor);
  return editor;
}
 
Example #12
Source File: EditorEmptyTextPainter.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected void advertiseActions(@Nonnull JComponent splitters, @Nonnull UIUtil.TextPainter painter) {
  appendSearchEverywhere(painter);
  appendToolWindow(painter, "Project View", ToolWindowId.PROJECT_VIEW, splitters);
  appendAction(painter, "Go to File", getActionShortcutText("GotoFile"));
  appendAction(painter, "Recent Files", getActionShortcutText(IdeActions.ACTION_RECENT_FILES));
  appendAction(painter, "Navigation Bar", getActionShortcutText("ShowNavBar"));
  appendDnd(painter);
}
 
Example #13
Source File: TextComponentSelectionModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void selectWordAtCaret(final boolean honorCamelWordsSettings) {
  removeSelection();

  EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(
          IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET);
  handler.execute(myEditor, null, DataManager.getInstance().getDataContext(myEditor.getComponent()));
}
 
Example #14
Source File: SwitchToFind.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void update(AnActionEvent e) {
  if (KeymapUtil.isEmacsKeymap()) {
    // Emacs users are accustomed to the editor that executes 'find next' on subsequent pressing of shortcut that
    // activates 'incremental search'. Hence, we do the similar hack here for them.
    ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT).update(e);
  }
  else {
    EditorSearchSession search = e.getData(EditorSearchSession.SESSION_KEY);
    e.getPresentation().setEnabledAndVisible(search != null);
  }
}
 
Example #15
Source File: ConsoleLogConsole.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
private DefaultActionGroup createPopupActions(ActionManager actionManager, ClearLogAction action) {
    AnAction[] children = ((ActionGroup)actionManager.getAction(IdeActions.GROUP_CONSOLE_EDITOR_POPUP)).getChildren(null);
    DefaultActionGroup group = new DefaultActionGroup(children);
    group.addSeparator();
    group.add(action);
    return group;
}
 
Example #16
Source File: ConsoleLogToolWindowFactory.java    From aem-ide-tooling-4-intellij with Apache License 2.0 5 votes vote down vote up
private static ActionToolbar createToolbar(Project project, Editor editor, ConsoleLogConsole console) {
    DefaultActionGroup group = new DefaultActionGroup();
    group.add(new EditNotificationSettings(project));
    group.add(new DisplayBalloons());
    group.add(new ToggleSoftWraps(editor));
    group.add(new ScrollToTheEndToolbarAction(editor));
    group.add(ActionManager.getInstance().getAction(IdeActions.ACTION_MARK_ALL_NOTIFICATIONS_AS_READ));
    group.add(new ConsoleLogConsole.ClearLogAction(console));
    group.add(new ContextHelpAction(ConsoleLog.HELP_ID));

    return ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, false);
}
 
Example #17
Source File: SwitchToFind.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  if (KeymapUtil.isEmacsKeymap()) {
    // Emacs users are accustomed to the editor that executes 'find next' on subsequent pressing of shortcut that
    // activates 'incremental search'. Hence, we do the similar hack here for them.
    ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_NEXT).actionPerformed(e);
    return;
  }

  EditorSearchSession search = e.getRequiredData(EditorSearchSession.SESSION_KEY);
  final FindModel findModel = search.getFindModel();
  FindUtil.configureFindModel(false, e.getDataContext().getData(EDITOR), findModel, false);
  search.getComponent().getSearchTextComponent().selectAll();
}
 
Example #18
Source File: StatisticsPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public StatisticsPanel(final Project project, final TestFrameworkRunningModel model) {
  myProject = project;
  myTableModel = new StatisticsTableModel();
  myStatisticsTableView.setModelAndUpdateColumns(myTableModel);
  myFrameworkRunningModel = model;

  final Runnable gotoSuiteOrParentAction = createGotoSuiteOrParentAction();
  new DoubleClickListener() {
    @Override
    protected boolean onDoubleClick(MouseEvent e) {
      gotoSuiteOrParentAction.run();
      return true;
    }
  }.installOn(myStatisticsTableView);

  // Fire selection changed and move focus on SHIFT+ENTER
  final KeyStroke shiftEnterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_MASK);
  SMRunnerUtil.registerAsAction(shiftEnterKey, "select-test-proxy-in-test-view",
                          new Runnable() {
                            public void run() {
                              showSelectedProxyInTestsTree();
                            }
                          },
                          myStatisticsTableView);

  // Expand selected or go to parent on ENTER
  final KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
  SMRunnerUtil.registerAsAction(enterKey, "go-to-selected-suite-or-parent",
                          gotoSuiteOrParentAction,
                          myStatisticsTableView);
  // Contex menu in Table
  PopupHandler.installPopupHandler(myStatisticsTableView, IdeActions.GROUP_TESTTREE_POPUP, ActionPlaces.TESTTREE_VIEW_POPUP);
  // set this statistic tab as dataprovider for test's table view
  DataManager.registerDataProvider(myStatisticsTableView, this);
}
 
Example #19
Source File: ShowAutoImportPass.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String getMessage(final boolean multiple, @Nonnull String name) {
  final String messageKey = multiple ? "import.popup.multiple" : "import.popup.text";
  String hintText = DaemonBundle.message(messageKey, name);
  hintText += " " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_SHOW_INTENTION_ACTIONS));
  return hintText;
}
 
Example #20
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 #21
Source File: ShowErrorDescriptionAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void changeState() {
  if (Comparing.strEqual(ActionManagerEx.getInstanceEx().getPrevPreformedActionId(), IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)) {
    shouldShowDescription = descriptionShown;
  } else {
    shouldShowDescription = false;
    descriptionShown = true;
  }
}
 
Example #22
Source File: CtrlMouseHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static BrowseMode getBrowseMode(@JdkConstants.InputEventMask int modifiers) {
  if (modifiers != 0) {
    final Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
    if (KeymapUtil.matchActionMouseShortcutsModifiers(activeKeymap, modifiers, IdeActions.ACTION_GOTO_DECLARATION)) return BrowseMode.Declaration;
    if (KeymapUtil.matchActionMouseShortcutsModifiers(activeKeymap, modifiers, IdeActions.ACTION_GOTO_TYPE_DECLARATION)) return BrowseMode.TypeDeclaration;
    if (KeymapUtil.matchActionMouseShortcutsModifiers(activeKeymap, modifiers, IdeActions.ACTION_GOTO_IMPLEMENTATION)) return BrowseMode.Implementation;
  }
  return BrowseMode.None;
}
 
Example #23
Source File: PromptConsole.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
private void setupPromptEditor() {
    EditorSettings editorSettings = ((EditorEx) m_promptEditor).getSettings();
    editorSettings.setAdditionalLinesCount(0);

    m_promptEditor.getComponent().setPreferredSize(new Dimension(0, 100));

    // add copy/paste actions
    m_promptEditor.addEditorMouseListener(EditorActionUtil.createEditorPopupHandler(IdeActions.GROUP_CUT_COPY_PASTE));

    // hook some key event on prompt editor
    m_promptEditor.getContentComponent().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(@NotNull KeyEvent e) {
            if (m_promptEnabled && e.isControlDown()) {
                int keyCode = e.getKeyCode();
                if (keyCode == KeyEvent.VK_ENTER) {
                    String command = normalizeCommand(m_promptEditor.getDocument().getText());
                    m_history.addInHistory(command);
                    m_consoleView.print(command + "\r\n", USER_INPUT);
                    m_consoleView.scrollToEnd();
                    ApplicationManager.getApplication().runWriteAction(() -> setPromptCommand(""));
                } else if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) {
                    String history = m_history.getFromHistory(keyCode == KeyEvent.VK_DOWN);
                    if (history != null) {
                        ApplicationManager.getApplication().runWriteAction(() -> setPromptCommand(history));
                    }
                }
            }
        }
    });
}
 
Example #24
Source File: StartNewLineBeforeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredWriteAction
@Override
public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) {
  editor.getSelectionModel().removeSelection();
  LogicalPosition caretPosition = editor.getCaretModel().getLogicalPosition();
  final int line = caretPosition.line;
  int lineStartOffset = editor.getDocument().getLineStartOffset(line);
  editor.getCaretModel().moveToOffset(lineStartOffset);
  getHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, caret, dataContext);
  editor.getCaretModel().moveToOffset(editor.getDocument().getLineStartOffset(line));
  getHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END).execute(editor, caret, dataContext);
}
 
Example #25
Source File: HighlightUsagesHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
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 #26
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void advertiseCtrlArrows() {
  if (!myEditor.isOneLineMode() && FeatureUsageTracker.getInstance().isToBeAdvertisedInLookup(CodeCompletionFeatures.EDITING_COMPLETION_CONTROL_ARROWS, getProject())) {
    String downShortcut = CompletionUtil.getActionShortcut(IdeActions.ACTION_LOOKUP_DOWN);
    String upShortcut = CompletionUtil.getActionShortcut(IdeActions.ACTION_LOOKUP_UP);
    if (StringUtil.isNotEmpty(downShortcut) && StringUtil.isNotEmpty(upShortcut)) {
      addAdvertisement(downShortcut + " and " + upShortcut + " will move caret down and up in the editor", null);
    }
  }
}
 
Example #27
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void advertiseCtrlDot() {
  if (FeatureUsageTracker.getInstance().isToBeAdvertisedInLookup(CodeCompletionFeatures.EDITING_COMPLETION_FINISH_BY_CONTROL_DOT, getProject())) {
    String dotShortcut = CompletionUtil.getActionShortcut(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_DOT);
    if (StringUtil.isNotEmpty(dotShortcut)) {
      addAdvertisement("Press " + dotShortcut + " to choose the selected (or first) suggestion and insert a dot afterwards", null);
    }
  }
}
 
Example #28
Source File: CompletionProgressIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void advertiseTabReplacement(CompletionParameters parameters) {
  if (CompletionUtil.shouldShowFeature(parameters, CodeCompletionFeatures.EDITING_COMPLETION_REPLACE) &&
      myOffsetMap.getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET) != myOffsetMap.getOffset(CompletionInitializationContext.SELECTION_END_OFFSET)) {
    String shortcut = CompletionUtil.getActionShortcut(IdeActions.ACTION_CHOOSE_LOOKUP_ITEM_REPLACE);
    if (StringUtil.isNotEmpty(shortcut)) {
      addAdvertisement("Use " + shortcut + " to overwrite the current identifier with the chosen variant", null);
    }
  }
}
 
Example #29
Source File: AbstractProjectViewPSIPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void initTree() {
  myTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
  UIUtil.setLineStyleAngled(myTree);
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(true);
  myTree.expandPath(new TreePath(myTree.getModel().getRoot()));

  EditSourceOnDoubleClickHandler.install(myTree);

  ToolTipManager.sharedInstance().registerComponent(myTree);
  TreeUtil.installActions(myTree);

  new MySpeedSearch(myTree);

  myTree.addKeyListener(new KeyAdapter() {
    @Override
    public void keyPressed(KeyEvent e) {
      if (KeyEvent.VK_ENTER == e.getKeyCode()) {
        TreePath path = getSelectedPath();
        if (path != null && !myTree.getModel().isLeaf(path.getLastPathComponent())) {
          return;
        }

        DataContext dataContext = DataManager.getInstance().getDataContext(myTree);
        OpenSourceUtil.openSourcesFrom(dataContext, ScreenReader.isActive());
      }
      else if (KeyEvent.VK_ESCAPE == e.getKeyCode()) {
        if (e.isConsumed()) return;
        PsiCopyPasteManager copyPasteManager = PsiCopyPasteManager.getInstance();
        boolean[] isCopied = new boolean[1];
        if (copyPasteManager.getElements(isCopied) != null && !isCopied[0]) {
          copyPasteManager.clear();
          e.consume();
        }
      }
    }
  });
  CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_PROJECT_VIEW_POPUP, ActionPlaces.PROJECT_VIEW_POPUP);
}
 
Example #30
Source File: ScopeViewPane.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public JComponent createComponent() {
  myViewPanel = new ScopeTreeViewPanel(myProject);
  Disposer.register(this, myViewPanel);
  myViewPanel.initListeners();
  myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId()));
  myTree = myViewPanel.getTree();
  PopupHandler.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP);
  enableDnD();

  return myViewPanel.getPanel();
}