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);
Version:
0.5
Author:
Robert Futrell
See Also:
  • Constructor Details

    • ErrorStrip

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

    • 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:
    • getFollowCaret

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

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class JComponent
    • getLevelThreshold

      public ParserNotice.Level getLevelThreshold()
      Returns the minimum severity a parser notice must be for it to be displayed in this error strip. This will be one of the constants defined in the ParserNotice class.
      Returns:
      The minimum severity.
      See Also:
    • 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:
    • getShowMarkedOccurrences

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

      public String getToolTipText(MouseEvent e)
      Overrides:
      getToolTipText in class JComponent
    • paintComponent

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

      public void removeNotify()
      Overrides:
      removeNotify in class JComponent
    • 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:
    • 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:
    • 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:
    • setMarkerToolTipProvider

      public void setMarkerToolTipProvider(ErrorStrip.ErrorStripMarkerToolTipProvider provider)
      Sets the provider of tool tips for markers in this error strip. Applications can use this method to control the content and format of the tool tip descriptions of line markers.
      Parameters:
      provider - The provider. If this is null, a default implementation will be used.
    • 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:
    • 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:
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JPanel