Class DocumentSearchData

java.lang.Object
jsyntaxpane.actions.DocumentSearchData

public class DocumentSearchData extends Object
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 Details

    • getPattern

      public Pattern getPattern()
    • setPattern

      public void setPattern(Pattern pattern)
      Set the pattern to the given compiled pattern.
      Parameters:
      pattern -
    • setPattern

      public void setPattern(String pat, boolean regex, boolean ignoreCase) throws PatternSyntaxException
      Sets the pattern from a string and flags
      Parameters:
      pat - String of pattern
      regex - true if the pattern should be a regexp
      ignoreCase - true to ignore case
      Throws:
      PatternSyntaxException
    • isWrap

      public boolean isWrap()
    • setWrap

      public void setWrap(boolean wrap)
    • getFromEditor

      public static DocumentSearchData getFromEditor(JTextComponent target)
      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

      public void doReplaceAll(JTextComponent target, String replacement)
      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

      public void doReplace(JTextComponent target, String replacement)
      Replace single occurrence of match with the replacement.
      Parameters:
      target -
      replacement -
    • doFindPrev

      public boolean doFindPrev(JTextComponent target)
      FInd the previous match
      Parameters:
      target -
      Returns:
    • doFindNext

      public boolean doFindNext(JTextComponent target)
      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

      public void msgNotFound(Component target)
      Display an OptionPane dialog that the search string is not found
      Parameters:
      target -
    • showReplaceDialog

      public void showReplaceDialog(JTextComponent target)
      Show the Find and Replace dialog for the given frame
      Parameters:
      target -
    • showQuickFindDialog

      public void showQuickFindDialog(JTextComponent target)