|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.grid.ShrinkSearchableSupport
public abstract class ShrinkSearchableSupport
Searchable
is a class that can make JList, JTable and JComboBox searchable. However, when the data is
abundant, it is still annoying to look for a single word in hundreds of thousands of records. Hence,
ShrinkSearchableSupport
is requested, which means once you type a new letter in the searchable, the
JList, JTable and JComboBox will refresh its display based on the new string input.
ShrinkSearchableSupport
is a base abstract class. ListShrinkSearchableSupport
,
TableShrinkSearchableSupport
, ComboBoxShrinkSearchableSupport
are implementations to make
JList, JTable, JComboBox searchable to be able to shrink on searching respectively. For each implementation, there
are five methods need to be implemented.
As this is an abstract class, please refer to to javadoc of ListShrinkSearchableSupport
to
find out how to use it with JList respectively.
Last but not the least, only one Searchable is allowed on a component. If you install another one, it will remove the
first one and then install the new one.
Field Summary | |
---|---|
protected Searchable |
_searchable
|
static String |
CLIENT_PROPERTY_SHRINK_SEARCHABLE_SUPPORT
The client property for ShrinkSearchableSupport instance. |
Constructor Summary | |
---|---|
ShrinkSearchableSupport(Searchable searchable)
|
Method Summary | |
---|---|
protected abstract void |
applyFilter(String searchingText)
Update the filterable model, usually applying filter, based on the latest Searchable searching text. |
protected String |
convertElementToString(Object object)
Convert the element to string. |
protected abstract int |
getActualIndexAt(int visualIndex)
Get actual index from the visual index. |
protected abstract int |
getVisualIndexAt(int actualIndex)
Get visual index from the actual index. |
abstract 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 |
propertyChange(PropertyChangeEvent evt)
Property change listener registered for the component's model |
void |
searchableEventFired(SearchableEvent e)
Handle the SearchableEvent fired from Searchable. |
abstract void |
uninstallFilterableModel()
Uninstall the filterable model installed by installFilterableModel . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Searchable _searchable
public static final String CLIENT_PROPERTY_SHRINK_SEARCHABLE_SUPPORT
Constructor Detail |
---|
public ShrinkSearchableSupport(Searchable searchable)
Method Detail |
---|
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
evt
- the property change eventprotected boolean needReinstallFilterableModel(PropertyChangeEvent event)
return event.getNewValue() != _filterableListModel.
event
- the property change event
public void searchableEventFired(SearchableEvent e)
SEARCHABLE_CHANGE
and SEARCHABLE_END
events. In these two
case, it will invoke updateFilterModel
to shrink the model.
searchableEventFired
in interface SearchableListener
e
- the eventprotected String convertElementToString(Object object)
object
- the object to be converted
protected abstract int getActualIndexAt(int visualIndex)
applyFilter
so
that we can get the current selection information hence we are able to set the selection back after the filter is
applied.
visualIndex
- the visual index
protected abstract int getVisualIndexAt(int actualIndex)
applyFilter
so
that we can set the selection back.
actualIndex
- the actual index
public abstract void installFilterableModel()
public abstract void uninstallFilterableModel()
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.
protected abstract void applyFilter(String searchingText)
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);
}
};
searchingText
- current searching text
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |