|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.AbstractListModel com.jidesoft.combobox.DefaultComboBoxModelWrapper com.jidesoft.combobox.FilterableComboBoxModel
public class FilterableComboBoxModel
FilterableComboBoxModel
is a list model which wraps another list model so that user can apply filters on
it.
addFilter(Filter)
to a filter to the ComboBoxModel. By default, filters won't take effect
immediately. You need to call setFiltersApplied(true)
to apply those filters. If
filtersApplied
flag is true already, you just need to call refresh(). We don't refresh automatically
because you might have several filters to add. You can add all of them, then only call refresh once.
setFiltersApplied(boolean)
controls all the filters. Each filter has its own enabled flag which will
control each individual filter.
By default, if you have more than one filters, all filters will be used in AND mode. You can see javadoc of setAndMode(boolean)
to find more information.
Field Summary | |
---|---|
protected List<Filter> |
_filters
The data structure contains all the filters. |
protected boolean |
_filtersApplied
A flag to turn on/off filters. |
Fields inherited from class com.jidesoft.combobox.DefaultComboBoxModelWrapper |
---|
_indexes, _model |
Fields inherited from class javax.swing.AbstractListModel |
---|
listenerList |
Constructor Summary | |
---|---|
FilterableComboBoxModel()
|
|
FilterableComboBoxModel(ComboBoxModel model)
Creates a FilterableComboBoxModel from any table model. |
Method Summary | |
---|---|
void |
addFilter(Filter filter)
Adds a filter to the list model. |
void |
addFilters(List<Filter> filters)
Adds a list of filters to the list model. |
void |
clearFilters()
Removes all filters of this list model. |
void |
contentsChanged(ListDataEvent e)
The event handler when items are updated in the underlying combo box model. |
Filter[] |
getFilters()
Gets all filters. |
void |
intervalAdded(ListDataEvent e)
The event handler when new items are added in the underlying combo box model. |
void |
intervalRemoved(ListDataEvent e)
The event handler when items are removed in the underlying combo box model. |
boolean |
isAndMode()
Sets the logic of filters on the list model. |
boolean |
isFiltersApplied()
Checks if the filters are in effect. |
boolean |
isReselectItemOnFiltering()
Gets the flag indicating if FilterableComboBoxModel will try to reselect item if the current selected item is filtered away after filtering. |
void |
refresh()
Reapply all filters after they are changed. |
void |
removeFilter(Filter filter)
Removes the filter from the list model. |
void |
setActualModel(ComboBoxModel model)
Sets the actual list model. |
void |
setAndMode(boolean andMode)
Sets the logic of the filters on the same column. |
void |
setFiltersApplied(boolean apply)
Applies or unapplies the filters. |
void |
setReselectItemOnFiltering(boolean reselectItemOnFiltering)
Sets the flag indicating if FilterableComboBoxModel will try to reselect item if the current selected item is filtered away after filtering. |
protected boolean |
shouldBeFiltered(int row,
List<Filter> filters)
The method contains the algorithm to filter the specified row. |
Methods inherited from class com.jidesoft.combobox.DefaultComboBoxModelWrapper |
---|
getActualIndexAt, getActualModel, getElementAt, getIndexAt, getIndexes, getSelectedItem, getSize, reallocateIndexes, setIndexes, setSelectedItem |
Methods inherited from class javax.swing.AbstractListModel |
---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.swing.ListModel |
---|
addListDataListener, removeListDataListener |
Field Detail |
---|
protected List<Filter> _filters
protected boolean _filtersApplied
setFiltersApplied(boolean)
with true will turn it on and setFiltersApplied(boolean)
with false will turn it off.
Constructor Detail |
---|
public FilterableComboBoxModel()
public FilterableComboBoxModel(ComboBoxModel model)
model
- the combobox model.Method Detail |
---|
public void setActualModel(ComboBoxModel model)
DefaultComboBoxModelWrapper
setActualModel
in interface ComboBoxModelWrapper
setActualModel
in class DefaultComboBoxModelWrapper
model
- the list model.public void intervalAdded(ListDataEvent e)
DefaultComboBoxModelWrapper
intervalAdded
in interface ListDataListener
intervalAdded
in class DefaultComboBoxModelWrapper
e
- the eventpublic void intervalRemoved(ListDataEvent e)
DefaultComboBoxModelWrapper
intervalRemoved
in interface ListDataListener
intervalRemoved
in class DefaultComboBoxModelWrapper
e
- the eventpublic void contentsChanged(ListDataEvent e)
DefaultComboBoxModelWrapper
contentsChanged
in interface ListDataListener
contentsChanged
in class DefaultComboBoxModelWrapper
e
- the eventpublic void refresh()
protected boolean shouldBeFiltered(int row, List<Filter> filters)
row
- the row indexfilters
- The list of filters
public void addFilters(List<Filter> filters)
filters
- the list of Filters.public void addFilter(Filter filter)
You can use AbstractFilter
to create new filter.
If you need the row index in order to decide if the value should be filtered, you can use AbstractListFilter
and use getRowIndex() to find out current row index.
filter
- the Filter to be added.public void removeFilter(Filter filter)
filter
- the Filter to be removed.public void clearFilters()
public Filter[] getFilters()
public void setFiltersApplied(boolean apply)
apply
- true to apply the filters.public boolean isFiltersApplied()
public boolean isAndMode()
public void setAndMode(boolean andMode)
andMode
- true or false.public boolean isReselectItemOnFiltering()
setReselectItemOnFiltering(boolean)
public void setReselectItemOnFiltering(boolean reselectItemOnFiltering)
reselectItemOnFiltering
- the flag
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |