Class TextComponentSearcher

java.lang.Object
docking.widgets.TextComponentSearcher
All Implemented Interfaces:
FindDialogSearcher

public class TextComponentSearcher extends Object implements FindDialogSearcher
A class to find text matches in the given TextComponent. This class will search for all matches and cache the results for future requests when the user presses Next or Previous. All matches will be highlighted in the text component. The match containing the cursor will be a different highlight color than the others. When the find dialog is closed, all highlights are removed.
  • Constructor Details

    • TextComponentSearcher

      public TextComponentSearcher(JEditorPane editorPane)
  • Method Details

    • setEditorPane

      public void setEditorPane(JEditorPane editorPane)
    • getEditorPane

      public JEditorPane getEditorPane()
    • dispose

      public void dispose()
      Description copied from interface: FindDialogSearcher
      Disposes this searcher. This does nothing by default.
      Specified by:
      dispose in interface FindDialogSearcher
    • clearHighlights

      public void clearHighlights()
      Description copied from interface: FindDialogSearcher
      Clears any active highlights.
      Specified by:
      clearHighlights in interface FindDialogSearcher
    • hasSearchResults

      public boolean hasSearchResults()
    • isStale

      public boolean isStale()
    • getCursorPosition

      public CursorPosition getCursorPosition()
      Description copied from interface: FindDialogSearcher
      The current cursor position. Used to search for the next item.
      Specified by:
      getCursorPosition in interface FindDialogSearcher
      Returns:
      the cursor position.
    • setCursorPosition

      public void setCursorPosition(CursorPosition position)
      Description copied from interface: FindDialogSearcher
      Sets the cursor position after a successful search.
      Specified by:
      setCursorPosition in interface FindDialogSearcher
      Parameters:
      position - the cursor position.
    • getStart

      public CursorPosition getStart()
      Description copied from interface: FindDialogSearcher
      Returns the start cursor position. This is used when a search is wrapped to start at the beginning of the search range.
      Specified by:
      getStart in interface FindDialogSearcher
      Returns:
      the start position.
    • getEnd

      public CursorPosition getEnd()
      Description copied from interface: FindDialogSearcher
      The end cursor position. This is used when a search is wrapped while searching backwards to start at the end position.
      Specified by:
      getEnd in interface FindDialogSearcher
      Returns:
      the end position.
    • highlightSearchResults

      public void highlightSearchResults(SearchLocation location)
      Description copied from interface: FindDialogSearcher
      Called to signal the implementor should highlight the given search location.
      Specified by:
      highlightSearchResults in interface FindDialogSearcher
      Parameters:
      location - the search result location.
    • search

      public SearchLocation search(String text, CursorPosition cursorPosition, boolean searchForward, boolean useRegex)
      Description copied from interface: FindDialogSearcher
      Perform a search for the next item in the given direction starting at the given cursor position.
      Specified by:
      search in interface FindDialogSearcher
      Parameters:
      text - the search text.
      cursorPosition - the current cursor position.
      searchForward - true if searching forward.
      useRegex - true if the search text is a regular expression; false if the texts is literal text.
      Returns:
      the search result or null if no match was found.