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); }
public void addFoldingAreaPainter(AbstractFoldingAreaPainter painter) { if (myFoldingAreaPainters.contains(painter)) { return; } myFoldingAreaPainters.add(painter); relayout(true); repaint(); }