class SortedFilteredList<T> : ObservableList<T>
A wrapper for an observable list of items that can be bound to a list control like TableView, ListView etc.
The wrapper makes the data sortable and filterable. Configure a filter by setting the predicate property or by calling filterWhen to automatically update the predicate when an observable value changes.
Usage:
val table = TableView<Person>()
val data = SortedFilteredList(persons).bindTo(table)
Items can be updated by calling data.items.setAll
or data.items.addAll
at a later time.
<init> |
SortedFilteredList(items: ObservableList<T> = FXCollections.observableArrayList(), initialPredicate: (T) -> Boolean = { true }, filteredItems: FilteredList<T> = FilteredList(items, initialPredicate), sortedItems: SortedList<T> = SortedList(filteredItems))
A wrapper for an observable list of items that can be bound to a list control like TableView, ListView etc. |
filteredItems |
val filteredItems: FilteredList<T> |
items |
val items: ObservableList<T> |
predicate |
var predicate: (T) -> Boolean |
predicateProperty |
val predicateProperty: ObjectProperty<(T) -> Boolean> |
setAllPassThrough |
var setAllPassThrough: Boolean |
size |
val size: Int |
sortedItems |
val sortedItems: SortedList<T> |
add |
fun add(element: T): Boolean fun add(index: Int, element: T): Unit |
addAll |
fun addAll(index: Int, elements: Collection<T>): Boolean fun addAll(elements: Collection<T>): Boolean fun addAll(vararg elements: T): <ERROR CLASS> |
addListener |
fun addListener(listener: ListChangeListener<in T>?): Unit fun addListener(listener: InvalidationListener?): Unit |
bindTo |
fun bindTo(tableView: TableView<T>): SortedFilteredList<T>
Bind this data object to the given TableView. fun bindTo(listView: ListView<T>): SortedFilteredList<T>
Bind this data object to the given ListView. |
clear |
fun clear(): Unit |
contains |
fun contains(element: T): Boolean |
containsAll |
fun containsAll(elements: Collection<T>): Boolean |
filterWhen |
fun <Q> filterWhen(observable: ObservableValue<Q>, filterExpr: (Q, T) -> Boolean): Unit
Update the filter predicate whenever the given observable changes. The filter expression receives both the observable value and the current list item to evaluate. |
get |
fun get(index: Int): T |
indexOf |
fun indexOf(element: T): Int |
isEmpty |
fun isEmpty(): Boolean |
iterator |
fun iterator(): MutableIterator<T> |
lastIndexOf |
fun lastIndexOf(element: T): Int |
listIterator |
fun listIterator(): MutableListIterator<T> fun listIterator(index: Int): MutableListIterator<T> |
refilter |
fun refilter(): Unit
Force the filtered list to refilter its items based on the current predicate without having to configure a new predicate. Avoid reassigning the property value as that would impede binding. |
remove |
fun remove(element: T): Boolean fun remove(from: Int, to: Int): Unit |
removeAll |
fun removeAll(elements: Collection<T>): Boolean fun removeAll(vararg elements: T): <ERROR CLASS> |
removeAt |
fun removeAt(index: Int): T? |
removeListener |
fun removeListener(listener: ListChangeListener<in T>?): Unit fun removeListener(listener: InvalidationListener?): Unit |
retainAll |
fun retainAll(vararg elements: T): <ERROR CLASS> fun retainAll(elements: Collection<T>): Boolean |
set |
fun set(index: Int, element: T): T
Support editing of the sorted/filtered list. Useful to support editing support in ListView/TableView etc |
setAll |
fun setAll(col: MutableCollection<out T>?): Boolean fun setAll(vararg elements: T): Boolean |
subList |
fun subList(fromIndex: Int, toIndex: Int): MutableList<T> |
sizeProperty |
val ObservableList<*>.sizeProperty: IntegerBinding |
addClass |
fun <T : Styleable> Iterable<T>.addClass(vararg cssClass: CssRule): <ERROR CLASS>
Add the given type safe css classes to every Node in this Iterable. Pseudo classes are also supported. |
asObservable |
fun <T> List<T>.asObservable(): ObservableList<T>
Returns a new ObservableList that is backed by the original list. |
asUnmodifiable |
fun <T> ObservableList<T>.asUnmodifiable(): ObservableList<T>
Returns an unmodifiable ObservableList that wraps the original list. |
asyncItems |
fun <T> SortedFilteredList<T>.asyncItems(func: FXTask<*>.() -> Collection<T>): <ERROR CLASS> |
asyncItems |
fun <T> ObservableList<T>.asyncItems(func: FXTask<*>.() -> Collection<T>): <ERROR CLASS> |
bind |
fun <SourceType, TargetType> MutableList<TargetType>.bind(sourceList: ObservableList<SourceType>, converter: (SourceType) -> TargetType): ListConversionListener<SourceType, TargetType> fun <SourceType, TargetType> MutableList<TargetType>.bind(sourceSet: ObservableSet<SourceType>, converter: (SourceType) -> TargetType): SetConversionListener<SourceType, TargetType>
Bind this list to the given observable list by converting them into the correct type via the given converter. Changes to the observable list are synced. fun <SourceTypeKey, SourceTypeValue, TargetType> MutableList<TargetType>.bind(sourceMap: ObservableMap<SourceTypeKey, SourceTypeValue>, converter: (SourceTypeKey, SourceTypeValue) -> TargetType): MapConversionListener<SourceTypeKey, SourceTypeValue, TargetType> |
contains |
fun <T : Node> Iterable<T>.contains(cmp: UIComponent): <ERROR CLASS> |
fill |
fun <T> ObservableList<T>.fill(value: T): Unit
Fills the observable list with the provided value. Fires only one change notification on the list. |
getProperty |
fun <T> Any.getProperty(prop: KMutableProperty1<*, T>): ObjectProperty<T> |
invalidate |
fun <T> ObservableList<T>.invalidate(): Unit |
mapEach |
fun <T, R> Iterable<T>.mapEach(action: T.() -> R): <ERROR CLASS>
map with the element as receiver. |
mapEachTo |
fun <T, R, C : MutableCollection<in R>> Iterable<T>.mapEachTo(destination: C, action: T.() -> R): <ERROR CLASS>
mapTo with the element as receiver. |
move |
fun <T> MutableList<T>.move(item: T, newIndex: Int): Unit
Moves the given T item to the specified index |
moveAll |
fun <T> MutableList<T>.moveAll(newIndex: Int, predicate: (T) -> Boolean): Unit
Moves all items meeting a predicate to the given index |
moveAt |
fun <T> MutableList<T>.moveAt(oldIndex: Int, newIndex: Int): Unit
Moves the given item at the |
moveDown |
fun <T> MutableList<T>.moveDown(item: T): Boolean
Moves the given element T up the MutableList by an index increment
unless it is at the bottom already which will result in no movement.
Returns a fun <T> MutableList<T>.moveDown(predicate: (T) -> Boolean): <ERROR CLASS>
Moves first element T down an index that satisfies the given predicate, unless its already at the bottom |
moveDownAll |
fun <T> MutableList<T>.moveDownAll(predicate: (T) -> Boolean): <ERROR CLASS>
Moves all T elements down an index that satisfy the given predicate, unless they are already at the bottom |
moveDownAt |
fun <T> MutableList<T>.moveDownAt(index: Int): Unit
Moves the given element T up the MutableList by one increment unless it is at the bottom already which will result in no movement |
moveToBottomWhere |
fun <T> MutableList<T>.moveToBottomWhere(predicate: (T) -> Boolean): Unit |
moveToTopWhere |
fun <T> MutableList<T>.moveToTopWhere(predicate: (T) -> Boolean): Unit |
moveUp |
fun <T> MutableList<T>.moveUp(item: T): Boolean
Moves the given element T up the MutableList by an index increment
unless it is at the top already which will result in no movement.
Returns a fun <T> MutableList<T>.moveUp(predicate: (T) -> Boolean): <ERROR CLASS>
Moves first element T up an index that satisfies the given predicate, unless its already at the top |
moveUpAll |
fun <T> MutableList<T>.moveUpAll(predicate: (T) -> Boolean): <ERROR CLASS>
Moves all T elements up an index that satisfy the given predicate, unless they are already at the top |
moveUpAt |
fun <T> MutableList<T>.moveUpAt(index: Int): Unit
Moves the given element at specified index up the MutableList by one increment unless it is at the top already which will result in no movement |
observable |
fun <T : Any> Any.observable(propName: String): ObjectProperty<T> |
observable |
fun <T> List<T>. |
onChange |
fun <T> ObservableList<T>.onChange(op: (Change<out T>) -> Unit): <ERROR CLASS> |
removeClass |
fun <T : Styleable> Iterable<T>.removeClass(vararg cssClass: CssRule): <ERROR CLASS>
Remove the given type safe css classes from every node in this Iterable. Pseudo classes are also supported. |
reverse |
fun <T> ObservableList<T>.reverse(): Unit
Reverse the order in the observable list. Fires only one change notification on the list. |
shuffle |
fun <T> ObservableList<T>.shuffle(): Unit
Randomly shuffles elements in this observable list. Fires only one change notification on the list. fun <T> ObservableList<T>.shuffle(random: Random): Unit
Randomly shuffles elements in this observable list using the specified random instance as the source of randomness. Fires only one change notification on the list. |
sort |
fun <T : Comparable<T>> ObservableList<T>.sort(): Unit
Sorts elements in the observable list according to their natural sort order. Fires only one change notification on the list. |
sortBy |
fun <T, R : Comparable<R>> ObservableList<T>.sortBy(selector: (T) -> R?): Unit
Sorts elements in the observable list according to natural sort order of the value returned by specified selector function. Fires only one change notification on the list. |
sortByDescending |
fun <T, R : Comparable<R>> ObservableList<T>.sortByDescending(selector: (T) -> R?): Unit
Sorts elements in the observable list descending according to natural sort order of the value returned by specified selector function. Fires only one change notification on the list. |
sortWith |
fun <T> ObservableList<T>.sortWith(comparator: Comparator<in T>): Unit
Sorts elements in the observable list according to the order specified with comparator. Fires only one change notification on the list. |
swap |
fun <T> MutableList<T>.swap(indexOne: Int, indexTwo: Int): Unit
Swaps the position of two items at two respective indices fun <T> MutableList<T>.swap(itemOne: T, itemTwo: T): Unit
Swaps the index position of two items |
toJSON |
fun <T : JsonModel> Iterable<T>.toJSON(): <ERROR CLASS> |
toObservable |
fun <T> List<T>.toObservable(): ObservableList<T>
Returns a new ObservableList with the elements from the original list. |
toggleClass |
fun <T : Styleable> Iterable<T>.toggleClass(cssClass: CssRule, predicate: Boolean): <ERROR CLASS>
Toggle the given type safe css class on every node in this iterable based on the given predicate. Pseudo classes are also supported. |
withEach |
fun <T> Iterable<T>.withEach(action: T.() -> Unit): <ERROR CLASS>
forEach with the element as receiver. |