public class FiltersHandler extends AndFilter implements PropertyChangeListener
FiltersHandler represents a RowFilter
instance that
can be attached to a JTable
to compose dynamically the
outcome of one or more filter editors. As such, it is a dynamic filter, which
updates the table when there are changes in any of the composed sub
filters.
Users have, after version 3.2, no direct use for this class
In Java 6, a filter is automatically associated to a RowSorter
, so JTable
instances with a
TableFilter must define their own RowSorter
. Being this
not the case, the TableFilter will automatically set the default RowSorter
in that table. That is, tables with a TableFilter will
always have sorting enabled.
The RowSorter
interface does not support filtering
capabilities, which are only enabled via the DefaultRowSorter
class. If the registered table uses any sorter
that does not subclass the DefaultRowSorter
class, the
TableFilter will perform no filtering at all.
RowFilter.ComparisonType, RowFilter.Entry<M,I>
filters
Modifier and Type | Method and Description |
---|---|
void |
addFilter(IFilter... filtersToAdd)
ComposedFilter interface. |
void |
addFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
Adds a new filter editor, called from the
TableFilterHeader . |
boolean |
applyEditorFilter(Filter filter)
Applies the passed filter, from an associated editor, and, on success,
reports it to observers.
|
boolean |
consolidateFilterChanges(int modelIndex)
Method called when an editor has ended typing changes.
|
void |
enableNotifications(boolean enable)
Temporarily enable/disable notifications to the observers, including
the registered
JTable . |
void |
filterUpdated(IFilter filter)
ComposedFilter interface. |
AutoChoices |
getAutoChoices()
Returns the auto choices mode.
|
net.coderazzi.filters.gui.editor.FilterEditor |
getEditor(int column)
Returns the
FilterEditor instance on the given column. |
Collection<net.coderazzi.filters.gui.editor.FilterEditor> |
getEditors()
Returns all registered
FilterEditor s. |
IParserModel |
getParserModel()
Returns the registered
IParserModel instance. |
JTable |
getTable()
Returns the associated table.
|
boolean |
isAdaptiveChoices()
Returns the adaptive choices mode.
|
boolean |
isAutoSelection()
Returns the autoselection mode.
|
boolean |
isFilterOnUpdates()
Returns true if the filter is reapplied on updates.
|
void |
propertyChange(PropertyChangeEvent evt)
PropertyChangeListener interface, for changes on IParserModel . |
void |
removeFilter(IFilter... filtersToRemove)
ComposedFilter interface. |
void |
removeFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
Removes a filter editor, called from the
TableFilterHeader . |
void |
setAdaptiveChoices(boolean enableAdaptiveChoices)
Sets the adaptive choices mode.
|
void |
setAutoChoices(AutoChoices mode)
Sets/unsets the auto choices flag.
|
void |
setAutoSelection(boolean enable)
Sets the autoselection mode
|
void |
setEnabled(boolean enabled)
Enables/Disables the filtering.
|
void |
setFilterOnUpdates(boolean enable)
Sets the filter on updates flag.
It sets the sortOnUpdates flag on the underlying DefaultRowSorter |
void |
setParserModel(IParserModel parserModel)
Sets the
IParserModel instance. |
void |
setTable(JTable table)
Method to set the associated table.
|
void |
tableUpdated()
Report that the table is updated.
|
void |
updateEditorChoices(net.coderazzi.filters.gui.editor.FilterEditor editor)
Method invoked by the FilterEditor when its autoChoices mode OR user
choices change; in return, it will set the proper choices on the
specified editor.
|
void |
updateModel() |
void |
updateTableFilter()
Method to set/update the filtering.
|
getFilters, isDisabled
addFilterObserver, getFilterObservers, isEnabled, removeFilterObserver, reportFilterUpdatedToObservers
andFilter, dateFilter, notFilter, numberFilter, orFilter, regexFilter
public void setTable(JTable table)
RowSorter
, the default one is automatically created.public JTable getTable()
public void setParserModel(IParserModel parserModel)
IParserModel
instance.public IParserModel getParserModel()
IParserModel
instance.public void propertyChange(PropertyChangeEvent evt)
PropertyChangeListener
interface, for changes on IParserModel
.propertyChange
in interface PropertyChangeListener
public void setEnabled(boolean enabled)
setEnabled
in interface IFilter
setEnabled
in class ComposedFilter
IFilter.setEnabled(boolean)
public void setAutoChoices(AutoChoices mode)
public AutoChoices getAutoChoices()
public void setFilterOnUpdates(boolean enable)
DefaultRowSorter
public boolean isFilterOnUpdates()
public void setAdaptiveChoices(boolean enableAdaptiveChoices)
public boolean isAdaptiveChoices()
public void setAutoSelection(boolean enable)
Sets the autoselection mode
if autoSelection is true, if there is only one possible row to select on the table, it will be selected.
public boolean isAutoSelection()
setAutoSelection(boolean)
public void addFilter(IFilter... filtersToAdd)
ComposedFilter
interface.addFilter
in class ComposedFilter
public void removeFilter(IFilter... filtersToRemove)
ComposedFilter
interface.removeFilter
in class ComposedFilter
public void addFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
TableFilterHeader
.public void removeFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
TableFilterHeader
.public void updateEditorChoices(net.coderazzi.filters.gui.editor.FilterEditor editor)
public void filterUpdated(IFilter filter)
ComposedFilter
interface.filterUpdated
in interface IFilterObserver
filterUpdated
in class ComposedFilter
IFilterObserver.filterUpdated(IFilter)
public boolean applyEditorFilter(Filter filter)
public boolean consolidateFilterChanges(int modelIndex)
public void updateTableFilter()
public Collection<net.coderazzi.filters.gui.editor.FilterEditor> getEditors()
FilterEditor
s.public net.coderazzi.filters.gui.editor.FilterEditor getEditor(int column)
FilterEditor
instance on the given column.public void enableNotifications(boolean enable)
Temporarily enable/disable notifications to the observers, including
the registered JTable
.
Multiple calls to this method can be issued, but the caller must ensure that there are as many calls with true parameter as with false parameter, as the notifications are only re-enabled when the zero balance is reached.
public void tableUpdated()
public void updateModel()