ice.ri.common.search
Class SearchHelper

java.lang.Object
  extended byice.ri.common.search.SearchHelper
All Implemented Interfaces:
EventListener, PropertyChangeListener

public class SearchHelper
extends Object
implements PropertyChangeListener

This class provides search support for html document with or without multiple frames based on Search class, which provides Viewport based search support.

This class is compatible with Java 1.1.8 and higher and can be used with AWT based and Swing based applications. This class supports modal (modal dialog) and non-model (non-modal dialog or panel) operation.

SearchDialog in sample browser application shows how to use this class in a modal dialog. SearchPanel shows how to use this class in a non-modal form.

  1. Create a new SearchHelper object
  2. Call init() to initialize search environment
  3. Implement a SearchStatusEventListener or extend SearchStatusEventAdapter and register it to SearchHelper by calling addSearchStatusEventListener
  4. Call the property setters to set search properties.
  5. Call findNext and findPrevious to select the next and previous matches in the document, respectively.
  6. Call dispose() when no more search action is performed.

Since:
6.1
Author:
ICEsoft Technologies Inc.
See Also:
SearchStatusEventListener, SearchStatusEventAdapter, SearchPanel, ice.browser.SearchDialog, Search, Viewport

Field Summary
static int END_OF_SEARCH
          End of search indicator.
static int MATCH_FOUND
          Match found indicator.
static int NO_MATCH_FOUND
          No match found indicator.
static int RESET_ALL
          Reset all search parameters indicator.
static int RESET_HIGHLIGHT
          Reset parameter highlight indicator.
 
Constructor Summary
SearchHelper(Viewport viewport)
          Construct a new SearchHelper object.
 
Method Summary
 void addSearchStatusEventListener(SearchStatusEventListener l)
           
 void dispose()
          Removes all added SearchStatusEventListener.
 void findNext()
          Find and select next search match.
 void findPrevious()
          Find and select previous occurance of search match.
 String getSearchText()
          Retrieves search text set previously
 void init()
          Checks for child viewports and initilizes a list of (viewport, search) pair.
 boolean isCaseSensitiveEnabled()
          Test to see if case sensitive search mode has been enabled.
 boolean isHighlighed()
          Test to see if highlighted mode has been set
 boolean isSearchReady()
          Test to see if searching operation can be performed because searching operation is only allowed when browser has finished loading, parsing, and rendering.
 boolean isWordSearchEnabled()
          Test to see if whole-word searching mode has been enabled.
 void propertyChange(PropertyChangeEvent e)
           
 void removeAllSearchStatusEventListeners()
           
 void removeSearchStatusEventListener(SearchStatusEventListener l)
           
 void setCaseSensitiveEnabled(boolean b)
          Set case-sensetivity.
 void setHighlighted(boolean b)
          Highlight or de-highlight all of search matches.
 void setSearchText(String text)
          Set new search text
 void setWordSearchEnabled(boolean b)
          Sets whole-word search setting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_MATCH_FOUND

public static int NO_MATCH_FOUND
No match found indicator.


END_OF_SEARCH

public static int END_OF_SEARCH
End of search indicator.


MATCH_FOUND

public static int MATCH_FOUND
Match found indicator.


RESET_ALL

public static int RESET_ALL
Reset all search parameters indicator. It indicates all document associated with #topLevelViewport have been changed and all searching parameters except searchText have been reset. Upon receiving reset call with this indicator, SearchStatusEventListener should reset the state of widgets for enabling/disabling match case search, highlight search, and whole word search.

See Also:
SearchPanel.reset(int)

RESET_HIGHLIGHT

public static int RESET_HIGHLIGHT
Reset parameter highlight indicator. It indicates one child frame has been changed and parameter hightlight has been reset. Upon receiving reset call with this indicator, SearchStatusEventListener should reset the state of the widget for enabling/disabling highlight search.

See Also:
SearchPanel.reset(int)
Constructor Detail

SearchHelper

public SearchHelper(Viewport viewport)
Construct a new SearchHelper object. A top level viewport, which is associated with browser window, should be assigned.

Parameters:
viewport - a top level viewport
Method Detail

init

public void init()
Checks for child viewports and initilizes a list of (viewport, search) pair.


dispose

public void dispose()
Removes all added SearchStatusEventListener. Dispose of all related search object and registered This method should be called when browser window is closing.


findNext

public void findNext()
Find and select next search match.


findPrevious

public void findPrevious()
Find and select previous occurance of search match.


setHighlighted

public void setHighlighted(boolean b)
Highlight or de-highlight all of search matches.

Parameters:
b - true to highlight all search matches, false to clear all highlighted search matches.

isHighlighed

public boolean isHighlighed()
Test to see if highlighted mode has been set

Returns:
True, if highlighted mode has been set.

setCaseSensitiveEnabled

public void setCaseSensitiveEnabled(boolean b)
Set case-sensetivity. By default it is case-insensetive.

Parameters:
b - true to enabled case sensitive search.

getSearchText

public String getSearchText()
Retrieves search text set previously

Returns:
search text

isCaseSensitiveEnabled

public boolean isCaseSensitiveEnabled()
Test to see if case sensitive search mode has been enabled.

Returns:
True, if case sensitive search mode has been enabled.

setWordSearchEnabled

public void setWordSearchEnabled(boolean b)
Sets whole-word search setting. When enabled, whole-word searching limits search results to text that matches the search String, and is also surrounded by a whitespace characters.

By default the whole-word searching is disabled.

Parameters:
b - true to enable whole-word based searching, false otherwise.

isWordSearchEnabled

public boolean isWordSearchEnabled()
Test to see if whole-word searching mode has been enabled.

Returns:
true to enable whole-word searching, false otherwise.

setSearchText

public void setSearchText(String text)
Set new search text

Parameters:
text - to search for

isSearchReady

public boolean isSearchReady()
Test to see if searching operation can be performed because searching operation is only allowed when browser has finished loading, parsing, and rendering.

Returns:
true if searching operation can be performed.

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

addSearchStatusEventListener

public void addSearchStatusEventListener(SearchStatusEventListener l)

removeSearchStatusEventListener

public void removeSearchStatusEventListener(SearchStatusEventListener l)

removeAllSearchStatusEventListeners

public void removeAllSearchStatusEventListeners()