com.borland.primetime.editor
Class SearchManager

java.lang.Object
  |
  +--com.borland.primetime.editor.SearchManager

public class SearchManager
extends java.lang.Object

This object stores search options and manages the search history lists. This class also contains the implementation of many of the search-related features in the editor.


Inner Class Summary
static class SearchManager.BackgroundSearchThread
           
static class SearchManager.FindAllMessage
           
static class SearchManager.RemoveMessageAction
           
static class SearchManager.SearchListener
           
static class SearchManager.SearchPathResultMessage
           
 
Field Summary
static com.borland.primetime.editor.SearchManager.SearchMessageCategory CATEGORY_SEARCH
           
 
Constructor Summary
SearchManager()
           
 
Method Summary
static void addFileFilterText(java.lang.String text)
          Add an entry to the history list used for file filters.
static void addPathText(java.lang.String text)
          Add an entry to the history list used for search paths.
static void addReplaceText(java.lang.String text)
          Add an entry to the history list used for replace text.
static void addSearchText(java.lang.String text)
          Add an entry to the history list used for search text.
static void findMatches(EditorPane editor, java.io.InputStream stream, SearchOptions opts)
          Find all of the matches of a particular string within an input stream.
static void findMatches(EditorPane editor, java.io.InputStream stream, SearchOptions opts, SearchResultsListener listener)
          Find all of the matches of a particular strings within an input stream.
static void findText(EditorPane editor, SearchOptions opts)
          Find some text in a particular editor.
static javax.swing.ComboBoxModel getFileFilterHistory()
          Get the file filter history list.
static javax.swing.ComboBoxModel getPathHistory()
          Get the path history list.
static javax.swing.ComboBoxModel getReplaceHistory()
          Get the replace history list.
static SearchOptions getSavedOptions()
          Get the most recently used set of search options.
static javax.swing.ComboBoxModel getSearchHistory()
          Get the search history list.
static void incrementalSearch(EditorPane editor, boolean forward)
          Start an incremental search.
static void repeatReplace(EditorPane editor)
          Find some text in a particular editor and replace it with different text.
static void repeatSearch(EditorPane editor)
          Repeat the previous search.
static void replaceAllText(EditorPane editor, SearchOptions opts)
          Find some text in a particular editor and replace it with different text.
static void replaceText(EditorPane editor, SearchOptions opts)
          Find some text in a particular editor and replace it with different text.
static RegularExpression.MatchResult search(char[] text, SearchOptions opts, int startOffset, int endOffset)
          Search a character array for a particular string.
static RegularExpression.MatchResult search(javax.swing.text.Document doc, SearchOptions opts, int startOffset, int endOffset)
          Search the document for a particular string.
static void searchInputStream(Browser browser, Project project, java.io.InputStream stream, Url path, SearchOptions opts, Message parentMsg)
          This methods looks for at least one instance of the search text in the stream.
static void searchPaths(Browser browser, Project project, Url[] paths, SearchOptions opts)
          Search Paths.
static void setSavedOptions(SearchOptions options)
          Set the set of search options to remember.
static void showNoMatchDialog(java.awt.Component parentComponent, java.lang.String searchText)
          Inform the user that no match was found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CATEGORY_SEARCH

public static final com.borland.primetime.editor.SearchManager.SearchMessageCategory CATEGORY_SEARCH
Constructor Detail

SearchManager

public SearchManager()
Method Detail

setSavedOptions

public static void setSavedOptions(SearchOptions options)
Set the set of search options to remember.
Parameters:
options - The SearchOptions object to store.

getSavedOptions

public static SearchOptions getSavedOptions()
Get the most recently used set of search options.
Returns:
The most recently used SearchOptions object.

addSearchText

public static void addSearchText(java.lang.String text)
Add an entry to the history list used for search text.
Parameters:
text - The most recent search text.

addReplaceText

public static void addReplaceText(java.lang.String text)
Add an entry to the history list used for replace text.
Parameters:
text - The most recent text used as a replacement string.

addPathText

public static void addPathText(java.lang.String text)
Add an entry to the history list used for search paths.
Parameters:
text - The most recent path text.

addFileFilterText

public static void addFileFilterText(java.lang.String text)
Add an entry to the history list used for file filters.
Parameters:
text - The most recent file filter text.

getSearchHistory

public static javax.swing.ComboBoxModel getSearchHistory()
Get the search history list.
Returns:
The ComboBoxModel containing the list of strings most recently searched for.

getReplaceHistory

public static javax.swing.ComboBoxModel getReplaceHistory()
Get the replace history list.
Returns:
The ComboBoxModel containing the list of strings most recently used as replacement text.

getPathHistory

public static javax.swing.ComboBoxModel getPathHistory()
Get the path history list.
Returns:
The ComboBoxModel containing the list of strings most recently used as search paths.

getFileFilterHistory

public static javax.swing.ComboBoxModel getFileFilterHistory()
Get the file filter history list.
Returns:
The ComboBoxModel containing the list of strings most recently used as file filters

search

public static RegularExpression.MatchResult search(javax.swing.text.Document doc,
                                                   SearchOptions opts,
                                                   int startOffset,
                                                   int endOffset)
Search the document for a particular string. If searching forward, returns the position within this document of the first occurrence of the specified string after the starting offset. If searching in backward, returns the position of the first occurrence of the specified string before the starting offset.
Parameters:
doc - The document to search.
startOffset - The location from which to start the search.
opts - The SearchOptions object that describes the options to use.
Returns:
A MatchResult object detailing the start and end of the searchString argument within the document; if it is not found, RegularExpress.NOMATCH is returned.

search

public static RegularExpression.MatchResult search(char[] text,
                                                   SearchOptions opts,
                                                   int startOffset,
                                                   int endOffset)
Search a character array for a particular string. If searching forward, returns the position within the array of the first occurrence of the specified string after the starting offset. If searching backward, returns the position of the first occurrence of the specified string before the starting offset.
Parameters:
text - The character array to search.
opts - The SearchOptions object that describes the options to use.
startOffset - The location from which to start the search.
endOffset - The location at which to end the search.
Returns:
A MatchResult object detailing the start and end of the searchString argument within the document; if it is not found, RegularExpress.NOMATCH is returned.

findText

public static void findText(EditorPane editor,
                            SearchOptions opts)
Find some text in a particular editor. This method will position the caret appropriately and is also responsible for notifying the user when no match is found.
Parameters:
editor - The editor containing the text to be searched.
opts - The SearchOptions object that describes the options to use.

replaceText

public static void replaceText(EditorPane editor,
                               SearchOptions opts)
Find some text in a particular editor and replace it with different text. This method will position the caret appropriately and is also responsible for prompting the user (if necessary) and notifying the user when no match is found.
Parameters:
editor - The editor containing the text to be replaced.
opts - The SearchOptions object that describes the options to use.

replaceAllText

public static void replaceAllText(EditorPane editor,
                                  SearchOptions opts)
Find some text in a particular editor and replace it with different text. Continue searching and replacing as necessary, or until the end of the document is reached. This method will position the caret appropriately and is also responsible for prompting the user (if necessary) and notifying the user if no match is found.
Parameters:
editor - The editor containing the document to be searched.
opts - The SearchOptions object that describes the options to use.

incrementalSearch

public static void incrementalSearch(EditorPane editor,
                                     boolean forward)
Start an incremental search.
Parameters:
editor - The EditorPane containing the text to be searched.

repeatSearch

public static void repeatSearch(EditorPane editor)
Repeat the previous search. This method uses the stored SearchOptions object to determine what to search for, and which options to use.
Parameters:
editor - The editor containing the text to be searched.

repeatReplace

public static void repeatReplace(EditorPane editor)
Find some text in a particular editor and replace it with different text. This method will position the caret appropriately and is also responsible for prompting the user (if necessary) and notifying the user when no match is found.
Parameters:
editor - The editor containing the text to be replaced.

findMatches

public static void findMatches(EditorPane editor,
                               java.io.InputStream stream,
                               SearchOptions opts)
Find all of the matches of a particular string within an input stream. This method creates a SearchListener to display the results in the IDE.
Parameters:
editor - the EditorPane that contains the stream being searched.
stream - The input stream to search
opts - The SearchOptions object that describes the options to use.

findMatches

public static void findMatches(EditorPane editor,
                               java.io.InputStream stream,
                               SearchOptions opts,
                               SearchResultsListener listener)
Find all of the matches of a particular strings within an input stream. This method calls the method matchFound(...) on the specified listener whenever a match is found.
Parameters:
editor - the EditorPane that contains the stream being searched.
stream - The input stream to search
opts - The SearchOptions object that describes the options to use.
listener - The SearchResultsListener to be notified when a match is found.

searchPaths

public static void searchPaths(Browser browser,
                               Project project,
                               Url[] paths,
                               SearchOptions opts)
Search Paths. This is the method that will be called by the SearchSourcePathDialog.
Parameters:
browser - The browser in which to display the search results.
project - The active project.
paths - An array of Url objects containing the base paths to search.
opts - The SearchOptions object containing the search options.
See Also:
SearchSourcePathDialog., SearchOptions

searchInputStream

public static void searchInputStream(Browser browser,
                                     Project project,
                                     java.io.InputStream stream,
                                     Url path,
                                     SearchOptions opts,
                                     Message parentMsg)
This methods looks for at least one instance of the search text in the stream. If one is found, a new SearchPathResultMessage is added to the parentMsg.
Parameters:
browser - The browser in which to display the search results.
project - The active project.
stream - The input stream to search
path - A Url object representing the directory to search.
opts - The SearchOptions object containing the search options.
parentMsg - The Message object to which new result messages should be parented.

showNoMatchDialog

public static void showNoMatchDialog(java.awt.Component parentComponent,
                                     java.lang.String searchText)
Inform the user that no match was found.
Parameters:
parentComponent - The component to use as the parent of the dialog.
searchText - The text that was being searched for.