Ejemplo n.º 1
0
  public LeftEditorHighlighter(@NotNull EditorComponent editorComponent, boolean rightToLeft) {
    setBackground(BACKGROUND_COLOR);
    myEditorComponent = editorComponent;
    myRightToLeft = rightToLeft;
    addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseExited(MouseEvent e) {
            mouseExitedFoldingArea(e);
            mouseExitedIconsArea(e);
          }

          @Override
          public void mouseEntered(MouseEvent e) {
            if (isInFoldingArea(e)) {
              mouseMovedInFoldingArea(e);
            } else if (isInTextArea(e)) {
              mouseMovedInTextArea(e);
            } else {
              mouseMovedInIconsArea(e);
            }
          }
        });
    addMouseMotionListener(
        new MouseMotionAdapter() {
          @Override
          public void mouseMoved(MouseEvent e) {
            if (isInFoldingArea(e)) {
              mouseExitedIconsArea(e);
              mouseMovedInFoldingArea(e);
            } else if (isInTextArea(e)) {
              mouseExitedFoldingArea(e);
              mouseExitedIconsArea(e);
              mouseMovedInTextArea(e);
            } else {
              mouseExitedFoldingArea(e);
              mouseMovedInIconsArea(e);
            }
          }
        });
    if (MPSToolTipManager.getInstance() != null) {
      MPSToolTipManager.getInstance().registerComponent(this);
    }
    editorComponent.addRebuildListener(
        new RebuildListener() {
          @Override
          public void editorRebuilt(EditorComponent editor) {
            assert SwingUtilities.isEventDispatchThread()
                : "LeftEditorHighlighter$RebuildListener should be called in eventDispatchThread";
            for (AbstractFoldingAreaPainter painter : myFoldingAreaPainters) {
              painter.editorRebuilt();
            }
          }
        });
    myBracketsPainter = new BracketsPainter(this, myRightToLeft);
    myFoldingButtonsPainter = new FoldingButtonsPainter(this);

    myFoldingAreaPainters.add(myBracketsPainter);
    myFoldingAreaPainters.add(myFoldingButtonsPainter);
  }
Ejemplo n.º 2
0
 public void removeFoldingAreaPainter(AbstractFoldingAreaPainter painter) {
   if (!myFoldingAreaPainters.contains(painter)) {
     return;
   }
   myFoldingAreaPainters.remove(painter);
   relayout(true);
   repaint();
 }
Ejemplo n.º 3
0
 public void addFoldingAreaPainter(AbstractFoldingAreaPainter painter) {
   if (myFoldingAreaPainters.contains(painter)) {
     return;
   }
   myFoldingAreaPainters.add(painter);
   relayout(true);
   repaint();
 }
Ejemplo n.º 4
0
 private void mousePressedInFoldingArea(MouseEvent e) {
   for (Iterator<AbstractFoldingAreaPainter> it = myFoldingAreaPainters.descendingIterator();
       it.hasNext(); ) {
     AbstractFoldingAreaPainter painter = it.next();
     painter.mousePressed(e);
     if (e.isConsumed()) {
       break;
     }
   }
 }