Top Description Inners Constructors Methods
org.jabref.gui.util

public Class BindingsHelper

extends Object
Class Inheritance
Imports
java.util.List, .Map, java.util.function.Consumer, .Function, javafx.beans.binding.BooleanBinding, .ObjectBinding, .StringBinding, javafx.beans.property.ListProperty, .Property, javafx.beans.value.ChangeListener, .ObservableValue, javafx.collections.FXCollections, .ListChangeListener, .MapChangeListener, .ObservableList, .ObservableMap, javafx.css.PseudoClass, javafx.scene.Node, com.tobiasdiez.easybind.EasyBind, com.tobiasdiez.easybind.PreboundBinding, com.tobiasdiez.easybind.Subscription

Helper methods for javafx binding. Some methods are taken from https://bugs.openjdk.java.net/browse/JDK-8134679

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <A, B> void
bindBidirectional(Property<A> propertyA, Property<B> propertyB, Function<A, B> mapAtoB, Function<B, A> mapBtoA)

Binds propertyA bidirectional to propertyB using the provided map functions to convert between them.

public static <A> void
bindBidirectional(Property<A> propertyA, ObservableValue<A> propertyB, Consumer<A> updateB)

Binds propertyA bidirectional to propertyB while using updateB to update propertyB when propertyA changed.

public static <A, B> void
bindBidirectional(ObservableValue<A> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<A> updateB)

Binds propertyA bidirectional to propertyB using updateB to update propertyB when propertyA changed and similar for updateA.

public static <A, B> void
bindContentBidirectional(ObservableList<A> propertyA, ListProperty<B> propertyB, Consumer<ObservableList<B>> updateA, Consumer<List<A>> updateB)

public static <A, B> void
bindContentBidirectional(ObservableList<A> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<List<A>> updateB)

public static <A, B> void
bindContentBidirectional(ListProperty<A> listProperty, Property<B> property, Function<List<A>, B> mapToB, Function<B, List<A>> mapToList)

public static <A, V, B> void
bindContentBidirectional(ObservableMap<A, V> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<Map<A, V>> updateB)

public static <A, V, B> void
bindContentBidirectional(ObservableMap<A, V> propertyA, Property<B> propertyB, Consumer<B> updateA, Function<Map<A, V>, B> mapToB)

public static <T> ObservableValue<T>
constantOf(T value)

public static ObservableValue<Boolean>
constantOf(boolean value)

public static ObservableValue<? extends String>
public static <T> ObservableList<T>
forUI(ObservableList<T> list)

Returns a wrapper around the given list that posts changes on the JavaFX thread.

public static <T> ObservableValue<T>
ifThenElse(ObservableValue<Boolean> condition, T value, T other)

public static com.tobiasdiez.easybind.Subscription
includePseudoClassWhen(Node node, PseudoClass pseudoClass, ObservableValue<? extends Boolean> condition)

public static <T, U> ObservableList<U>
map(ObservableValue<T> source, Function<T, List<U>> mapper)

public static <T> com.tobiasdiez.easybind.Subscription

Returns:

a subscription that can be used to stop invoking subscriber for any further observable changes.
subscribeFuture
(ObservableValue<T>
observable value to subscribe to
observable
,
Consumer<? super T>
action to invoke for values of observable.
subscriber
)

Invokes subscriber for the every new value of observable, but not for the current value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BindingsHelperback to summary
private BindingsHelper()

Method Detail

bindBidirectionalback to summary
public static <A, B> void bindBidirectional(Property<A> propertyA, Property<B> propertyB, Function<A, B> mapAtoB, Function<B, A> mapBtoA)

Binds propertyA bidirectional to propertyB using the provided map functions to convert between them.

bindBidirectionalback to summary
public static <A> void bindBidirectional(Property<A> propertyA, ObservableValue<A> propertyB, Consumer<A> updateB)

Binds propertyA bidirectional to propertyB while using updateB to update propertyB when propertyA changed.

bindBidirectionalback to summary
public static <A, B> void bindBidirectional(ObservableValue<A> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<A> updateB)

Binds propertyA bidirectional to propertyB using updateB to update propertyB when propertyA changed and similar for updateA.

bindContentBidirectionalback to summary
public static <A, B> void bindContentBidirectional(ObservableList<A> propertyA, ListProperty<B> propertyB, Consumer<ObservableList<B>> updateA, Consumer<List<A>> updateB)
bindContentBidirectionalback to summary
public static <A, B> void bindContentBidirectional(ObservableList<A> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<List<A>> updateB)
bindContentBidirectionalback to summary
public static <A, B> void bindContentBidirectional(ListProperty<A> listProperty, Property<B> property, Function<List<A>, B> mapToB, Function<B, List<A>> mapToList)
bindContentBidirectionalback to summary
public static <A, V, B> void bindContentBidirectional(ObservableMap<A, V> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<Map<A, V>> updateB)
bindContentBidirectionalback to summary
public static <A, V, B> void bindContentBidirectional(ObservableMap<A, V> propertyA, Property<B> propertyB, Consumer<B> updateA, Function<Map<A, V>, B> mapToB)
constantOfback to summary
public static <T> ObservableValue<T> constantOf(T value)
constantOfback to summary
public static ObservableValue<Boolean> constantOf(boolean value)
emptyStringback to summary
public static ObservableValue<? extends String> emptyString()
forUIback to summary
public static <T> ObservableList<T> forUI(ObservableList<T> list)

Returns a wrapper around the given list that posts changes on the JavaFX thread.

ifThenElseback to summary
public static <T> ObservableValue<T> ifThenElse(ObservableValue<Boolean> condition, T value, T other)
includePseudoClassWhenback to summary
public static com.tobiasdiez.easybind.Subscription includePseudoClassWhen(Node node, PseudoClass pseudoClass, ObservableValue<? extends Boolean> condition)
mapback to summary
public static <T, U> ObservableList<U> map(ObservableValue<T> source, Function<T, List<U>> mapper)
subscribeFutureback to summary
public static <T> com.tobiasdiez.easybind.Subscription subscribeFuture(ObservableValue<T> observable, Consumer<? super T> subscriber)

Invokes subscriber for the every new value of observable, but not for the current value.

API Note

EasyBind#subscribe(ObservableValue, Consumer) is similar but also invokes the subscriber for the current value

Parameters
observable:ObservableValue<T>

observable value to subscribe to

subscriber:Consumer<? super T>

action to invoke for values of observable.

Returns:com.tobiasdiez.easybind.Subscription

a subscription that can be used to stop invoking subscriber for any further observable changes.

org.jabref.gui.util back to summary

private Class BindingsHelper.BidirectionalBinding<A, B>

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ObservableValue<A>
private final Consumer<B>
private final Consumer<A>
private boolean

Constructor Summary

AccessConstructor and Description
public
BidirectionalBinding(ObservableValue<A> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<A> updateB)

Method Summary

Modifier and TypeMethod and Description
public void
changedA(ObservableValue<? extends A> observable, A oldValue, A newValue)

public void
changedB(ObservableValue<? extends B> observable, B oldValue, B newValue)

public ChangeListener<? super A>
public ChangeListener<? super B>
private <T> void
updateLocked(Consumer<T> update, T oldValue, T newValue)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

propertyAback to summary
private final ObservableValue<A> propertyA
updateAback to summary
private final Consumer<B> updateA
updateBback to summary
private final Consumer<A> updateB
updatingback to summary
private boolean updating

Constructor Detail

BidirectionalBindingback to summary
public BidirectionalBinding(ObservableValue<A> propertyA, ObservableValue<B> propertyB, Consumer<B> updateA, Consumer<A> updateB)

Method Detail

changedAback to summary
public void changedA(ObservableValue<? extends A> observable, A oldValue, A newValue)
changedBback to summary
public void changedB(ObservableValue<? extends B> observable, B oldValue, B newValue)
getChangeListenerAback to summary
public ChangeListener<? super A> getChangeListenerA()
getChangeListenerBback to summary
public ChangeListener<? super B> getChangeListenerB()
updateLockedback to summary
private <T> void updateLocked(Consumer<T> update, T oldValue, T newValue)
org.jabref.gui.util back to summary

private Class BindingsHelper.BidirectionalListBinding<A, B>

extends Object
implements ListChangeListener<A>, ChangeListener<B>
Class Inheritance
All Implemented Interfaces
javafx.beans.value.ChangeListener, javafx.collections.ListChangeListener

Field Summary

Modifier and TypeField and Description
private final ObservableList<A>
private final ObservableValue<B>
private final Consumer<B>
private final Consumer<List<A>>
private boolean

Constructor Summary

AccessConstructor and Description
public
BidirectionalListBinding(ObservableList<A> listProperty, ObservableValue<B> property, Consumer<B> updateA, Consumer<List<A>> updateB)

Method Summary

Modifier and TypeMethod and Description
public void
changed(ObservableValue<? extends B>
The ObservableValue which value changed
observable
,
B
The old value
oldValue
,
B
The new value
newValue
)

Implements javafx.beans.value.ChangeListener.changed.

Called when the value of an ObservableValue changes.

public void
onChanged(ListChangeListener.Change<? extends A>
an object representing the change that was done
c
)

Implements javafx.collections.ListChangeListener.onChanged.

Called after a change has been made to an ObservableList.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

listPropertyback to summary
private final ObservableList<A> listProperty
propertyback to summary
private final ObservableValue<B> property
updateAback to summary
private final Consumer<B> updateA
updateBback to summary
private final Consumer<List<A>> updateB
updatingback to summary
private boolean updating

Constructor Detail

BidirectionalListBindingback to summary
public BidirectionalListBinding(ObservableList<A> listProperty, ObservableValue<B> property, Consumer<B> updateA, Consumer<List<A>> updateB)

Method Detail

changedback to summary
public void changed(ObservableValue<? extends B> observable, B oldValue, B newValue)

Implements javafx.beans.value.ChangeListener.changed.

Doc from javafx.beans.value.ChangeListener.changed.

Called when the value of an ObservableValue changes.

In general, it is considered bad practice to modify the observed value in this method.

Parameters
observable:ObservableValue<? extends B>

The ObservableValue which value changed

oldValue:B

The old value

newValue:B

The new value

Annotations
@Override
onChangedback to summary
public void onChanged(ListChangeListener.Change<? extends A> c)

Implements javafx.collections.ListChangeListener.onChanged.

Doc from javafx.collections.ListChangeListener.onChanged.

Called after a change has been made to an ObservableList.

Parameters
c:ListChangeListener.Change<? extends A>

an object representing the change that was done

Annotations
@Override
org.jabref.gui.util back to summary

private Class BindingsHelper.BidirectionalMapBinding<A, V, B>

extends Object
implements MapChangeListener<A, V>, ChangeListener<B>
Class Inheritance
All Implemented Interfaces
javafx.beans.value.ChangeListener, javafx.collections.MapChangeListener

Field Summary

Modifier and TypeField and Description
private final ObservableMap<A, V>
private final ObservableValue<B>
private final Consumer<B>
private final Consumer<Map<A, V>>
private boolean

Constructor Summary

AccessConstructor and Description
public
BidirectionalMapBinding(ObservableMap<A, V> mapProperty, ObservableValue<B> property, Consumer<B> updateA, Consumer<Map<A, V>> updateB)

Method Summary

Modifier and TypeMethod and Description
public void
changed(ObservableValue<? extends B>
The ObservableValue which value changed
observable
,
B
The old value
oldValue
,
B
The new value
newValue
)

Implements javafx.beans.value.ChangeListener.changed.

Called when the value of an ObservableValue changes.

public void
onChanged(MapChangeListener.Change<? extends A, ? extends V>
the change that was made
c
)

Implements javafx.collections.MapChangeListener.onChanged.

Called after a change has been made to an ObservableMap.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapPropertyback to summary
private final ObservableMap<A, V> mapProperty
propertyback to summary
private final ObservableValue<B> property
updateAback to summary
private final Consumer<B> updateA
updateBback to summary
private final Consumer<Map<A, V>> updateB
updatingback to summary
private boolean updating

Constructor Detail

BidirectionalMapBindingback to summary
public BidirectionalMapBinding(ObservableMap<A, V> mapProperty, ObservableValue<B> property, Consumer<B> updateA, Consumer<Map<A, V>> updateB)

Method Detail

changedback to summary
public void changed(ObservableValue<? extends B> observable, B oldValue, B newValue)

Implements javafx.beans.value.ChangeListener.changed.

Doc from javafx.beans.value.ChangeListener.changed.

Called when the value of an ObservableValue changes.

In general, it is considered bad practice to modify the observed value in this method.

Parameters
observable:ObservableValue<? extends B>

The ObservableValue which value changed

oldValue:B

The old value

newValue:B

The new value

Annotations
@Override
onChangedback to summary
public void onChanged(MapChangeListener.Change<? extends A, ? extends V> c)

Implements javafx.collections.MapChangeListener.onChanged.

Doc from javafx.collections.MapChangeListener.onChanged.

Called after a change has been made to an ObservableMap. This method is called on every elementary change (put/remove) once. This means, complex changes like keySet().removeAll(Collection) or clear() may result in more than one call of onChanged method.

Parameters
c:MapChangeListener.Change<? extends A, ? extends V>

the change that was made

Annotations
@Override