tornadofx / tornadofx / ItemViewModel

ItemViewModel

open class ItemViewModel<T> : ViewModel

Constructors

<init> ItemViewModel(initialValue: T? = null, itemProperty: ObjectProperty<T> = SimpleObjectProperty(initialValue))

Properties

empty val empty: BooleanBinding
isEmpty val isEmpty: Boolean
isNotEmpty val isNotEmpty: Boolean
item var item: T
itemProperty val itemProperty: ObjectProperty<T>

Inherited Properties

autocommitProperties val autocommitProperties: ObservableList<ObservableValue<out Any>>
dirty open val dirty: BooleanBinding
dirtyListListener val dirtyListListener: ListChangeListener<Any>
dirtyListener val dirtyListener: ChangeListener<Any>
dirtyProperties val dirtyProperties: ObservableList<ObservableValue<*>>
externalChangeListeners val externalChangeListeners: ObservableMap<Property<*>, ChangeListener<Any>>
ignoreDirtyStateProperties val ignoreDirtyStateProperties: ObservableList<ObservableValue<out Any>>
isDirty val isDirty: Boolean
isNotDirty val isNotDirty: Boolean
isValid val isValid: Boolean
propertyCache val propertyCache: ObservableMap<Property<*>, Property<*>>
propertyMap val propertyMap: ObservableMap<Property<*>, () -> Property<*>?>
valid val valid: ReadOnlyBooleanProperty
validationContext val validationContext: ValidationContext

Functions

asyncItem fun asyncItem(func: () -> T?): <ERROR CLASS>
bind fun <N : Any, ReturnType : Property<N>> bind(property: KProperty1<T, N?>, autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: N? = null): ReturnType
fun <N : Any, ReturnType : Property<N>> bind(property: KMutableProperty1<T, N>, autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: N? = null): ReturnType
fun <N : Any, ReturnType : Property<N>> bind(property: KMutableProperty1<T, N?>, autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: N? = null): ReturnType
fun <N : Any, PropertyType : Property<N>, ReturnType : PropertyType> bind(property: KProperty1<T, PropertyType>, autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: N? = null): ReturnType
fun <N : Any, PropertyType : Property<N>, ReturnType : PropertyType> bind(property: KMutableProperty1<T, PropertyType>, autocommit: Boolean = false, forceObjectProperty: Boolean = false): ReturnType
fun <N : Any, ReturnType : Property<N>> bind(property: KFunction<N>, autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: N? = null): ReturnType
fun <N : Any, PropertyType : Property<N>, ReturnType : PropertyType> bind(property: KFunction<PropertyType>, autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: N? = null): ReturnType
select fun <N> select(nested: (T) -> ObservableValue<N>): Property<N>

Inherited Functions

addValidator fun <T> addValidator(node: Node, property: ObservableValue<T>, trigger: ValidationTrigger = ValidationTrigger.OnChange(), validator: ValidationContext.(T?) -> ValidationMessage?): Unit
assignValue fun assignValue(facade: Property<*>, prop: Property<*>?, defaultValue: Any? = null): Unit
backingValue fun <T> backingValue(property: Property<T>): Any?

Extract the value of the corresponding source property

bind fun <PropertyType : Property<T>, T : Any, ResultType : PropertyType> bind(autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: T? = null, propertyProducer: () -> PropertyType?): ResultType

Wrap a JavaFX property and return the ViewModel facade for this property

clearDecorators fun clearDecorators(): Boolean
commit fun commit(vararg fields: ObservableValue<*>, successFn: () -> Unit = {}): Booleanfun commit(force: Boolean = false, focusFirstError: Boolean = true, vararg fields: ObservableValue<*>, successFn: () -> Unit = {}): Boolean

Perform validation and flush the values into the source object if validation passes.

dirtyStateProperty fun dirtyStateProperty(): BooleanBinding
isDirty fun <T> isDirty(property: Property<T>): Boolean
isNotDirty fun <T> isNotDirty(property: Property<T>): Boolean
markDirty fun markDirty(property: ObservableValue<*>): Unit
onCommit open fun onCommit(): Unit
open fun onCommit(commits: List<Commit>): Unit

This function is called after a successful commit, right before the optional successFn call sent to the commit call is invoked.

property fun <T : Any> property(autocommit: Boolean = false, forceObjectProperty: Boolean = false, defaultValue: T? = null, op: () -> Property<T>): PropertyDelegate<T>
rollback fun rollback(vararg fields: Property<*>): Unit

Rollback all or the specified fields

setDecorationProvider fun setDecorationProvider(decorationProvider: (ValidationMessage) -> Decorator?): Unit
valid fun valid(vararg fields: Property<*>): BooleanExpression

Create a boolean binding indicating if the given list of properties are currently valid with regards to the ValidationContext of this ViewModel.

validate fun validate(focusFirstError: Boolean = true, decorateErrors: Boolean = true, failFast: Boolean = false, vararg fields: ObservableValue<*>): Boolean

Extension Functions

bindTo fun <V : ItemViewModel<T>, T> V.bindTo(itemFragment: ItemFragment<T>): <ERROR CLASS>

Rebind the itemProperty of the ViewModel when the itemProperty in the ListCellFragment changes.

bindToItem fun <V : ItemViewModel<T>, S, T> V.bindToItem(cellFragment: TableCellFragment<S, T>): <ERROR CLASS>

Rebind the itemProperty of the ViewModel when the itemProperty in the TableCellFragment changes. TODO: Do we need this, or can we just use the one above?

bindToRowItem fun <V : ItemViewModel<S>, S, T> V.bindToRowItem(cellFragment: TableCellFragment<S, T>): <ERROR CLASS>

Rebind the rowItemProperty of the ViewModel when the itemProperty in the TableCellFragment changes.

getProperty fun <T> Any.getProperty(prop: KMutableProperty1<*, T>): ObjectProperty<T>
observable fun <T : Any> Any.observable(propName: String): ObjectProperty<T>
property fun <T> ViewModel.property(value: T? = null): PropertyDelegate<T>

Inheritors

TaskStatus open class TaskStatus : ItemViewModel<FXTask<*>>