Package docking.widgets
Class TextComponentSearcher
java.lang.Object
docking.widgets.TextComponentSearcher
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears any active highlights.void
dispose()
Disposes this searcher.The current cursor position.getEnd()
The end cursor position.getStart()
Returns the start cursor position.boolean
void
highlightSearchResults
(SearchLocation location) Called to signal the implementor should highlight the given search location.boolean
isStale()
search
(String text, CursorPosition cursorPosition, boolean searchForward, boolean useRegex) Perform a search for the next item in the given direction starting at the given cursor position.void
setCursorPosition
(CursorPosition position) Sets the cursor position after a successful search.void
setEditorPane
(JEditorPane editorPane) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface docking.widgets.FindDialogSearcher
searchAll
-
Constructor Details
-
TextComponentSearcher
-
-
Method Details
-
setEditorPane
-
getEditorPane
-
dispose
public void dispose()Description copied from interface:FindDialogSearcher
Disposes this searcher. This does nothing by default.- Specified by:
dispose
in interfaceFindDialogSearcher
-
clearHighlights
public void clearHighlights()Description copied from interface:FindDialogSearcher
Clears any active highlights.- Specified by:
clearHighlights
in interfaceFindDialogSearcher
-
hasSearchResults
public boolean hasSearchResults() -
isStale
public boolean isStale() -
getCursorPosition
Description copied from interface:FindDialogSearcher
The current cursor position. Used to search for the next item.- Specified by:
getCursorPosition
in interfaceFindDialogSearcher
- Returns:
- the cursor position.
-
setCursorPosition
Description copied from interface:FindDialogSearcher
Sets the cursor position after a successful search.- Specified by:
setCursorPosition
in interfaceFindDialogSearcher
- Parameters:
position
- the cursor position.
-
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 interfaceFindDialogSearcher
- Returns:
- the start position.
-
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 interfaceFindDialogSearcher
- Returns:
- the end position.
-
highlightSearchResults
Description copied from interface:FindDialogSearcher
Called to signal the implementor should highlight the given search location.- Specified by:
highlightSearchResults
in interfaceFindDialogSearcher
- 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 interfaceFindDialogSearcher
- 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.
-