Class ErrorStrip

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class ErrorStrip
    extends JPanel
    A component to sit alongside an RSyntaxTextArea that displays colored markers for locations of interest (parser errors, marked occurrences, etc.).

    ErrorStrips display ParserNotices from Parsers. Currently, the only way to get lines flagged in this component is to register a Parser on an RSyntaxTextArea and return ParserNotices for each line to display an icon for. The severity of each notice must be at least the threshold set by setLevelThreshold(org.fife.ui.rsyntaxtextarea.parser.ParserNotice.Level) to be displayed in this error strip. The default threshold is ParserNotice.Level.WARNING.

    An ErrorStrip can be added to a UI like so:

     textArea = createTextArea();
     textArea.addParser(new MyParser(textArea)); // Identifies lines to display
     scrollPane = new RTextScrollPane(textArea, true);
     ErrorStrip es = new ErrorStrip(textArea);
     JPanel temp = new JPanel(new BorderLayout());
     temp.add(scrollPane);
     temp.add(es, BorderLayout.LINE_END);
     
    See Also:
    Serialized Form
    • Constructor Detail

      • ErrorStrip

        public ErrorStrip​(RSyntaxTextArea textArea)
        Constructor.
        Parameters:
        textArea - The text area we are examining.
    • Method Detail

      • addNotify

        public void addNotify()
        Overridden so we only start listening for parser notices when this component (and presumably the text area) are visible.
        Overrides:
        addNotify in class JComponent
      • doLayout

        public void doLayout()
        Manually manages layout since this component uses no layout manager.
        Overrides:
        doLayout in class Container
      • getCaretMarkerColor

        public Color getCaretMarkerColor()
        returns the color to use when painting the caret marker.
        Returns:
        The caret marker color.
        See Also:
        setCaretMarkerColor(Color)
      • getFollowCaret

        public boolean getFollowCaret()
        Returns whether the caret's position should be drawn.
        Returns:
        Whether the caret's position should be drawn.
        See Also:
        setFollowCaret(boolean)
      • getShowMarkAll

        public boolean getShowMarkAll()
        Returns whether "mark all" highlights are shown in this error strip.
        Returns:
        Whether markers are shown for "mark all" highlights.
        See Also:
        setShowMarkAll(boolean)
      • getShowMarkedOccurrences

        public boolean getShowMarkedOccurrences()
        Returns whether marked occurrences are shown in this error strip.
        Returns:
        Whether marked occurrences are shown.
        See Also:
        setShowMarkedOccurrences(boolean)
      • paintComponent

        protected void paintComponent​(Graphics g)
        Overridden to (possibly) draw the caret's position.
        Overrides:
        paintComponent in class JComponent
        Parameters:
        g - The graphics context.
      • setCaretMarkerColor

        public void setCaretMarkerColor​(Color color)
        Sets the color to use when painting the caret marker.
        Parameters:
        color - The new caret marker color.
        See Also:
        getCaretMarkerColor()
      • setFollowCaret

        public void setFollowCaret​(boolean follow)
        Toggles whether the caret's current location should be drawn.
        Parameters:
        follow - Whether the caret's current location should be followed.
        See Also:
        getFollowCaret()
      • setLevelThreshold

        public void setLevelThreshold​(ParserNotice.Level level)
        Sets the minimum severity a parser notice must be for it to be displayed in this error strip. This should be one of the constants defined in the ParserNotice class. The default value is ParserNotice.Level.WARNING.
        Parameters:
        level - The new severity threshold.
        See Also:
        getLevelThreshold(), ParserNotice
      • setShowMarkAll

        public void setShowMarkAll​(boolean show)
        Sets whether "mark all" highlights are shown in this error strip.
        Parameters:
        show - Whether to show markers for "mark all" highlights.
        See Also:
        getShowMarkAll()
      • setShowMarkedOccurrences

        public void setShowMarkedOccurrences​(boolean show)
        Sets whether marked occurrences are shown in this error strip.
        Parameters:
        show - Whether to show marked occurrences.
        See Also:
        getShowMarkedOccurrences()