com.alee.extended.tree
Class AsyncTreeNodesFilter<E extends AsyncUniqueNode>

java.lang.Object
  extended by com.alee.extended.tree.AsyncTreeNodesFilter<E>
All Implemented Interfaces:
Filter<E>

public class AsyncTreeNodesFilter<E extends AsyncUniqueNode>
extends java.lang.Object
implements Filter<E>

Special smart tree filter that doesn't filter out parent nodes which has childs that are accepted by filter. This can be used in any kind of filter fields to provide a proper visual feedback in tree.

Author:
Mikle Garin

Field Summary
protected  java.util.Map<java.lang.String,java.lang.Boolean> acceptStatesCache
          Accept states by node IDs cache.
protected  boolean matchCase
          Whether should match case or not.
protected  boolean searchFromStart
          Whether should search from node text beginning or not.
protected  java.lang.String searchText
          Search request text.
protected  TextProvider<E> textProvider
          Nodes text provider.
protected  boolean useSpaceAsSeparator
          Whether should use space character as requests separator or not.
 
Constructor Summary
AsyncTreeNodesFilter()
           
 
Method Summary
 boolean accept(E node)
          Returns whether the specified object is accepted by this filter or not.
protected  boolean accept(java.lang.String nodeText, java.lang.String searchRequest, boolean searchFromStart)
          Returns whether filter accepts specified node text or not.
protected  boolean acceptIncludingChilds(E node, java.lang.String searchRequest)
          Returns whether the specified node or any of its childs match the filter or not.
protected  boolean acceptNode(E node, java.lang.String searchRequest)
          Returns whether the specified node matches the filter or not.
protected  boolean acceptNodeImpl(E node, java.lang.String searchRequest)
          Returns whether the specified node matches the filter or not.
 void clearCache()
          Clears accept states cache.
 void clearCache(E node)
          Clears specific node accept state cache.
 void clearCache(java.lang.String nodeId)
          Clears specific node accept state cache.
 java.lang.String getSearchText()
          Returns search request text.
 TextProvider<E> getTextProvider()
          Returns nodes text provider.
 boolean isMatchCase()
          Returns whether should match case or not.
 boolean isSearchFromStart()
          Returns whether should search from node text beginning or not.
 boolean isUseSpaceAsSeparator()
          Returns whether should use space character as requests separator or not.
 void setMatchCase(boolean matchCase)
          Returns whether should match case or not.
 void setSearchFromStart(boolean searchFromStart)
          Sets whether should search from node text beginning or not.
 void setSearchText(java.lang.String searchText)
          Sets search request text.
 void setTextProvider(TextProvider<E> textProvider)
          Sets nodes text provider.
 void setUseSpaceAsSeparator(boolean useSpaceAsSeparator)
          Sets whether should use space character as requests separator or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

textProvider

protected TextProvider<E extends AsyncUniqueNode> textProvider
Nodes text provider.


acceptStatesCache

protected java.util.Map<java.lang.String,java.lang.Boolean> acceptStatesCache
Accept states by node IDs cache.


matchCase

protected boolean matchCase
Whether should match case or not.


useSpaceAsSeparator

protected boolean useSpaceAsSeparator
Whether should use space character as requests separator or not.


searchFromStart

protected boolean searchFromStart
Whether should search from node text beginning or not.


searchText

protected java.lang.String searchText
Search request text.

Constructor Detail

AsyncTreeNodesFilter

public AsyncTreeNodesFilter()
Method Detail

getTextProvider

public TextProvider<E> getTextProvider()
Returns nodes text provider.

Returns:
nodes text provider

setTextProvider

public void setTextProvider(TextProvider<E> textProvider)
Sets nodes text provider. If set to null DefaultTextProvider will be used instead.

Parameters:
textProvider - new nodes text provider

isMatchCase

public boolean isMatchCase()
Returns whether should match case or not.

Returns:
true if should match case, false otherwise

setMatchCase

public void setMatchCase(boolean matchCase)
Returns whether should match case or not.

Parameters:
matchCase - whether should match case or not

isUseSpaceAsSeparator

public boolean isUseSpaceAsSeparator()
Returns whether should use space character as requests separator or not.

Returns:
true if should use space character as requests separator, false otherwise

setUseSpaceAsSeparator

public void setUseSpaceAsSeparator(boolean useSpaceAsSeparator)
Sets whether should use space character as requests separator or not.

Parameters:
useSpaceAsSeparator - whether should use space character as requests separator or not

isSearchFromStart

public boolean isSearchFromStart()
Returns whether should search from node text beginning or not.

Returns:
true if should search from node text beginning, false otherwise

setSearchFromStart

public void setSearchFromStart(boolean searchFromStart)
Sets whether should search from node text beginning or not.

Parameters:
searchFromStart - whether should search from node text beginning or not

getSearchText

public java.lang.String getSearchText()
Returns search request text.

Returns:
search request text

setSearchText

public void setSearchText(java.lang.String searchText)
Sets search request text.

Parameters:
searchText - search request text

clearCache

public void clearCache()
Clears accept states cache.


clearCache

public void clearCache(E node)
Clears specific node accept state cache.


clearCache

public void clearCache(java.lang.String nodeId)
Clears specific node accept state cache.


accept

public boolean accept(E node)
Returns whether the specified object is accepted by this filter or not.

Specified by:
accept in interface Filter<E extends AsyncUniqueNode>
Parameters:
node - object to process
Returns:
true if the specified object is accepted by this filter, false otherwise

acceptIncludingChilds

protected boolean acceptIncludingChilds(E node,
                                        java.lang.String searchRequest)
Returns whether the specified node or any of its childs match the filter or not.

Parameters:
node - node to match
searchRequest - search request text
Returns:
true if the specified node or any of its childs match the filter, false otherwise

acceptNode

protected boolean acceptNode(E node,
                             java.lang.String searchRequest)
Returns whether the specified node matches the filter or not. This method might return cached value if it exists, otherwise it will retrieve and cache a new value.

Parameters:
node - node to match
searchRequest - search request text
Returns:
true if the specified node matches the filter, false otherwise

acceptNodeImpl

protected boolean acceptNodeImpl(E node,
                                 java.lang.String searchRequest)
Returns whether the specified node matches the filter or not.

Parameters:
node - node to match
searchRequest - search request text
Returns:
true if the specified node matches the filter, false otherwise

accept

protected boolean accept(java.lang.String nodeText,
                         java.lang.String searchRequest,
                         boolean searchFromStart)
Returns whether filter accepts specified node text or not.

Parameters:
nodeText - node text
searchRequest - single search request
searchFromStart - whether should start searching from the beginning of the node text
Returns:
true if filter accepts specified node text, false otherwise