JIDE 3.5.15

com.jidesoft.tree
Class TreeShrinkSearchableSupport

java.lang.Object
  extended by com.jidesoft.grid.ShrinkSearchableSupport
      extended by com.jidesoft.tree.TreeShrinkSearchableSupport
All Implemented Interfaces:
SearchableListener, PropertyChangeListener, EventListener

public class TreeShrinkSearchableSupport
extends ShrinkSearchableSupport

TreeShrinkSearchableSupport is a subclass of ShrinkSearchableSupport to make TreeSearchable shrinkable while searching.


Field Summary
 
Fields inherited from class com.jidesoft.grid.ShrinkSearchableSupport
_searchable, CLIENT_PROPERTY_SHRINK_SEARCHABLE_SUPPORT
 
Constructor Summary
TreeShrinkSearchableSupport(Searchable searchable)
           
 
Method Summary
protected  void applyFilter(String searchingText)
          Update the filterable model, usually applying filter, based on the latest Searchable searching text.
protected  int getActualIndexAt(int viewIndex)
          Get actual index from the visual index.
protected  int getVisualIndexAt(int actualIndex)
          Get visual index from the actual index.
 void installFilterableModel()
          Install a filterable model for the component where Searchable installed in.
protected  boolean needReinstallFilterableModel(PropertyChangeEvent event)
          Checks if the filterable model should be reinstalled if the model is changed.
 void uninstallFilterableModel()
          Uninstall the filterable model installed by installFilterableModel.
 
Methods inherited from class com.jidesoft.grid.ShrinkSearchableSupport
convertElementToString, propertyChange, searchableEventFired
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeShrinkSearchableSupport

public TreeShrinkSearchableSupport(Searchable searchable)
Method Detail

needReinstallFilterableModel

protected boolean needReinstallFilterableModel(PropertyChangeEvent event)
Description copied from class: ShrinkSearchableSupport
Checks if the filterable model should be reinstalled if the model is changed.

To keep the backward compatibility, it returns false by default.

To avoid potential infinite loop, the recommended implementation for this method is

 return event.getNewValue() != _filterableListModel.
 

Overrides:
needReinstallFilterableModel in class ShrinkSearchableSupport
Parameters:
event - the property change event
Returns:
true if a new filterable model should be installed. Otherwise false.

installFilterableModel

public void installFilterableModel()
Description copied from class: ShrinkSearchableSupport
Install a filterable model for the component where Searchable installed in.

Specified by:
installFilterableModel in class ShrinkSearchableSupport

uninstallFilterableModel

public void uninstallFilterableModel()
Description copied from class: ShrinkSearchableSupport
Uninstall the filterable model installed by installFilterableModel.

If you are extending this class to create your customized ShrinkSearchableSupport class, please make sure you will invoke _searchable.getComponent().removePropertyChangeListener("model", this); to remove the property change listener. Otherwise the filterable model may not be removed.

Specified by:
uninstallFilterableModel in class ShrinkSearchableSupport

applyFilter

protected void applyFilter(String searchingText)
Description copied from class: ShrinkSearchableSupport
Update the filterable model, usually applying filter, based on the latest Searchable searching text.

If you want to override this method, please be noted that you probably need make your filter#convertElementToString to invoke ShrinkSearchableSupport.convertElementToString(Object). Below is one sample implementation while creating the filter.

 WildcardFilter wildcardFilter = new WildcardFilter(searchingText) {
     protected String convertElementToString(Object value) {
         String stringValue = TableShrinkSearchableSupport.this.convertElementToString(value);
         return stringValue != null ? stringValue : super.convertElementToString(value);
     }
 };
 

Specified by:
applyFilter in class ShrinkSearchableSupport
Parameters:
searchingText - current searching text

getActualIndexAt

protected int getActualIndexAt(int viewIndex)
Description copied from class: ShrinkSearchableSupport
Get actual index from the visual index. This method will be invoked before we invoke applyFilter so that we can get the current selection information hence we are able to set the selection back after the filter is applied.

Specified by:
getActualIndexAt in class ShrinkSearchableSupport
Parameters:
viewIndex - the visual index
Returns:
the actual index

getVisualIndexAt

protected int getVisualIndexAt(int actualIndex)
Description copied from class: ShrinkSearchableSupport
Get visual index from the actual index. This method will be invoked after we invoke applyFilter so that we can set the selection back.

Specified by:
getVisualIndexAt in class ShrinkSearchableSupport
Parameters:
actualIndex - the actual index
Returns:
the visual index

JIDE 3.5.15