net.sf.echobinding.binding
Class AbstractBindingContext

java.lang.Object
  extended by net.sf.echobinding.binding.AbstractBindingContext
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, BindingContext
Direct Known Subclasses:
OgnlBindingContext

public abstract class AbstractBindingContext
extends java.lang.Object
implements BindingContext, java.io.Serializable

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap<java.lang.String,PropertyAdapter> _adapters
           
protected  java.beans.PropertyChangeSupport _changes
           
 
Constructor Summary
AbstractBindingContext()
           
 
Method Summary
 BindingContext add(java.lang.String id, PropertyAdapter binding)
          Adds a property adapter to the context.
 void addChild(BindingContext child)
          Adds a child to the set of child contexts.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Add listener for the specified property name.
protected  void firePropertyChange(java.beans.PropertyChangeEvent event)
           
protected  void firePropertyChange(java.lang.String bindingId, java.lang.Object oldValue, java.lang.Object newValue)
           
 java.util.Set<BindingContext> getChilds()
          Returns the child binding contexts.
 BoundControl getControl(java.lang.String id)
          Returns the bound control that belongs to the adapter id.
 java.util.Set<BoundControl> getControls()
          Returns all registered controls.
 Decorator getDecorator(java.lang.String id)
          Returns the decorator for the specified binding id.
 Format getFormat(java.lang.String id)
          Returns the format for the specified adapter.
 BindingContext getParent()
          Returns the parent binding context.
 PresentationModel getPresentationModel()
          Returns the pesentation model.
 java.util.List<PropertyAdapter> getPropertyAdapters()
          Returns all property adapters for this context.
 boolean isDirty()
          Checks if the state of any controls in this context an its sub contexts is different from the state in the model.
 boolean isValid()
          Checks if all controls in this context and the controls in its sub contexts contain valid inputs.
 void propertyChange(java.beans.PropertyChangeEvent event)
           
 void registerControl(java.lang.String id, BoundControl control)
          Adds a control to the list of registered controls and registers the control as PropertyChangeListener at this context.
 PropertyAdapter remove(java.lang.String id)
          Removes a binding from the context.
 boolean removeChild(BindingContext context)
          Removes a child context from this context.
 void removeControl(BoundControl control)
          Renoves a bound control from the context.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
          Remove listeners for the given property name.
 void setChilds(java.util.Set<BindingContext> childs)
          Sets the child contexts.
 void setParent(BindingContext parent)
          Sets the parent binding context.
 void setPresentationModel(PresentationModel presentationModel)
          Sets the presentation model.
 void synchronize()
          Synchronizes the GUI/screen state with the application state.
 void update()
          Resets the GUI/screen state.
 void validate()
          Validates this context and all its sub contexts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.echobinding.binding.BindingContext
createChild, getAdapter, getModel, getValidationHandler, getValidationHandler, getValue, isDirty, setModel, setValidationHandler, setValue, validate
 

Field Detail

_adapters

protected java.util.HashMap<java.lang.String,PropertyAdapter> _adapters

_changes

protected java.beans.PropertyChangeSupport _changes
Constructor Detail

AbstractBindingContext

public AbstractBindingContext()
Method Detail

add

public BindingContext add(java.lang.String id,
                          PropertyAdapter binding)
Description copied from interface: BindingContext
Adds a property adapter to the context.

Specified by:
add in interface BindingContext
Parameters:
id - the adapter id
binding - the adapter
Returns:
this

remove

public PropertyAdapter remove(java.lang.String id)
Description copied from interface: BindingContext
Removes a binding from the context.

Specified by:
remove in interface BindingContext
Parameters:
id - The adapter id
Returns:
the removed property adapter

addChild

public void addChild(BindingContext child)
Adds a child to the set of child contexts.

Parameters:
child -

getChilds

public java.util.Set<BindingContext> getChilds()
Description copied from interface: BindingContext
Returns the child binding contexts.

Specified by:
getChilds in interface BindingContext
Returns:
Returns the childs.

setChilds

public void setChilds(java.util.Set<BindingContext> childs)
Sets the child contexts.

Parameters:
childs - The childs to set.

getParent

public BindingContext getParent()
Description copied from interface: BindingContext
Returns the parent binding context.

Specified by:
getParent in interface BindingContext
Returns:
Returns the parent binding context.

setParent

public void setParent(BindingContext parent)
Sets the parent binding context.

Specified by:
setParent in interface BindingContext
Parameters:
parent - The parent binding context to set.

getPropertyAdapters

public java.util.List<PropertyAdapter> getPropertyAdapters()
Description copied from interface: BindingContext
Returns all property adapters for this context.

Specified by:
getPropertyAdapters in interface BindingContext
Returns:
List of all adapters

getDecorator

public Decorator getDecorator(java.lang.String id)
Description copied from interface: BindingContext
Returns the decorator for the specified binding id.

Specified by:
getDecorator in interface BindingContext
Parameters:
id - the id
Returns:
the decorator of the binding

getFormat

public Format getFormat(java.lang.String id)
Description copied from interface: BindingContext
Returns the format for the specified adapter.

Specified by:
getFormat in interface BindingContext
Parameters:
id - the id
Returns:
the format

registerControl

public void registerControl(java.lang.String id,
                            BoundControl control)
Adds a control to the list of registered controls and registers the control as PropertyChangeListener at this context.

Specified by:
registerControl in interface BindingContext
Parameters:
id - the adapter id
control - the control

removeControl

public void removeControl(BoundControl control)
Description copied from interface: BindingContext
Renoves a bound control from the context.

Specified by:
removeControl in interface BindingContext
Parameters:
control - the control

getControl

public BoundControl getControl(java.lang.String id)
Description copied from interface: BindingContext
Returns the bound control that belongs to the adapter id.

Specified by:
getControl in interface BindingContext
Parameters:
id - The adapter id
Returns:
The bound control

getControls

public java.util.Set<BoundControl> getControls()
Description copied from interface: BindingContext
Returns all registered controls.

Specified by:
getControls in interface BindingContext
Returns:
the controls

firePropertyChange

protected void firePropertyChange(java.lang.String bindingId,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
                           throws BindingException
Parameters:
bindingId -
oldValue -
newValue -
Throws:
BindingException

firePropertyChange

protected void firePropertyChange(java.beans.PropertyChangeEvent event)
                           throws BindingException
Throws:
BindingException

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: BindingContext
Add a PropertyChangeListener to the listener list. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.

Specified by:
addPropertyChangeListener in interface BindingContext
Parameters:
listener - the listener

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Add listener for the specified property name.

Specified by:
addPropertyChangeListener in interface BindingContext
Parameters:
propertyName -
listener -

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: BindingContext
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.

Specified by:
removePropertyChangeListener in interface BindingContext
Parameters:
listener - - The PropertyChangeListener to be removed

removePropertyChangeListener

public void removePropertyChangeListener(java.lang.String propertyName,
                                         java.beans.PropertyChangeListener listener)
Remove listeners for the given property name.

Parameters:
propertyName -
listener -

synchronize

public void synchronize()
Description copied from interface: BindingContext
Synchronizes the GUI/screen state with the application state. Transfers the state of every widget attached to this context to the model.

Specified by:
synchronize in interface BindingContext

isValid

public boolean isValid()
Description copied from interface: BindingContext
Checks if all controls in this context and the controls in its sub contexts contain valid inputs.

Specified by:
isValid in interface BindingContext
Returns:
true if all controls are valid, otherwise false

isDirty

public boolean isDirty()
Description copied from interface: BindingContext
Checks if the state of any controls in this context an its sub contexts is different from the state in the model.

Specified by:
isDirty in interface BindingContext
Returns:
true if any controls is dirty, false otherwise

update

public void update()
Description copied from interface: BindingContext
Resets the GUI/screen state. Overwrites the widget's state with the state in the model.

Specified by:
update in interface BindingContext

validate

public void validate()
Description copied from interface: BindingContext
Validates this context and all its sub contexts. Invokes validateInput() on each attached control to show validation errors to the user.

Specified by:
validate in interface BindingContext

removeChild

public boolean removeChild(BindingContext context)
Description copied from interface: BindingContext
Removes a child context from this context.

Specified by:
removeChild in interface BindingContext
Parameters:
context - the context
Returns:
true, if remove child

getPresentationModel

public PresentationModel getPresentationModel()
Description copied from interface: BindingContext
Returns the pesentation model.

Specified by:
getPresentationModel in interface BindingContext
Returns:
Returns the presentationModel.

setPresentationModel

public void setPresentationModel(PresentationModel presentationModel)
Description copied from interface: BindingContext
Sets the presentation model.

Specified by:
setPresentationModel in interface BindingContext
Parameters:
presentationModel - The presentationModel to set.


Copyright © 2007. All Rights Reserved.