Class AtPainter

  • All Implemented Interfaces:
    EventListener, org.eclipse.jface.text.IPainter, org.eclipse.swt.events.PaintListener, org.eclipse.swt.internal.SWTEventListener

    public class AtPainter
    extends Object
    implements org.eclipse.jface.text.IPainter, org.eclipse.swt.events.PaintListener
    A painter draws additional text on line near original. Painter can change additional texts
    • Color
    • Background Color
    • Selection Background Color

    User can set strategy, that processes text before showing it as additional text.

    • Field Detail

      • document

        protected org.eclipse.jface.text.IDocument document
      • textWidget

        protected org.eclipse.swt.custom.StyledText textWidget
      • color

        protected org.eclipse.swt.graphics.Color color
      • choosenLineColor

        protected org.eclipse.swt.graphics.Color choosenLineColor
      • selectedTextColor

        protected org.eclipse.swt.graphics.Color selectedTextColor
      • defaultBackgroundColor

        protected org.eclipse.swt.graphics.Color defaultBackgroundColor
      • fontSize

        protected int fontSize
      • isEnabled

        protected boolean isEnabled
    • Constructor Detail

      • AtPainter

        @Deprecated
        public AtPainter​(org.eclipse.jface.text.source.ISourceViewer viewer,
                         org.eclipse.swt.graphics.Color aditionalTextColor,
                         org.eclipse.swt.graphics.Color choosenLineColor,
                         org.eclipse.swt.graphics.Color selectedTextColor,
                         IAtLineProcessStrategy lineProcessStrategy)
        Constructor
        Parameters:
        viewer - - ISourceViewer of Editor, can't be null.
        aditionalTextColor - - Color of additional text, can't be null.
        choosenLineColor - - Color of caret line, can't be null.
        selectedTextColor - - Color of selected additional text background, can't be null.
        lineProcessStrategy - - strategy for processing lines, can't be null.
        Throws:
        IllegalArgumentException - if any of arguments are null
      • AtPainter

        public AtPainter​(org.eclipse.jface.text.source.ISourceViewer viewer,
                         org.eclipse.swt.graphics.Color aditionalTextColor,
                         org.eclipse.swt.graphics.Color choosenLineColor,
                         org.eclipse.swt.graphics.Color selectedTextColor,
                         org.eclipse.swt.graphics.Color defaultBackgroundColor,
                         IAtLineProcessStrategy lineProcessStrategy)
        Constructor
        Parameters:
        viewer - - ISourceViewer of Editor, can't be null.
        aditionalTextColor - - Color of additional text, can't be null.
        choosenLineColor - - Color of caret line, can't be null.
        selectedTextColor - - Color of selected additional text background, can't be null.
        defaultBackgroundColor - - Color of text background, can't be null.
        lineProcessStrategy - - strategy for processing lines, can't be null.
        Throws:
        IllegalArgumentException - if any of arguments are null
    • Method Detail

      • dispose

        public void dispose()
        Specified by:
        dispose in interface org.eclipse.jface.text.IPainter
      • paint

        public void paint​(int reason)
        Specified by:
        paint in interface org.eclipse.jface.text.IPainter
      • deactivate

        public void deactivate​(boolean redraw)
        Specified by:
        deactivate in interface org.eclipse.jface.text.IPainter
      • setPositionManager

        public void setPositionManager​(org.eclipse.jface.text.IPaintPositionManager manager)
        Specified by:
        setPositionManager in interface org.eclipse.jface.text.IPainter
      • paintControl

        public void paintControl​(org.eclipse.swt.events.PaintEvent e)
        Specified by:
        paintControl in interface org.eclipse.swt.events.PaintListener
      • setProcessStrategy

        public void setProcessStrategy​(IAtLineProcessStrategy strategy)
        Changes line process strategy.
        Parameters:
        strategy - - strategy to use. Can't be null.
        Throws:
        IllegalArgumentException - if strategy is null
      • setAtColor

        public void setAtColor​(org.eclipse.swt.graphics.Color color)
        Changes additional text color.
        Parameters:
        color - - color of additional text, can't be null.
        Throws:
        IllegalArgumentException - if color is null
      • setSelectedTextBackgroundColor

        public void setSelectedTextBackgroundColor​(org.eclipse.swt.graphics.Color color)
        Changes additional text selection background color. Use your eclipse text selection background color for best look.
        Parameters:
        color - - color of selected additional text background. Can't be null.
        Throws:
        IllegalArgumentException - if color is null
      • setChoosenLineColor

        public void setChoosenLineColor​(org.eclipse.swt.graphics.Color color)
        Changes chosen line color.
        Parameters:
        color - - color of chosen line. Can't be null.
        Throws:
        IllegalArgumentException - if color is null
      • setDefaultBackgroundColor

        public void setDefaultBackgroundColor​(org.eclipse.swt.graphics.Color color)
        Sets default background color.
        Parameters:
        color - - color to set. Can't be null.
      • clear

        public void clear()
        Clears current AtLineInfo Collection, i.e. deletes all additional text.
        Doesn't redraw textWidget
      • show

        public boolean show​(AtLineInfo info)
        Shows additional text at AtLineInfo's lineNumber.
        Parameters:
        info - - element to show. Can't be null
        Returns:
        true if element was added to show collection.
        Throws:
        NullPointerException - if info is null
      • show

        public boolean show​(AtLineInfo info,
                            String text)
        Shows additional text at AtLineInfo's lineNumber.
        Parameters:
        info - - element to show. Can't be null
        text - - text to show on the line, can be null
        Returns:
        true if element was added to show collection.
        Throws:
        NullPointerException - if info is null
      • unshow

        public boolean unshow​(AtLineInfo info)
        Removes additional text at AtLineInfo's lineNumber.
        Parameters:
        info - - element to remove. Can't be null.
        Returns:
        true if element was in collection.
        Throws:
        IllegalArgumentException - if info is null
      • add

        public boolean add​(AtLineInfo info,
                           String text)

        Adds element to AtLineInfo Collection.

        Additional text will appear after next textWidget's redraw

        Parameters:
        info - - LineInfo to add. Can't be null
        Returns:
        true if element was added to show collection.
        Throws:
        IllegalArgumentException - if info is null
      • addAll

        public void addAll​(Map<? extends AtLineInfo,​String> otherMap)

        Adds all elements from otherSet to AtLineInfo Collection.

        Additional text will appear after next textWidget's redraw

        Parameters:
        otherMap - - map containing elements to be added. Can't be null.
        Throws:
        IllegalArgumentException - if otherSet is null
      • remove

        public boolean remove​(AtLineInfo info)

        Removes element from AtLineInfo Collection.

        Additional text will disappear after next textWidget's redraw

        Parameters:
        info - - element to remove. Can't be null.
        Returns:
        true if element was in collection.
        Throws:
        IllegalArgumentException - if info is null
      • redraw

        public void redraw()
        Redraws AtPainter's textWidget
      • isEnabled

        public boolean isEnabled()
        Return paiter enabled state
        Returns:
        paiter enabled state
      • setEnabled

        public void setEnabled​(boolean enabled,
                               boolean redrawIfChanged)
        Sets paiter enabled state
        Parameters:
        enabled - - enabled state
        redrawIfChanged - - true, if you need to call redraw() if value changed