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>
ATableFilter
that filters based on column valuesThis class maintains a list of
ColumnConstraintSet
objects that are logically combined to determine if the overall filter accepts the given row object. Each ColumnConstraint has an associatedLogicOperation
which 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 boolean
acceptsRow(R rowObject)
Returns true if this filter matches the given row (data)<T> void
addConstraintSet(LogicOperation logicalOp, int columnIndex, java.util.List<ColumnConstraint<T>> constraints)
Adds a new constraintSet to this ColumnBasedTableFilterColumnBasedTableFilter<R>
copy()
boolean
equals(java.lang.Object obj)
java.util.List<ColumnConstraintSet<R,?>>
getConstraintSets()
Return the list of ConstraintSets in this TableFilterjava.lang.String
getHtmlRepresentation()
Returns an HTML description of this filter.java.lang.String
getName()
Returns the name of this filter.java.lang.String
getToolTip(int columnIndex)
Return a tooltip that describes the effect of this filter for a specific filter.boolean
hasColumnFilter(int columnModelIndex)
Returns true if the there is a column filter on the column specifiedint
hashCode()
boolean
isEquivalent(ColumnBasedTableFilter<?> other)
Checks if the givenColumnBasedTableFilter
is the same as this one except for its name.boolean
isSaved()
Returns true if this filter has been saved (i.e.boolean
isSubFilterOf(TableFilter<?> tableFilter)
Returns true if this filter is a more specific version of the given filter.<T> void
restore(SaveState saveState, java.lang.Object dataSource)
Restore this filter from the given saveState.SaveState
save()
Serializes this filter into a SaveState object.void
setName(java.lang.String name)
Sets the name of this filter.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface docking.widgets.table.TableFilter
isEmpty
-
-
-
-
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:TableFilter
Returns true if this filter matches the given row (data)- Specified by:
acceptsRow
in 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:TableFilter
Returns 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:
isSubFilterOf
in 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:TableFilter
Returns true if the there is a column filter on the column specified- Specified by:
hasColumnFilter
in 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:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
isEquivalent
public boolean isEquivalent(ColumnBasedTableFilter<?> other)
Checks if the givenColumnBasedTableFilter
is 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)
-
-