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 TypeMethodDescriptionbooleandoFindNext(JTextComponent target) Perform a FindNext operation on the given text component.booleandoFindPrev(JTextComponent target) FInd the previous matchvoiddoReplace(JTextComponent target, String replacement) Replace single occurrence of match with the replacement.voiddoReplaceAll(JTextComponent target, String replacement) Perform a replace all operation on the given component.static DocumentSearchDatagetFromEditor(JTextComponent target) Get the Search data from a Document.booleanisWrap()voidmsgNotFound(Component target) Display an OptionPane dialog that the search string is not foundvoidsetPattern(String pat, boolean regex, boolean ignoreCase) Sets the pattern from a string and flagsvoidsetPattern(Pattern pattern) Set the pattern to the given compiled pattern.voidsetWrap(boolean wrap) voidshowQuickFindDialog(JTextComponent target) voidshowReplaceDialog(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
-