Class ColumnBasedTableFilter<R>
- java.lang.Object
-
- docking.widgets.table.columnfilter.ColumnBasedTableFilter<R>
-
- Type Parameters:
R- the row type of the table
- All Implemented Interfaces:
TableFilter<R>
public class ColumnBasedTableFilter<R> extends java.lang.Object implements TableFilter<R>
ATableFilterthat filters based on column valuesThis class maintains a list of
ColumnConstraintSetobjects that are logically combined to determine if the overall filter accepts the given row object. Each ColumnConstraint has an associatedLogicOperationwhich determines how its result are combined with the constraint set before it. (The first ConstraintSets LogicOperation is not used). AND operations have higher precedence than the OR operations.
-
-
Constructor Summary
Constructors Constructor Description ColumnBasedTableFilter(RowObjectTableModel<R> model)Constructs a new empty ColumnBasedTableFilter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptsRow(R rowObject)Returns true if this filter matches the given row (data)<T> voidaddConstraintSet(LogicOperation logicalOp, int columnIndex, java.util.List<ColumnConstraint<T>> constraints)Adds a new constraintSet to this ColumnBasedTableFilterColumnBasedTableFilter<R>copy()booleanequals(java.lang.Object obj)java.util.List<ColumnConstraintSet<R,?>>getConstraintSets()Return the list of ConstraintSets in this TableFilterjava.lang.StringgetHtmlRepresentation()Returns an HTML description of this filter.java.lang.StringgetName()Returns the name of this filter.java.lang.StringgetToolTip(int columnIndex)Return a tooltip that describes the effect of this filter for a specific filter.booleanhasColumnFilter(int columnModelIndex)Returns true if the there is a column filter on the column specifiedinthashCode()booleanisEquivalent(ColumnBasedTableFilter<?> other)Checks if the givenColumnBasedTableFilteris the same as this one except for its name.booleanisSaved()Returns true if this filter has been saved (i.e.booleanisSubFilterOf(TableFilter<?> tableFilter)Returns true if this filter is a more specific version of the given filter.<T> voidrestore(SaveState saveState, java.lang.Object dataSource)Restore this filter from the given saveState.SaveStatesave()Serializes this filter into a SaveState object.voidsetName(java.lang.String name)Sets the name of this filter.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ColumnBasedTableFilter
public ColumnBasedTableFilter(RowObjectTableModel<R> model)
Constructs a new empty ColumnBasedTableFilter- Parameters:
model- the table model
-
-
Method Detail
-
copy
public ColumnBasedTableFilter<R> copy()
-
acceptsRow
public boolean acceptsRow(R rowObject)
Description copied from interface:TableFilterReturns true if this filter matches the given row (data)- Specified by:
acceptsRowin interfaceTableFilter<R>- Parameters:
rowObject- the current row object- Returns:
- true if the element at the given row matches this filter.
-
getName
public java.lang.String getName()
Returns the name of this filter.Names are used for saving filters, so unless they are saved they typically don't have a name.
- Returns:
- the name of this filter.
-
setName
public void setName(java.lang.String name)
Sets the name of this filter.- Parameters:
name- the new name for this filter.
-
addConstraintSet
public <T> void addConstraintSet(LogicOperation logicalOp, int columnIndex, java.util.List<ColumnConstraint<T>> constraints)
Adds a new constraintSet to this ColumnBasedTableFilter- Parameters:
logicalOp- The logic operation (AND or OR) for how the new ConstraintSet's result will be combined with the previous ConstraintSet's result.columnIndex- the model index of the column whose values must past the given constraint filters.constraints- a list of ColumnConstraints where at least one must pass for the constraintSet to pass.
-
isSubFilterOf
public boolean isSubFilterOf(TableFilter<?> tableFilter)
Description copied from interface:TableFilterReturns true if this filter is a more specific version of the given filter.For example, if this filter is a 'starts with' text filter, with the value of 'bobo', then if the given filter is also a 'starts with' filter, with a value of 'bob', then this filter is considered a sub-filter of the given sub-filter.
- Specified by:
isSubFilterOfin interfaceTableFilter<R>- Parameters:
tableFilter- the filter to check- Returns:
- true if this filter is a sub-filter of the given filter
-
hasColumnFilter
public boolean hasColumnFilter(int columnModelIndex)
Description copied from interface:TableFilterReturns true if the there is a column filter on the column specified- Specified by:
hasColumnFilterin interfaceTableFilter<R>- Parameters:
columnModelIndex- the model index of the column to test for column filters.- Returns:
- true if the there is a column filter on the column specified.
-
getConstraintSets
public java.util.List<ColumnConstraintSet<R,?>> getConstraintSets()
Return the list of ConstraintSets in this TableFilter- Returns:
- the list of ConstraintSets in this TableFilter
-
save
public SaveState save()
Serializes this filter into a SaveState object.- Returns:
- the SaveState serialized version of this filter.
-
restore
public <T> void restore(SaveState saveState, java.lang.Object dataSource)
Restore this filter from the given saveState.- Parameters:
saveState- that contains the serialized filter datadataSource- the Table's DataSource which some objects might need to restore themselves.
-
getHtmlRepresentation
public java.lang.String getHtmlRepresentation()
Returns an HTML description of this filter.Note: the HTML string returned does NOT start with the HTML tag so that it can be combined with other text.
- Returns:
- an HTML description of this filter.
-
getToolTip
public java.lang.String getToolTip(int columnIndex)
Return a tooltip that describes the effect of this filter for a specific filter.- Parameters:
columnIndex- the model index of the column to get a filter description of.- Returns:
- a tooltip that describes this filter for a specific column.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
isEquivalent
public boolean isEquivalent(ColumnBasedTableFilter<?> other)
Checks if the givenColumnBasedTableFilteris the same as this one except for its name.- Parameters:
other- the other filter to check for equivalence.- Returns:
- true if the other filter is the same as this one except for its name
-
isSaved
public boolean isSaved()
Returns true if this filter has been saved (i.e. has a name)- Returns:
- true if this filter has been saved (i.e. has a name)
-
-