コード例 #1
0
  private static void setupEditorDefault(EditorEx editor) {
    ConsoleViewUtil.setupConsoleEditor(editor, false, false);
    editor.getContentComponent().setFocusCycleRoot(false);
    editor.setHorizontalScrollbarVisible(false);
    editor.setVerticalScrollbarVisible(true);
    editor.setBorder(null);

    final EditorSettings editorSettings = editor.getSettings();
    editorSettings.setAdditionalLinesCount(0);
    editorSettings.setAdditionalColumnsCount(1);
    editorSettings.setRightMarginShown(false);
  }
コード例 #2
0
  private Editor createLogEditor() {
    Project project = myProjectModel.getProject();
    final Editor editor = ConsoleViewUtil.setupConsoleEditor(project, false, false);
    myProjectModel
        .getProject()
        .getMessageBus()
        .connect()
        .subscribe(
            ProjectManager.TOPIC,
            new ProjectManagerAdapter() {
              @Override
              public void projectClosed(Project project) {
                if (project == myProjectModel.getProject()) {
                  EditorFactory.getInstance().releaseEditor(editor);
                }
              }
            });

    ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true);

    final ClearLogAction clearLog = new ClearLogAction(this);
    clearLog.registerCustomShortcutSet(
        ActionManager.getInstance().getAction(IdeActions.CONSOLE_CLEAR_ALL).getShortcutSet(),
        editor.getContentComponent());

    editor.addEditorMouseListener(
        new EditorPopupHandler() {
          public void invokePopup(final EditorMouseEvent event) {
            final ActionManager actionManager = ActionManager.getInstance();
            final ActionPopupMenu menu =
                actionManager.createActionPopupMenu(
                    ActionPlaces.EDITOR_POPUP, createPopupActions(actionManager, clearLog));
            final MouseEvent mouseEvent = event.getMouseEvent();
            menu.getComponent()
                .show(mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
          }
        });
    return editor;
  }
コード例 #3
0
    @Override
    public void mouseClicked(final EditorMouseEvent e) {
      final Editor editor = e.getEditor();
      final MouseEvent mouseEvent = e.getMouseEvent();
      if (mouseEvent.isPopupTrigger()
          || mouseEvent.isMetaDown()
          || mouseEvent.isControlDown()
          || mouseEvent.getButton() != MouseEvent.BUTTON1
          || MarkupEditorFilterFactory.createIsDiffFilter().avaliableIn(editor)
          || e.getArea() != EditorMouseEventArea.LINE_MARKERS_AREA
          || ConsoleViewUtil.isConsoleViewEditor(editor)
          || !isFromMyProject(editor)) {
        return;
      }

      PsiDocumentManager.getInstance(myProject)
          .commitAndRunReadAction(
              new Runnable() {
                @Override
                public void run() {
                  final int line = EditorUtil.yPositionToLogicalLine(editor, mouseEvent);
                  final Document document = editor.getDocument();
                  final VirtualFile file = FileDocumentManager.getInstance().getFile(document);
                  if (line >= 0 && line < document.getLineCount() && file != null) {
                    ApplicationManager.getApplication()
                        .invokeLater(
                            new Runnable() {
                              @Override
                              public void run() {
                                if (!myProject.isDisposed()
                                    && myProject.isInitialized()
                                    && file.isValid()) {
                                  ActionManagerEx.getInstanceEx()
                                      .fireBeforeActionPerformed(
                                          "ToggleLineBreakpoint", e.getMouseEvent());

                                  XLineBreakpoint breakpoint =
                                      XBreakpointUtil.toggleLineBreakpoint(
                                          myProject,
                                          file,
                                          editor,
                                          line,
                                          mouseEvent.isAltDown(),
                                          false);
                                  if (!mouseEvent.isAltDown()
                                      && mouseEvent.isShiftDown()
                                      && breakpoint != null) {
                                    breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
                                    String selection = editor.getSelectionModel().getSelectedText();
                                    if (selection != null) {
                                      breakpoint.setLogExpression(selection);
                                    } else {
                                      breakpoint.setLogMessage(true);
                                    }
                                    // edit breakpoint
                                    DebuggerUIUtil.showXBreakpointEditorBalloon(
                                        myProject,
                                        mouseEvent.getPoint(),
                                        ((EditorEx) editor).getGutterComponentEx(),
                                        false,
                                        breakpoint);
                                  }
                                }
                              }
                            });
                  }
                }
              });
    }
コード例 #4
0
 private static void setupEditor(@NotNull final EditorEx editor) {
   if (!UIUtil.isUnderDarcula()) editor.setBackgroundColor(Gray._247);
   noScrolling(editor);
   editor.getScrollPane().setBorder(null);
   ConsoleViewUtil.setupConsoleEditor(editor, false, false);
 }