Class AutoBinding<SS,SV,TS,TV>
- Type Parameters:
SS
- the type of source objectSV
- the type of value that the source property representsTS
- the type of target objectTV
- the type of value that the target property represents
- Direct Known Subclasses:
JComboBoxBinding, JListBinding, JTableBinding
Binding
that automatically syncs the source
and target by refreshing and saving according to one of three update
strategies. The update strategy is specified for an AutoBinding
on creation, and is one of:
AutoBinding.UpdateStrategy.READ_ONCE
AutoBinding.UpdateStrategy.READ
AutoBinding.UpdateStrategy.READ_WRITE
The behavior of AutoBinding
for each
of the update strategies is defined as follows:
READ_ONCE |
Summary: Tries to sync the target from the source only once, at bind time.
Details: |
|
READ |
Summary: Tries to keep the target in sync with the source.
Details: |
|
READ_WRITE |
Summary: Tries to keep both the source and target in sync with each other.
Details:
Automatically responds to changes in the state of the source as follows:
If the change represents a value change, use the try-refresh-then-save
procedure mentioned above. Otherwise, if the change represents the
source becoming writeable, tries to update the source from the target
by calling
Automatically responds to changes in the state of the target as follows:
If the change represents the target simply becoming writeable, try to
sync the target from the source by calling |
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enumeration representing the possible update strategies of anAutoBinding
.Nested classes/interfaces inherited from class Binding
Binding.SyncFailure, Binding.SyncFailureType, Binding.ValueResult<V>
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AutoBinding
(AutoBinding.UpdateStrategy strategy, SS sourceObject, Property<SS, SV> sourceProperty, TS targetObject, Property<TS, TV> targetProperty, String name) Create an instance ofAutoBinding
between two properties of two objects, with the given update strategy. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
bindImpl()
Called byBinding.bind()
to allow subclasses to initiate binding.Returns theAutoBinding's
update strategy.protected String
Returns a string representing the internal state of theBinding
.protected void
Called to indicate that the source property has fired aPropertyStateEvent
to indicate that its state has changed for the source object.protected void
Called to indicate that the target property has fired aPropertyStateEvent
to indicate that its state has changed for the target object.protected void
Called byBinding.unbind()
to allow subclasses to uninitiate binding.Methods inherited from class Binding
addBindingListener, addPropertyChangeListener, addPropertyChangeListener, bind, bindUnmanaged, firePropertyChange, getBindingListeners, getConverter, getName, getPropertyChangeListeners, getPropertyChangeListeners, getSourceNullValue, getSourceObject, getSourceProperty, getSourceUnreadableValue, getSourceValueForTarget, getTargetNullValue, getTargetObject, getTargetProperty, getTargetValueForSource, getValidator, isBound, isManaged, isSourceUnreadableValueSet, notifySynced, notifySyncFailed, refresh, refreshAndNotify, refreshAndNotifyUnmanaged, refreshUnmanaged, removeBindingListener, removePropertyChangeListener, removePropertyChangeListener, save, saveAndNotify, saveAndNotifyUnmanaged, saveUnmanaged, setConverter, setManaged, setSourceNullValue, setSourceObject, setSourceObjectUnmanaged, setSourceProperty, setSourceUnreadableValue, setTargetNullValue, setTargetObject, setTargetObjectUnmanaged, setTargetProperty, setValidator, throwIfBound, throwIfManaged, throwIfUnbound, toString, unbind, unbindUnmanaged, unsetSourceUnreadableValue
-
Constructor Details
-
AutoBinding
protected AutoBinding(AutoBinding.UpdateStrategy strategy, SS sourceObject, Property<SS, SV> sourceProperty, TS targetObject, Property<TS, TV> targetProperty, String name) Create an instance ofAutoBinding
between two properties of two objects, with the given update strategy.- Parameters:
strategy
- the update strategysourceObject
- the source objectsourceProperty
- a property on the source objecttargetObject
- the target objecttargetProperty
- a property on the target objectname
- a name for theBinding
- Throws:
IllegalArgumentException
- if the source property or target property isnull
-
-
Method Details
-
getUpdateStrategy
Returns theAutoBinding's
update strategy.- Returns:
- the update strategy
-
bindImpl
protected void bindImpl()Description copied from class:Binding
Called byBinding.bind()
to allow subclasses to initiate binding. Subclasses typically need not installPropertyStateListeners
on the source property and target property as they will be notified by calls toBinding.sourceChangedImpl(PropertyStateEvent)
andBinding.targetChangedImpl(PropertyStateEvent)
when the source and target properties change respectively. -
unbindImpl
protected void unbindImpl()Description copied from class:Binding
Called byBinding.unbind()
to allow subclasses to uninitiate binding. -
paramString
Returns a string representing the internal state of theBinding
. This method is intended to be used for debugging purposes only, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
. -
sourceChangedImpl
Description copied from class:Binding
Called to indicate that the source property has fired aPropertyStateEvent
to indicate that its state has changed for the source object. Called after theBinding
has notified any property change listeners andBindingListeners
that the source value has been edited (only if thePropertyStateEvent
represents a value change). This method is useful for subclasses to detect source changes and perform syncing as appropriate. -
targetChangedImpl
Description copied from class:Binding
Called to indicate that the target property has fired aPropertyStateEvent
to indicate that its state has changed for the target object. Called after theBinding
has notified any property change listeners andBindingListeners
that the target value has been edited (only if thePropertyStateEvent
represents a value change). This method is useful for subclasses to detect target changes and perform syncing as appropriate.
-