private AnAction createBackspaceHandlingAction() {
    final AnAction upAction =
        new AnAction() {
          @Override
          public void actionPerformed(final AnActionEvent e) {
            new WriteCommandAction(
                getLanguageConsole().getProject(), getLanguageConsole().getFile()) {
              @Override
              protected void run(@NotNull final Result result) throws Throwable {
                String text = getLanguageConsole().getEditorDocument().getText();
                String newText =
                    text.substring(
                        0, text.length() - myConsoleExecuteActionHandler.getPythonIndent());
                getLanguageConsole().getEditorDocument().setText(newText);
                getLanguageConsole()
                    .getConsoleEditor()
                    .getCaretModel()
                    .moveToOffset(newText.length());
              }
            }.execute();
          }

          @Override
          public void update(final AnActionEvent e) {
            e.getPresentation()
                .setEnabled(
                    myConsoleExecuteActionHandler.getCurrentIndentSize()
                            >= myConsoleExecuteActionHandler.getPythonIndent()
                        && isIndentSubstring(getLanguageConsole().getEditorDocument().getText()));
          }
        };
    upAction.registerCustomShortcutSet(KeyEvent.VK_BACK_SPACE, 0, null);
    upAction.getTemplatePresentation().setVisible(false);
    return upAction;
  }
Example #2
0
 private void mousePressedInIconsArea(MouseEvent e) {
   EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e);
   if (iconRenderer != null) {
     if (e.getButton() == MouseEvent.BUTTON3) {
       JPopupMenu popupMenu = iconRenderer.getPopupMenu();
       if (popupMenu != null && e.getID() == MouseEvent.MOUSE_PRESSED) {
         e.consume();
         Component component = e.getComponent();
         popupMenu.show(component == null ? myEditorComponent : component, e.getX(), e.getY());
       }
       return;
     }
     AnAction action = iconRenderer.getClickAction();
     if (e.getButton() == MouseEvent.BUTTON1 && action != null) {
       if (e.getID() == MouseEvent.MOUSE_CLICKED) {
         AnActionEvent actionEvent =
             new AnActionEvent(
                 e,
                 new LeftEditorHighlighterDataContext(myEditorComponent, iconRenderer.getNode()),
                 ICON_AREA,
                 action.getTemplatePresentation(),
                 ActionManager.getInstance(),
                 e.getModifiers());
         action.update(actionEvent);
         action.actionPerformed(actionEvent);
       }
       e.consume();
     }
   }
 }
  private AnAction createInterruptAction() {
    AnAction anAction =
        new AnAction() {
          @Override
          public void actionPerformed(final AnActionEvent e) {
            if (myPydevConsoleCommunication.isExecuting()) {
              getConsoleView().print("^C", ProcessOutputTypes.SYSTEM);
            }
            myPydevConsoleCommunication.interrupt();
          }

          @Override
          public void update(final AnActionEvent e) {
            EditorEx consoleEditor = getConsoleView().getConsole().getConsoleEditor();
            boolean enabled =
                IJSwingUtilities.hasFocus(consoleEditor.getComponent())
                    && !consoleEditor.getSelectionModel().hasSelection();
            e.getPresentation().setEnabled(enabled);
          }
        };
    anAction.registerCustomShortcutSet(
        KeyEvent.VK_C,
        InputEvent.CTRL_MASK,
        getConsoleView().getConsole().getConsoleEditor().getComponent());
    anAction.getTemplatePresentation().setVisible(false);
    return anAction;
  }
 public boolean matches(@NotNull final String name, @NotNull final String pattern) {
   final AnAction anAction = myActionManager.getAction(name);
   if (!(anAction instanceof ActionGroup)) {
     final Presentation presentation = anAction.getTemplatePresentation();
     final String text = presentation.getText();
     final String description = presentation.getDescription();
     final Pattern compiledPattern = getPattern(pattern);
     if ((text != null && myMatcher.matches(text, compiledPattern))
         || (description != null && myMatcher.matches(description, compiledPattern))) {
       return true;
     }
   }
   return false;
 }