Class DocumentSearchData


  • public class DocumentSearchData
    extends java.lang.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 Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean doFindNext​(javax.swing.text.JTextComponent target)
      Perform a FindNext operation on the given text component.
      boolean doFindPrev​(javax.swing.text.JTextComponent target)
      FInd the previous match
      void doReplace​(javax.swing.text.JTextComponent target, java.lang.String replacement)
      Replace single occurrence of match with the replacement.
      void doReplaceAll​(javax.swing.text.JTextComponent target, java.lang.String replacement)
      Perform a replace all operation on the given component.
      static DocumentSearchData getFromEditor​(javax.swing.text.JTextComponent target)
      Get the Search data from a Document.
      java.util.regex.Pattern getPattern()  
      boolean isWrap()  
      void msgNotFound​(java.awt.Component target)
      Display an OptionPane dialog that the search string is not found
      void setPattern​(java.lang.String pat, boolean regex, boolean ignoreCase)
      Sets the pattern from a string and flags
      void setPattern​(java.util.regex.Pattern pattern)
      Set the pattern to the given compiled pattern.
      void setWrap​(boolean wrap)  
      void showQuickFindDialog​(javax.swing.text.JTextComponent target)  
      void showReplaceDialog​(javax.swing.text.JTextComponent target)
      Show the Find and Replace dialog for the given frame
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getPattern

        public java.util.regex.Pattern getPattern()
      • setPattern

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

        public void setPattern​(java.lang.String pat,
                               boolean regex,
                               boolean ignoreCase)
                        throws java.util.regex.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:
        java.util.regex.PatternSyntaxException
      • isWrap

        public boolean isWrap()
      • setWrap

        public void setWrap​(boolean wrap)
      • getFromEditor

        public static DocumentSearchData getFromEditor​(javax.swing.text.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​(javax.swing.text.JTextComponent target,
                                 java.lang.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​(javax.swing.text.JTextComponent target,
                              java.lang.String replacement)
        Replace single occurrence of match with the replacement.
        Parameters:
        target -
        replacement -
      • doFindPrev

        public boolean doFindPrev​(javax.swing.text.JTextComponent target)
        FInd the previous match
        Parameters:
        target -
        Returns:
      • doFindNext

        public boolean doFindNext​(javax.swing.text.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​(java.awt.Component target)
        Display an OptionPane dialog that the search string is not found
        Parameters:
        target -
      • showReplaceDialog

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

        public void showQuickFindDialog​(javax.swing.text.JTextComponent target)