net.coderazzi.filters.gui
Class FiltersHandler

java.lang.Object
  extended by javax.swing.RowFilter
      extended by net.coderazzi.filters.Filter
          extended by net.coderazzi.filters.ComposedFilter
              extended by net.coderazzi.filters.AndFilter
                  extended by net.coderazzi.filters.gui.FiltersHandler
All Implemented Interfaces:
PropertyChangeListener, EventListener, IFilter, IFilterObserver

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.

Author:
Luis M Pena - lu@coderazzi.net

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.RowFilter
RowFilter.ComparisonType, RowFilter.Entry<M,I>
 
Field Summary
 
Fields inherited from class net.coderazzi.filters.ComposedFilter
filters
 
Method Summary
 void addFilter(IFilter... filtersToAdd)
          Subscribes one or more IFilter instances to receive filter events from this composition filter.
 void addFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
          Adds a new filter editor.
 void enableNotifications(boolean enable)
          Temporarily enable/disable notifications to the observers, including the registered JTable.
 void filterUpdated(IFilter filter)
          Notification made by the observer when the associated IFilter instance updates the held filter.
 AutoChoices getAutoChoices()
          Returns the auto choices mode.
 net.coderazzi.filters.gui.editor.FilterEditor getEditor(int column)
           
 Collection<net.coderazzi.filters.gui.editor.FilterEditor> getEditors()
           
 IParserModel getParserModel()
           
 JTable getTable()
          Returns the associated table.
 boolean isAdaptiveChoices()
          Returns the adaptive choices mode.
 boolean isAutoSelection()
          Returns the autoselection mode.
 void propertyChange(PropertyChangeEvent evt)
          PropertyChangeListener interface, for changes on IParserModel.
 void removeFilter(IFilter... filtersToRemove)
          Unsubscribes one or more IFilters that were previously subscribed to receive filter events.
 void removeFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
          Removes an existing editor.
 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 setParserModel(IParserModel parserModel)
           
 void setTable(JTable table)
          Method to set the associated table.
 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 updateTableFilter()
          Method to set/update the filtering.
 
Methods inherited from class net.coderazzi.filters.AndFilter
include
 
Methods inherited from class net.coderazzi.filters.ComposedFilter
getFilters, isDisabled
 
Methods inherited from class net.coderazzi.filters.Filter
addFilterObserver, getFilterObservers, isEnabled, removeFilterObserver, reportFilterUpdatedToObservers
 
Methods inherited from class javax.swing.RowFilter
andFilter, dateFilter, notFilter, numberFilter, orFilter, regexFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setTable

public void setTable(JTable table)
Method to set the associated table. If the table had not defined its own RowSorter, the default one is automatically created.


getTable

public JTable getTable()
Returns the associated table.


setParserModel

public void setParserModel(IParserModel parserModel)

getParserModel

public IParserModel getParserModel()

propertyChange

public void propertyChange(PropertyChangeEvent evt)
PropertyChangeListener interface, for changes on IParserModel.

Specified by:
propertyChange in interface PropertyChangeListener

setEnabled

public void setEnabled(boolean enabled)
Enables/Disables the filtering.

Specified by:
setEnabled in interface IFilter
Overrides:
setEnabled in class ComposedFilter
See Also:
IFilter.setEnabled(boolean)

setAutoChoices

public void setAutoChoices(AutoChoices mode)
Sets/unsets the auto choices flag.


getAutoChoices

public AutoChoices getAutoChoices()
Returns the auto choices mode.


setAdaptiveChoices

public void setAdaptiveChoices(boolean enableAdaptiveChoices)
Sets the adaptive choices mode.


isAdaptiveChoices

public boolean isAdaptiveChoices()
Returns the adaptive choices mode.


setAutoSelection

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.


isAutoSelection

public boolean isAutoSelection()
Returns the autoselection mode.

See Also:
setAutoSelection(boolean)

addFilter

public void addFilter(IFilter... filtersToAdd)
Description copied from class: ComposedFilter
Subscribes one or more IFilter instances to receive filter events from this composition filter.

Overrides:
addFilter in class ComposedFilter

removeFilter

public void removeFilter(IFilter... filtersToRemove)
Description copied from class: ComposedFilter
Unsubscribes one or more IFilters that were previously subscribed to receive filter events.

Overrides:
removeFilter in class ComposedFilter

addFilterEditor

public void addFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
Adds a new filter editor.


removeFilterEditor

public void removeFilterEditor(net.coderazzi.filters.gui.editor.FilterEditor editor)
Removes an existing editor.


updateEditorChoices

public 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.


filterUpdated

public void filterUpdated(IFilter filter)
Description copied from interface: IFilterObserver

Notification made by the observer when the associated IFilter instance updates the held filter.

Specified by:
filterUpdated in interface IFilterObserver
Overrides:
filterUpdated in class ComposedFilter
See Also:
IFilterObserver.filterUpdated(IFilter)

updateTableFilter

public void updateTableFilter()
Method to set/update the filtering.


getEditors

public Collection<net.coderazzi.filters.gui.editor.FilterEditor> getEditors()

getEditor

public net.coderazzi.filters.gui.editor.FilterEditor getEditor(int column)

enableNotifications

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.



Copyright © 2011 coderazzi. All Rights Reserved.