Top Description Fields Constructors Methods
org.jabref.gui.util.uithreadaware

public Class UiThreadBinding<T>

extends Object
implements Binding<T>
Class Inheritance
All Implemented Interfaces
javafx.beans.binding.Binding, javafx.beans.value.ObservableValue, javafx.beans.Observable
Imports
javafx.beans.InvalidationListener, javafx.beans.binding.Binding, javafx.beans.value.ChangeListener, javafx.collections.ObservableList

This class can be used to wrap a Binding inside it. When wrapped, any Listener listening for updates to the wrapped Binding (for example because of a binding to it) is ensured to be notified on the JavaFX Application Thread. It should be used to implement bindings where updates come in from a background thread but should be reflected in the UI where it is necessary that changes to the UI are performed on the JavaFX Application thread.

Field Summary

Modifier and TypeField and Description
private final Binding<T>

Constructor Summary

AccessConstructor and Description
public
UiThreadBinding(Binding<T> delegate)

Method Summary

Modifier and TypeMethod and Description
public void
addListener(InvalidationListener
The listener to register
listener
)

Implements javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid.

public void
addListener(ChangeListener<? super T>
The listener to register
listener
)

Implements javafx.beans.value.ObservableValue.addListener.

Adds a ChangeListener which will be notified whenever the value of the ObservableValue changes.

public void
dispose()

Implements javafx.beans.binding.Binding.dispose.

Signals to the Binding that it will not be used anymore and any references can be removed.

public ObservableList<?>
getDependencies()

Implements javafx.beans.binding.Binding.getDependencies.

Returns the dependencies of a binding in an unmodifiable javafx.collections.ObservableList.

public T
getValue()

Implements javafx.beans.value.ObservableValue.getValue.

Returns the current value of this ObservableValue

public void
invalidate()

Implements javafx.beans.binding.Binding.invalidate.

Mark a binding as invalid.

public boolean
isValid()

Implements javafx.beans.binding.Binding.isValid.

Checks if a binding is valid.

public void
removeListener(InvalidationListener
The listener to remove
listener
)

Implements javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

public void
removeListener(ChangeListener<? super T>
The listener to remove
listener
)

Implements javafx.beans.value.ObservableValue.removeListener.

Removes the given listener from the list of listeners that are notified whenever the value of the ObservableValue changes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private final Binding<T> delegate

Constructor Detail

UiThreadBindingback to summary
public UiThreadBinding(Binding<T> delegate)

Method Detail

addListenerback to summary
public void addListener(InvalidationListener listener)

Implements javafx.beans.Observable.addListener.

Doc from javafx.beans.Observable.addListener.

Adds an InvalidationListener which will be notified whenever the Observable becomes invalid. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

Note that the same actual InvalidationListener instance may be safely registered for different Observables.

The Observable stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakInvalidationListener avoid this situation.

Parameters
listener:InvalidationListener

The listener to register

Annotations
@Override
addListenerback to summary
public void addListener(ChangeListener<? super T> listener)

Implements javafx.beans.value.ObservableValue.addListener.

Doc from javafx.beans.value.ObservableValue.addListener.

Adds a ChangeListener which will be notified whenever the value of the ObservableValue changes. If the same listener is added more than once, then it will be notified more than once. That is, no check is made to ensure uniqueness.

Note that the same actual ChangeListener instance may be safely registered for different ObservableValues.

The ObservableValue stores a strong reference to the listener which will prevent the listener from being garbage collected and may result in a memory leak. It is recommended to either unregister a listener by calling removeListener after use or to use an instance of WeakChangeListener avoid this situation.

Parameters
listener:ChangeListener<? super T>

The listener to register

Annotations
@Override
disposeback to summary
public void dispose()

Implements javafx.beans.binding.Binding.dispose.

Doc from javafx.beans.binding.Binding.dispose.

Signals to the Binding that it will not be used anymore and any references can be removed. A call of this method usually results in the binding stopping to observe its dependencies by unregistering its listener(s). The implementation is optional.

All bindings in our implementation use instances of javafx.beans.WeakInvalidationListener, which means usually a binding does not need to be disposed. But if you plan to use your application in environments that do not support WeakReferences you have to dispose unused Bindings to avoid memory leaks.

Annotations
@Override
getDependenciesback to summary
public ObservableList<?> getDependencies()

Implements javafx.beans.binding.Binding.getDependencies.

Doc from javafx.beans.binding.Binding.getDependencies.

Returns the dependencies of a binding in an unmodifiable javafx.collections.ObservableList. The implementation is optional. The main purpose of this method is to support developers during development. It allows to explore and monitor dependencies of a binding during runtime.

Because this method should not be used in production code, it is recommended to implement this functionality as sparse as possible. For example if the dependencies do not change, each call can generate a new ObservableList, avoiding the necessity to store the result.

Returns:ObservableList<?>

an unmodifiable ObservableList of the dependencies

Annotations
@Override
getValueback to summary
public T getValue()

Implements javafx.beans.value.ObservableValue.getValue.

Doc from javafx.beans.value.ObservableValue.getValue.

Returns the current value of this ObservableValue

Returns:T

The current value

Annotations
@Override
invalidateback to summary
public void invalidate()

Implements javafx.beans.binding.Binding.invalidate.

Doc from javafx.beans.binding.Binding.invalidate.

Mark a binding as invalid. This forces the recalculation of the value of the Binding next time it is request.

Annotations
@Override
isValidback to summary
public boolean isValid()

Implements javafx.beans.binding.Binding.isValid.

Doc from javafx.beans.binding.Binding.isValid.

Checks if a binding is valid.

Returns:boolean

true if the Binding is valid, false otherwise

Annotations
@Override
removeListenerback to summary
public void removeListener(InvalidationListener listener)

Implements javafx.beans.Observable.removeListener.

Doc from javafx.beans.Observable.removeListener.

Removes the given listener from the list of listeners, that are notified whenever the value of the Observable becomes invalid.

If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

Parameters
listener:InvalidationListener

The listener to remove

Annotations
@Override
removeListenerback to summary
public void removeListener(ChangeListener<? super T> listener)

Implements javafx.beans.value.ObservableValue.removeListener.

Doc from javafx.beans.value.ObservableValue.removeListener.

Removes the given listener from the list of listeners that are notified whenever the value of the ObservableValue changes.

If the given listener has not been previously registered (i.e. it was never added) then this method call is a no-op. If it had been previously added then it will be removed. If it had been added more than once, then only the first occurrence will be removed.

Parameters
listener:ChangeListener<? super T>

The listener to remove

Annotations
@Override