|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.kleopatra.view.binding.BeanBinding
Helper to manage data binding.
Finds and binds input widgets of source container to properties of a bean-like target. Name of widgets is used as identifier of the widget.
Has state: exactly one container and exactly one target! Internally delegates into both directions:
PENDING: better support external triggers?
PENDING: think about using PresentationModel?
Field Summary | |
protected BeanAdapter |
beanAdapter
adapter vending valueModels bound to target properties. |
protected Trigger |
externalTrigger
externally accessible trigger. |
protected javax.swing.JComponent |
input
the common parent for all widgets to bind. |
protected Trigger |
internalTrigger
used for internally created buffered adapters. |
protected boolean |
observeChanges
flag to control listening to the adapted bean |
Constructor Summary | |
BeanBinding(javax.swing.JComponent input,
boolean observeChanges)
Prepares binding between children of input container with listening option. |
|
BeanBinding(javax.swing.JComponent input,
java.lang.Object target)
Prepares binding between children of input container and target bean without listening to changes of target bean. |
|
BeanBinding(javax.swing.JComponent input,
java.lang.Object target,
boolean observeChanges)
Prepares binding between children of input container and target bean with listening option. |
Method Summary | |
void |
addInversToggleDependents(java.lang.String componentName,
java.util.List dependents)
|
protected void |
addToggleDependents(EnableMultiplexer multiplexer,
java.util.List dependents)
|
void |
addToggleDependents(java.lang.String componentName,
java.util.List dependents)
adds a collection of components to be (dis)abled in synch with the selection state of the AbstractButton componentName. |
protected void |
bind(BindingMetaData metaData)
PRE: isBindable() |
void |
bind(java.util.Collection bindingMetaData)
tries to bind components to all given bindingMetaData. |
void |
bindBooleanInput(java.lang.String componentName)
|
void |
bindBooleanInput(java.lang.String componentName,
java.lang.String propertyName)
binds an AbstractButton to a two-state property. |
void |
bindComboBoxInput(java.lang.String componentName,
java.lang.Object model)
|
void |
bindComboBoxInput(java.lang.String componentName,
java.lang.Object model,
boolean editable)
|
void |
bindComboBoxInput(java.lang.String componentName,
java.lang.String propertyName,
java.lang.Object model)
|
void |
bindComboBoxInput(java.lang.String componentName,
java.lang.String propertyName,
java.lang.Object model,
boolean editable)
binds the selection of a comboBox to a property. |
void |
bindFormattedTextInput(java.lang.String componentName)
|
void |
bindFormattedTextInput(java.lang.String componentName,
java.lang.String propertyName)
|
void |
bindListAndSelection(java.lang.String componentName,
java.lang.String listPropertyName,
java.lang.String selectionPropertyName)
binds a list with both data and (single) selection. |
void |
bindListAndSelectionInput(java.lang.String componentName,
java.lang.String listPropertyName,
java.lang.String selectionPropertyName)
binds a list with both data and (single) selection. |
void |
bindListInput(java.lang.String componentName,
java.lang.String selectionPropertyName,
java.lang.String listPropertyName)
binds a list with both (single) selection and data. |
void |
bindRadioGroup(java.util.List componentIDs,
java.lang.String propertyName,
java.util.List optionValues)
binds the selection in a group of RadioButtons to a property. |
void |
bindRadioGroup(java.lang.String propertyName,
java.util.List componentIDs,
java.util.List optionValues)
binds the selection in a group of RadioButtons to a property. |
void |
bindSpinnerInput(java.lang.String componentName)
|
void |
bindSpinnerInput(java.lang.String componentName,
javax.swing.SpinnerModel model)
|
void |
bindSpinnerInput(java.lang.String componentName,
java.lang.String propertyName)
|
void |
bindSpinnerInput(java.lang.String componentName,
java.lang.String propertyName,
javax.swing.SpinnerModel spinnerModel)
binds a spinner's value to the property. |
void |
bindTextAreaInput(java.lang.String componentName)
|
void |
bindTextAreaInput(java.lang.String componentName,
boolean editable)
|
void |
bindTextAreaInput(java.lang.String componentName,
java.lang.String propertyName)
|
void |
bindTextAreaInput(java.lang.String componentName,
java.lang.String propertyName,
boolean editable)
binds a TextArea to a property. |
void |
bindTextInput(java.lang.String componentName)
|
void |
bindTextInput(java.lang.String componentName,
boolean editable)
|
void |
bindTextInput(java.lang.String componentName,
java.lang.String propertyName)
|
void |
bindTextInput(java.lang.String componentName,
java.lang.String propertyName,
boolean editable)
binds a TextField to a property. |
protected void |
checkBindable()
should not happen... |
void |
commit()
|
protected BeanAdapter |
createBeanAdapter()
|
protected java.util.List |
createList()
|
protected java.util.Map |
createMap()
|
javax.swing.JComponent |
findComponent(java.lang.String name)
|
void |
flush()
|
protected BeanAdapter |
getBeanAdapter()
|
protected BindingHandler |
getBindingHandler(BindingMetaData metaData)
|
protected Trigger |
getExternalTrigger()
returns the external trigger. |
javax.swing.JComponent |
getInputContainer()
returns a common ancestor of bound components. |
java.lang.Object |
getTarget()
returns the bound target. |
protected ValueModel |
getValueModel(java.lang.String propertyName)
returns an adapter from the beanAdapter. |
protected void |
internalCommit()
will trigger a commit from internal events. |
protected void |
internalFlush()
|
protected boolean |
isBindable()
not really needed if null check in constructor |
boolean |
isBufferEnabled()
|
void |
setBufferEnabled(boolean externalTriggering)
flag to enable buffering of ValueModels. |
void |
setEnabled(java.lang.String componentName,
boolean enabled)
|
void |
setTarget(java.lang.Object newTarget)
set the target to bind. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Trigger internalTrigger
protected Trigger externalTrigger
protected BeanAdapter beanAdapter
protected boolean observeChanges
protected javax.swing.JComponent input
Constructor Detail |
public BeanBinding(javax.swing.JComponent input, boolean observeChanges)
input
- - the parent container of the widgets to bind.
Must not be null.observeChanges
- - flag to indicate if the adapter should
listen to changes of the target bean.public BeanBinding(javax.swing.JComponent input, java.lang.Object target)
input
- - the parent container of the widgets to bind.
Must not be null.target
- - the target bean to bindpublic BeanBinding(javax.swing.JComponent input, java.lang.Object target, boolean observeChanges)
input
- - the parent container of the widgets to bind.
Must not be null.target
- - the target bean to bind, allowed to be null.observeChanges
- - flag to indicate if the adapter should
listen to changes of the target bean.Method Detail |
public void setBufferEnabled(boolean externalTriggering)
NOTE: this must be done before calling any of the bindXX methods!
public void setTarget(java.lang.Object newTarget)
public java.lang.Object getTarget()
public javax.swing.JComponent getInputContainer()
public boolean isBufferEnabled()
public void commit()
public void flush()
public void bind(java.util.Collection bindingMetaData)
bindingMetaData
- - list containing metaData. Must not be null.
java.lang.IllegalStateException
- if !isBindable()public void bindTextInput(java.lang.String componentName)
public void bindTextInput(java.lang.String componentName, boolean editable)
public void bindTextInput(java.lang.String componentName, java.lang.String propertyName)
public void bindTextInput(java.lang.String componentName, java.lang.String propertyName, boolean editable)
PENDING: currently _not_ adapted to Document directly, that is inserts/remove will not be committed at once but on on internal (action and focusLost) trigger, need parameter to enable/disable on a per-binding basis.
public void bindTextAreaInput(java.lang.String componentName)
public void bindTextAreaInput(java.lang.String componentName, boolean editable)
public void bindTextAreaInput(java.lang.String componentName, java.lang.String propertyName)
public void bindTextAreaInput(java.lang.String componentName, java.lang.String propertyName, boolean editable)
PENDING: currently _not_ adapted to Document directly, that is inserts/remove will not be committed at once but on on internal (action and focusLost) trigger, need parameter to enable/disable on a per-binding basis.
componentName
- propertyName
- editable
- public void bindFormattedTextInput(java.lang.String componentName)
public void bindFormattedTextInput(java.lang.String componentName, java.lang.String propertyName)
public void bindSpinnerInput(java.lang.String componentName)
public void bindSpinnerInput(java.lang.String componentName, java.lang.String propertyName)
public void bindSpinnerInput(java.lang.String componentName, javax.swing.SpinnerModel model)
public void bindSpinnerInput(java.lang.String componentName, java.lang.String propertyName, javax.swing.SpinnerModel spinnerModel)
All shortcut methods for spinner binding call this method.
componentName
- propertyName
- spinnerModel
- the spinnerModel to use, may be null.public void bindComboBoxInput(java.lang.String componentName, java.lang.Object model)
public void bindComboBoxInput(java.lang.String componentName, java.lang.Object model, boolean editable)
public void bindComboBoxInput(java.lang.String componentName, java.lang.String propertyName, java.lang.Object model)
public void bindComboBoxInput(java.lang.String componentName, java.lang.String propertyName, java.lang.Object model, boolean editable)
PRE: model can an Array, a ListModel, a List, or a property returning a ListModel or a List. Internally the binding will create a ComboBoxAdapter for all.
All short-cut methods for binding combos use this.
public void bindListAndSelectionInput(java.lang.String componentName, java.lang.String listPropertyName, java.lang.String selectionPropertyName)
NOTE: clients are responsible to guarantee that listProperty returns a "list-like" structure usable by SelectionInList as listHolder.
public void bindListInput(java.lang.String componentName, java.lang.String selectionPropertyName, java.lang.String listPropertyName)
public void bindListAndSelection(java.lang.String componentName, java.lang.String listPropertyName, java.lang.String selectionPropertyName)
public void bindBooleanInput(java.lang.String componentName)
public void bindBooleanInput(java.lang.String componentName, java.lang.String propertyName)
Internally uses a ToggleButtonAdapter. For constraints on the property, have a look at its api doc.
PENDING: client is responsible for not binding a radiobuttons/toggleButtons by this method at least none that should be used in a radioGroup.
componentName
- propertyName
- public void bindRadioGroup(java.lang.String propertyName, java.util.List componentIDs, java.util.List optionValues)
NOTE: it's the calling code's responsibility to guarantee valid options and equal lengths on boths lists.
public void bindRadioGroup(java.util.List componentIDs, java.lang.String propertyName, java.util.List optionValues)
NOTE: it's the calling code's responsibility to guarantee valid options and equal lengths on boths lists.
public void addToggleDependents(java.lang.String componentName, java.util.List dependents)
componentName
- the id of the controlling buttondependents
- a list of ids of dependent componentspublic void addInversToggleDependents(java.lang.String componentName, java.util.List dependents)
public void setEnabled(java.lang.String componentName, boolean enabled)
public javax.swing.JComponent findComponent(java.lang.String name)
protected void addToggleDependents(EnableMultiplexer multiplexer, java.util.List dependents)
protected ValueModel getValueModel(java.lang.String propertyName)
protected void bind(BindingMetaData metaData)
protected BindingHandler getBindingHandler(BindingMetaData metaData)
protected boolean isBindable()
protected void checkBindable() throws BindingComponentNotFoundException
BindingComponentNotFoundException
- if !isBindable()protected void internalCommit()
protected void internalFlush()
protected Trigger getExternalTrigger()
protected BeanAdapter getBeanAdapter()
protected BeanAdapter createBeanAdapter()
protected java.util.Map createMap()
protected java.util.List createList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |