Package jsyntaxpane.actions
Class DocumentSearchData
java.lang.Object
jsyntaxpane.actions.DocumentSearchData
Data that is shared by Find / Replace and Find Next actions for a Document
The data here will be added as a property of the Document using the key
PROPERTY_KEY. Only through the getFtmEditor can you crate a new instance.
The class is responsible for handling the doFind and doReplace all actions.
The class is also responsible for displaying the Find / Replace dialog
-
Method Summary
Modifier and TypeMethodDescriptionboolean
doFindNext
(JTextComponent target) Perform a FindNext operation on the given text component.boolean
doFindPrev
(JTextComponent target) FInd the previous matchvoid
doReplace
(JTextComponent target, String replacement) Replace single occurrence of match with the replacement.void
doReplaceAll
(JTextComponent target, String replacement) Perform a replace all operation on the given component.static DocumentSearchData
getFromEditor
(JTextComponent target) Get the Search data from a Document.boolean
isWrap()
void
msgNotFound
(Component target) Display an OptionPane dialog that the search string is not foundvoid
setPattern
(String pat, boolean regex, boolean ignoreCase) Sets the pattern from a string and flagsvoid
setPattern
(Pattern pattern) Set the pattern to the given compiled pattern.void
setWrap
(boolean wrap) void
showQuickFindDialog
(JTextComponent target) void
showReplaceDialog
(JTextComponent target) Show the Find and Replace dialog for the given frame
-
Method Details
-
getPattern
-
setPattern
Set the pattern to the given compiled pattern.- Parameters:
pattern
-
-
setPattern
Sets the pattern from a string and flags- Parameters:
pat
- String of patternregex
- true if the pattern should be a regexpignoreCase
- true to ignore case- Throws:
PatternSyntaxException
-
isWrap
public boolean isWrap() -
setWrap
public void setWrap(boolean wrap) -
getFromEditor
Get the Search data from a Document. If document does not have any search data, then a new instance is added, put and reurned.- Parameters:
target
- JTextCOmponent we are attaching to- Returns:
-
doReplaceAll
Perform a replace all operation on the given component. Note that this create a new duplicate String big as the entire document and then assign it to the target text component- Parameters:
target
-replacement
-
-
doReplace
Replace single occurrence of match with the replacement.- Parameters:
target
-replacement
-
-
doFindPrev
FInd the previous match- Parameters:
target
-- Returns:
-
doFindNext
Perform a FindNext operation on the given text component. Position the caret at the start of the next found pattern.- Parameters:
target
-- Returns:
- true if pattern is found, false otherwise
-
msgNotFound
Display an OptionPane dialog that the search string is not found- Parameters:
target
-
-
showReplaceDialog
Show the Find and Replace dialog for the given frame- Parameters:
target
-
-
showQuickFindDialog
-