com.vaadin.addon.jpacontainer.filter.util
Class AdvancedFilterableSupport

java.lang.Object
  extended by com.vaadin.addon.jpacontainer.filter.util.AdvancedFilterableSupport
All Implemented Interfaces:
AdvancedFilterable, Serializable

public class AdvancedFilterableSupport
extends Object
implements AdvancedFilterable, Serializable

Helper class that implements the filtering methods defined in AdvancedFilterable and can be either extended or used as a delegate.

Since:
1.0
Author:
Petter Holmström (Vaadin Ltd)
See Also:
Serialized Form

Nested Class Summary
static interface AdvancedFilterableSupport.ApplyFiltersListener
          ApplyFiltersListener interface to be implemented by classes that want to be notified when the filters are applied.
 
Nested classes/interfaces inherited from interface com.vaadin.addon.jpacontainer.AdvancedFilterable
AdvancedFilterable.FiltersAppliedEvent<C extends com.vaadin.data.Container & AdvancedFilterable>
 
Constructor Summary
AdvancedFilterableSupport()
           
 
Method Summary
 void addFilter(com.vaadin.data.Container.Filter filter)
           
 void addListener(AdvancedFilterableSupport.ApplyFiltersListener listener)
          Adds listener to the list of listeners to be notified when the filters are applied.
 void applyFilters()
          Applies the filters to the data, possibly causing the items in the container to change.
protected  void fireListeners()
           
 List<com.vaadin.data.Container.Filter> getAppliedFilters()
          Gets the list of filters that are currently applied.
 Collection<Object> getFilterablePropertyIds()
          Gets the IDs of all the properties that are filterable.
 List<com.vaadin.data.Container.Filter> getFilters()
          Gets the list of filters to apply.
static javax.persistence.criteria.Path<String> getPropertyPath(javax.persistence.criteria.From<?,?> root, Object propertyId)
           
static
<X,Y> javax.persistence.criteria.Path<X>
getPropertyPathTyped(javax.persistence.criteria.From<X,Y> root, Object propertyId)
           
 boolean hasUnappliedFilters()
          Checks if there are filters that have not yet been applied, or applied filters that have been removed using #removeAllFilters() or #removeFilter(com.vaadin.addon.jpacontainer.Filter) .
 boolean isApplyFiltersImmediately()
          Returns whether the filters should be applied immediately when a filter is added or removed.
 boolean isFilterable(Object propertyId)
          Checks if propertyId is filterable.
 boolean isValidFilter(com.vaadin.data.Container.Filter filter)
          Checks if filter is a valid filter, i.e.
 void removeAllFilters()
           
 void removeFilter(com.vaadin.data.Container.Filter filter)
           
 void removeListener(AdvancedFilterableSupport.ApplyFiltersListener listener)
          Removes listener from the list of listeners.
 void setApplyFiltersImmediately(boolean applyFiltersImmediately)
          Sets whether the filters should be applied immediately when a filter is added or removed.
 void setFilterablePropertyIds(Collection<?> propertyIds)
          Sets the filterable property IDs.
 void setFilterablePropertyIds(Object... propertyIds)
          Sets the filterable property IDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdvancedFilterableSupport

public AdvancedFilterableSupport()
Method Detail

addListener

public void addListener(AdvancedFilterableSupport.ApplyFiltersListener listener)
Adds listener to the list of listeners to be notified when the filters are applied. The listener will be notified as many times as it has been added.

Parameters:
listener - the listener to add (must not be null).

removeListener

public void removeListener(AdvancedFilterableSupport.ApplyFiltersListener listener)
Removes listener from the list of listeners. If the listener has been added more than once, it will be notified one less time. If the listener has not been added at all, nothing happens.

Parameters:
listener - the listener to remove (must not be null).

fireListeners

protected void fireListeners()

getFilterablePropertyIds

public Collection<Object> getFilterablePropertyIds()
Description copied from interface: AdvancedFilterable
Gets the IDs of all the properties that are filterable.

Specified by:
getFilterablePropertyIds in interface AdvancedFilterable
Returns:
an unmodifiable collection of property IDs (never null).
See Also:
AdvancedFilterable.getFilterablePropertyIds()

setFilterablePropertyIds

public void setFilterablePropertyIds(Collection<?> propertyIds)
Sets the filterable property IDs.

Parameters:
propertyIds - the property IDs to set (must not be null).

setFilterablePropertyIds

public void setFilterablePropertyIds(Object... propertyIds)
Sets the filterable property IDs.

Parameters:
propertyIds - the property IDs to set (must not be null).

isFilterable

public boolean isFilterable(Object propertyId)
Description copied from interface: AdvancedFilterable
Checks if propertyId is filterable.

Specified by:
isFilterable in interface AdvancedFilterable
Parameters:
propertyId - the property ID to check (must not be null).
Returns:
true if the property is filterable, false otherwise.
See Also:
AdvancedFilterable.isFilterable(java.lang.Object)

isValidFilter

public boolean isValidFilter(com.vaadin.data.Container.Filter filter)
Checks if filter is a valid filter, i.e. that all the properties that the filter restricts are filterable.

Parameters:
filter - the filter to check (must not be null).
Returns:
true if the filter is valid, false if it is not.

getFilters

public List<com.vaadin.data.Container.Filter> getFilters()
Description copied from interface: AdvancedFilterable
Gets the list of filters to apply. The filters will be applied as a conjunction (i.e. AND) in the order they appear in.

Specified by:
getFilters in interface AdvancedFilterable
Returns:
an unmodifiable list of filters (never null).
See Also:
AdvancedFilterable.getFilters()

getAppliedFilters

public List<com.vaadin.data.Container.Filter> getAppliedFilters()
Description copied from interface: AdvancedFilterable
Gets the list of filters that are currently applied. If AdvancedFilterable.isApplyFiltersImmediately() returns true, this list will be the same as the one returned by AdvancedFilterable.getFilters().

Specified by:
getAppliedFilters in interface AdvancedFilterable
Returns:
an unmodifiable list of filters (never null).
See Also:
AdvancedFilterable.getAppliedFilters()

setApplyFiltersImmediately

public void setApplyFiltersImmediately(boolean applyFiltersImmediately)
Description copied from interface: AdvancedFilterable
Sets whether the filters should be applied immediately when a filter is added or removed.

Specified by:
setApplyFiltersImmediately in interface AdvancedFilterable
Parameters:
applyFiltersImmediately - true to apply filters immediately, false to apply when AdvancedFilterable.applyFilters() is called.
See Also:
AdvancedFilterable.setApplyFiltersImmediately(boolean)

isApplyFiltersImmediately

public boolean isApplyFiltersImmediately()
Description copied from interface: AdvancedFilterable
Returns whether the filters should be applied immediately when a filter is added or removed. Default is true. If false, AdvancedFilterable.applyFilters() has to be called to apply the filters and update the container.

Specified by:
isApplyFiltersImmediately in interface AdvancedFilterable
Returns:
true if the filters are applied immediately, false otherwise.
See Also:
AdvancedFilterable.isApplyFiltersImmediately()

applyFilters

public void applyFilters()
Description copied from interface: AdvancedFilterable
Applies the filters to the data, possibly causing the items in the container to change.

Specified by:
applyFilters in interface AdvancedFilterable
See Also:
AdvancedFilterable.applyFilters()

hasUnappliedFilters

public boolean hasUnappliedFilters()
Description copied from interface: AdvancedFilterable
Checks if there are filters that have not yet been applied, or applied filters that have been removed using #removeAllFilters() or #removeFilter(com.vaadin.addon.jpacontainer.Filter) .

If AdvancedFilterable.isApplyFiltersImmediately() is true, this method always returns false.

Specified by:
hasUnappliedFilters in interface AdvancedFilterable
Returns:
true if there are unapplied filters, false otherwise.
See Also:
AdvancedFilterable.hasUnappliedFilters()

getPropertyPath

public static javax.persistence.criteria.Path<String> getPropertyPath(javax.persistence.criteria.From<?,?> root,
                                                                      Object propertyId)

getPropertyPathTyped

public static <X,Y> javax.persistence.criteria.Path<X> getPropertyPathTyped(javax.persistence.criteria.From<X,Y> root,
                                                                            Object propertyId)

addFilter

public void addFilter(com.vaadin.data.Container.Filter filter)
Parameters:
filter -

removeFilter

public void removeFilter(com.vaadin.data.Container.Filter filter)
Parameters:
filter -

removeAllFilters

public void removeAllFilters()


Copyright © 2013 Vaadin Ltd. All rights reserved.