Package docking.widgets.search
Class TextComponentSearcher
java.lang.Object
docking.widgets.search.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.
If searchAll(String, boolean) is called, then the search results will not be cached, as
they are when search(String, CursorPosition, boolean, boolean) is used. The expectation
is that clients will cache the search results themselves.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected TextComponentSearchResultscreateSearchResults(Worker theWorker, JEditorPane editor, String searchText, TreeMap<Integer, TextComponentSearchLocation> matchesByPosition) voiddispose()Disposes this searcher.The current cursor position.getEnd()The end cursor position.getStart()Returns the start cursor position.booleanbooleanisBusy()booleanisStale()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.Search for all matches.voidsetEditorPane(JEditorPane editorPane)
-
Field Details
-
editorPane
-
-
Constructor Details
-
TextComponentSearcher
-
-
Method Details
-
setEditorPane
-
getEditorPane
-
isBusy
public boolean isBusy() -
dispose
public void dispose()Description copied from interface:FindDialogSearcherDisposes this searcher.- Specified by:
disposein interfaceFindDialogSearcher
-
hasSearchResults
public boolean hasSearchResults() -
isStale
public boolean isStale() -
getCursorPosition
Description copied from interface:FindDialogSearcherThe current cursor position. Used to search for the next item.- Specified by:
getCursorPositionin interfaceFindDialogSearcher- Returns:
- the cursor position.
-
getStart
Description copied from interface:FindDialogSearcherReturns the start cursor position. This is used when a search is wrapped to start at the beginning of the search range.- Specified by:
getStartin interfaceFindDialogSearcher- Returns:
- the start position.
-
getEnd
Description copied from interface:FindDialogSearcherThe end cursor position. This is used when a search is wrapped while searching backwards to start at the end position.- Specified by:
getEndin interfaceFindDialogSearcher- Returns:
- the end position.
-
searchAll
Description copied from interface:FindDialogSearcherSearch for all matches.- Specified by:
searchAllin interfaceFindDialogSearcher- Parameters:
text- the search text.useRegex- true if the search text is a regular expression; false if the text is literal.- Returns:
- all search results or an empty list.
-
search
public SearchResults search(String text, CursorPosition cursorPosition, boolean searchForward, boolean useRegex) Description copied from interface:FindDialogSearcherPerform a search for the next item in the given direction starting at the given cursor position.- Specified by:
searchin 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 text is literal.- Returns:
- the search result or null if no match was found.
-
createSearchResults
protected TextComponentSearchResults createSearchResults(Worker theWorker, JEditorPane editor, String searchText, TreeMap<Integer, TextComponentSearchLocation> matchesByPosition)
-