gov.sns.tools.swing.patternfilter
Class PatternListFilter

java.lang.Object
  |
  +--gov.sns.tools.swing.patternfilter.PatternListFilter

public class PatternListFilter
extends java.lang.Object

PatternListFilter uses a pattern poster to filter a list of named items. As the user enters text into a text component, the list is filtered in real time. Items in the base list that match the pattern are placed into the filtered list.


Nested Class Summary
protected  class PatternListFilter.PatternChangeHandler
          PatternChangeHandler is an internal class whose instance is used to listen for pattern change events.
 
Field Summary
protected  java.util.List _baseList
           
protected  java.util.List _filteredList
           
protected  MessageCenter _messageCenter
           
protected  PatternListFilter.PatternChangeHandler _patternHandler
           
protected  PatternEventPoster _patternPoster
           
protected  ListFilterListener _proxy
           
 
Constructor Summary
PatternListFilter(java.util.List list, javax.swing.text.Document document)
          Constructor which uses the default pattern generator to construct a "contains" pattern.
PatternListFilter(java.util.List list, javax.swing.text.Document document, boolean caseSensitive)
          Constructor which uses the default pattern generator to construct a "contains" pattern.
PatternListFilter(java.util.List list, javax.swing.text.Document document, PatternGenerator patternGenerator, boolean caseSensitive)
          Constructor which uses the default pattern generator to construct a "contains" pattern.
PatternListFilter(java.util.List list, javax.swing.text.Document document, PatternGenerator patternGenerator, int patternFlags)
          Constructor which uses the default pattern generator to construct a "contains" pattern.
PatternListFilter(java.util.List list, PatternEventPoster patternPoster)
          Primary constructor
 
Method Summary
 void addListFilterListener(ListFilterListener listener)
          Add a listener of list filter events indicating that the list has been filtered and thus may have changed.
protected  void filterList(java.util.regex.Pattern pattern, boolean narrowing)
          Filter the base list based on the pattern and whether the pattern change is narrowing.
protected  void filterList(java.util.regex.Pattern pattern, java.util.List baseList)
          Filter the base list using the pattern.
 java.util.List getFilteredList()
          Get the filtered list
 void removeListFilterListener(ListFilterListener listener)
          Remove the listener from receiving list filter events.
protected  void setFilteredList(java.util.List list)
          Set the filtered list to the one specified and broadcast the filter list change event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_messageCenter

protected MessageCenter _messageCenter

_proxy

protected ListFilterListener _proxy

_patternHandler

protected PatternListFilter.PatternChangeHandler _patternHandler

_baseList

protected java.util.List _baseList

_filteredList

protected java.util.List _filteredList

_patternPoster

protected PatternEventPoster _patternPoster
Constructor Detail

PatternListFilter

public PatternListFilter(java.util.List list,
                         PatternEventPoster patternPoster)
Primary constructor

Parameters:
list - the list to filter with the pattern. This list is not modified by the filter.
patternPoster - the poster used to post pattern change events

PatternListFilter

public PatternListFilter(java.util.List list,
                         javax.swing.text.Document document,
                         boolean caseSensitive)
Constructor which uses the default pattern generator to construct a "contains" pattern. An item in the list matches if it contains the text entered into the document.

Parameters:
list - the list to filter with the pattern. This list is not modified by the filter.
document - the document used to generate the patterns used to filter the list
caseSensitive - true indicates the filter should be case sensitive and false indicates it should be case insensitive

PatternListFilter

public PatternListFilter(java.util.List list,
                         javax.swing.text.Document document)
Constructor which uses the default pattern generator to construct a "contains" pattern. An item in the list matches if it contains the text entered into the document. The pattern flags are set to 0 and thus the pattern is case sensitive.

Parameters:
list - the list to filter with the pattern. This list is not modified by the filter.
document - the document used to generate the patterns used to filter the list

PatternListFilter

public PatternListFilter(java.util.List list,
                         javax.swing.text.Document document,
                         PatternGenerator patternGenerator,
                         boolean caseSensitive)
Constructor which uses the default pattern generator to construct a "contains" pattern. An item in the list matches if it contains the text entered into the document. The pattern flags are set to 0.

Parameters:
list - the list to filter with the pattern. This list is not modified by the filter.
document - the document used to generate the patterns used to filter the list
patternGenerator - the pattern generator to use
caseSensitive - true indicates the filter should be case sensitive and false indicates it should be case insensitive

PatternListFilter

public PatternListFilter(java.util.List list,
                         javax.swing.text.Document document,
                         PatternGenerator patternGenerator,
                         int patternFlags)
Constructor which uses the default pattern generator to construct a "contains" pattern. An item in the list matches if it contains the text entered into the document. The pattern flags are set to 0.

Parameters:
list - the list to filter with the pattern. This list is not modified by the filter.
document - the document used to generate the patterns used to filter the list
patternGenerator - the pattern generator to use
patternFlags - the Pattern flags
Method Detail

addListFilterListener

public void addListFilterListener(ListFilterListener listener)
Add a listener of list filter events indicating that the list has been filtered and thus may have changed.

Parameters:
listener - The listener to receive the list filter events.

removeListFilterListener

public void removeListFilterListener(ListFilterListener listener)
Remove the listener from receiving list filter events.

Parameters:
listener - The listener to receive the list filter events.

getFilteredList

public java.util.List getFilteredList()
Get the filtered list

Returns:
the filtered list based on the present pattern.

setFilteredList

protected void setFilteredList(java.util.List list)
Set the filtered list to the one specified and broadcast the filter list change event.

Parameters:
list - the new filtered list.

filterList

protected void filterList(java.util.regex.Pattern pattern,
                          boolean narrowing)
Filter the base list based on the pattern and whether the pattern change is narrowing. If the pattern change is narrowing, the previous filter list can be used instead of the larger base list.

Parameters:
pattern - the pattern to use for filtering the list
narrowing - true indicates that the latest pattern filter is narrower than the pervious

filterList

protected void filterList(java.util.regex.Pattern pattern,
                          java.util.List baseList)
Filter the base list using the pattern. The base list is not changed, but rather items in the base list which match the pattern are placed into the filtered list.

Parameters:
pattern - the pattern used to filter items in the base list
baseList - the list of items we wish to filter