M
- the model typeV
- the filter typepublic abstract class Filter<M,V> extends Object implements UpdateEvent.HasUpdateHandlers, ActivateEvent.HasActivateHandlers<Filter<M,?>>, DeactivateEvent.HasDeactivateHandlers<Filter<M,?>>
Grid
to reduce the
amount of information that is displayed, thus highlighting the information of interest to the user. A filter is
generally invoked from a header menu.
Derived classes provide type-specific filter support (e.g. string, number, date, boolean, etc.) and must implement
getFilterConfig()
, getValue()
and getType()
.
To add a filter to a Grid
column, create an instance of a concrete subclass of Filter
, passing to the
constructor the ValueProvider
for the column, then add the filter to a GridFilters
using
AbstractGridFilters.addFilter(Filter)
and invoke AbstractGridFilters.initPlugin(Grid)
. The filter then appears in the
grid header menu item for any column that uses the supplied value provider.Constructor and Description |
---|
Filter(ValueProvider<? super M,V> valueProvider)
Creates a filter for the specified value provider.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addActivateHandler(ActivateEvent.ActivateHandler<Filter<M,?>> handler)
Adds a
ActivateEvent handler. |
HandlerRegistration |
addDeactivateHandler(DeactivateEvent.DeactivateHandler<Filter<M,?>> handler)
Adds a
DeactivateEvent handler. |
HandlerRegistration |
addUpdateHandler(UpdateEvent.UpdateHandler handler)
Adds a
UpdateEvent.UpdateHandler handler for UpdateEvent events. |
protected FilterConfig |
createNewFilterConfig() |
protected void |
fireUpdate() |
abstract List<FilterConfig> |
getFilterConfig()
Returns a list of filter configurations.
|
FilterHandler<V> |
getHandler() |
Menu |
getMenu()
Returns the filter's menu.
|
protected abstract Class<V> |
getType() |
int |
getUpdateBuffer()
Returns the update buffer.
|
abstract Object |
getValue()
Template method to be implemented by all subclasses that is to get and return the value of the filter.
|
ValueProvider<? super M,V> |
getValueProvider()
Returns the value provider that implements the interface to the data model associated with this filter.
|
protected boolean |
isActivatable()
Template method to be implemented by all subclasses that is to return
true if the filter has enough
configuration information to be activated. |
boolean |
isActive()
Returns true if the filter is active.
|
void |
setActive(boolean active,
boolean suppressEvent)
Sets the status of the filter and fires the appropriate events.
|
void |
setFilterConfig(List<FilterConfig> configs)
Sets the filters values using the given filter configs.
|
void |
setHandler(FilterHandler<V> handler)
Sets the filter handler for this filter.
|
void |
setUpdateBuffer(int updateBuffer)
Number of milliseconds to wait after user interaction to fire an update (defaults to 500).
|
protected boolean |
validateModel(M model)
Template method to be implemented by all subclasses that is to validates the provided Model against the filters
configuration.
|
protected Menu menu
public Filter(ValueProvider<? super M,V> valueProvider)
GridFilters
, the filter appears in the
grid header menu item for any column that uses the supplied value provider.valueProvider
- the value provider that implements the interface to the data model associated with this
filter.public HandlerRegistration addActivateHandler(ActivateEvent.ActivateHandler<Filter<M,?>> handler)
ActivateEvent.HasActivateHandlers
ActivateEvent
handler.addActivateHandler
in interface ActivateEvent.HasActivateHandlers<Filter<M,?>>
handler
- the handlerpublic HandlerRegistration addDeactivateHandler(DeactivateEvent.DeactivateHandler<Filter<M,?>> handler)
DeactivateEvent.HasDeactivateHandlers
DeactivateEvent
handler.addDeactivateHandler
in interface DeactivateEvent.HasDeactivateHandlers<Filter<M,?>>
handler
- the handlerpublic HandlerRegistration addUpdateHandler(UpdateEvent.UpdateHandler handler)
UpdateEvent.HasUpdateHandlers
UpdateEvent.UpdateHandler
handler for UpdateEvent
events.addUpdateHandler
in interface UpdateEvent.HasUpdateHandlers
handler
- the handlerpublic abstract List<FilterConfig> getFilterConfig()
public void setFilterConfig(List<FilterConfig> configs)
configs
- the list of filter configurationspublic FilterHandler<V> getHandler()
public Menu getMenu()
public int getUpdateBuffer()
public abstract Object getValue()
public ValueProvider<? super M,V> getValueProvider()
public boolean isActive()
public void setActive(boolean active, boolean suppressEvent)
active
- the new filter statesuppressEvent
- true to prevent events from being firedpublic void setHandler(FilterHandler<V> handler)
String
representation of the filter and its native representation.handler
- for converting between String
and native representation of <V>
.public void setUpdateBuffer(int updateBuffer)
updateBuffer
- the update buffer in millisecondsprotected FilterConfig createNewFilterConfig()
protected void fireUpdate()
protected boolean isActivatable()
true
if the filter has enough
configuration information to be activated.protected boolean validateModel(M model)
model
- the modelCopyright © 2018. All rights reserved.