|
JavaGantt 2011.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteu.beesoft.gaia.util.ObjectBuilder<T>
eu.beesoft.gaia.swing.builder.SwingBuilder<T>
T
- class of object created by this builderpublic abstract class SwingBuilder<T>
Abstract superclass of all Swing-related object builders. It supports data binding.
Data binding assumes that there is one root data object for displayed form. Another objects are referenced from it or from objects referenced by it. So the object hierarchy is requested in bound data.
The binding for builder (and its object / component) is recorded in source XML file (as an attribute 'binding'). SwingBuilder uses this algorithm to bind a specific data property to component created by it:
ValueObject
, it uses get
/ set method
The binding for builder (and its object / component) is recorded in source
XML file (as an attribute 'binding'). You can use also so called
dot-convention: if your object references via property a object A, object A
references via property b object B, and you want to display property c of
that object, you can write binding as a.b.c
- it is easy.
Constructor Summary | |
---|---|
SwingBuilder()
|
Method Summary | |
---|---|
protected java.lang.Object |
convertValue(java.lang.Object value,
java.lang.Class<?> targetClass,
java.lang.String fullBinding)
Converts given value to requested type. |
protected java.lang.Object |
createBoundData(java.lang.String binding)
Creates a new data object for given binding. |
protected java.lang.Object |
findBoundData(java.lang.String fullBinding,
SwingBuilder<?> caller)
Returns an object that is addressed with given binding. |
protected java.util.List<SwingBuilder<?>> |
getBindableChildren()
Retuns a list of all children - builders that support data binding. |
java.lang.String |
getBinding()
Returns this bulder binding. |
java.lang.Object |
getBoundData(java.util.Set<java.lang.Object> changedObjects,
java.lang.String fullBinding)
Returns data from builder's object. |
protected java.lang.Object |
getBoundValueFromComponent(java.util.Set<java.lang.Object> changedObjects,
java.lang.String fullBinding)
Gets data value from the component created by this builder. |
protected java.lang.String |
getPropertyFromResourceBundle(java.lang.String name)
Returns property value for given name from the current resource bundle. |
protected java.lang.Object |
getValueFromBoundObject(java.lang.Object object,
java.lang.String propertyName,
java.lang.String fullBinding)
Returns a value from given data object and given property. |
protected void |
initBinding(java.lang.String value)
Initializes property binding (stores it to the instance
variable). |
protected boolean |
isBindable()
Returns true if binding ! |
protected java.awt.Dimension |
parseDimension(java.lang.String value)
Helper method to convert given String to java.awt.Dimension
object. |
void |
setBoundData(java.lang.Object data,
java.lang.String fullBinding)
Sets given data to component created by this builder. |
protected void |
setBoundValueToComponent(java.lang.Object value,
java.lang.String fullBinding)
Sets given data value to the component created by this builder. |
protected void |
setValueToBoundObject(java.lang.Object object,
java.lang.String propertyName,
java.lang.Object value,
java.lang.String fullBinding)
Sets a value to a given property of the given object. |
Methods inherited from class eu.beesoft.gaia.util.ObjectBuilder |
---|
addChild, createObject, createObject, getFactory, getChildren, getId, getObject, getParent, getProperties, getProperty, initClass, initId, initObjectProperties, initObjectProperty, parseBoolean, parseClass, parseConstant, parseConstructor, parseDouble, parseInstance, parseInstance, parseInt, parseInt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SwingBuilder()
Method Detail |
---|
protected java.awt.Dimension parseDimension(java.lang.String value)
java.awt.Dimension
object. String must have a form [int, int], for example "3, 5".
value
- - string to convert
protected java.lang.String getPropertyFromResourceBundle(java.lang.String name)
name
from the current resource bundle.
name
- - name of the property to finf
protected void initBinding(java.lang.String value)
binding
(stores it to the instance
variable). Given value is a a name of the property, which should be
displayed by builder's object (component).
value
- - value from according attribute in XML to initialize this
propertypublic java.lang.String getBinding()
protected boolean isBindable()
protected java.util.List<SwingBuilder<?>> getBindableChildren()
public void setBoundData(java.lang.Object data, java.lang.String fullBinding)
setBoundValueToComponent(Object, String)
.
data
- - data to setfullBinding
- - qualified path from root of data to given datapublic java.lang.Object getBoundData(java.util.Set<java.lang.Object> changedObjects, java.lang.String fullBinding)
changedObjects
- - a collection of data object's changed by userfullBinding
- - qualified path from root of data to given data
setBoundData(Object, String)
.protected java.lang.Object createBoundData(java.lang.String binding)
This method is invoked from getBoundData(Set, String)
method,
when is processed a property chain with null objects in the middle and
changed value at last property (for example, you have binding a.b.c,
object for b is null and user changed property c in UI - then is
necessary to create object for b property to create full chain).
This implementation throws RuntimeException to notify programmer to override it.
binding
- - binding for which should be created object
protected java.lang.Object findBoundData(java.lang.String fullBinding, SwingBuilder<?> caller)
fullBinding
- - binding for finding of objectcaller
- - instance of SwingBuilder which invoked this method
protected java.lang.Object getValueFromBoundObject(java.lang.Object object, java.lang.String propertyName, java.lang.String fullBinding)
ValueObject
, gets its property with given
name
object
- - source of requested datapropertyName
- - name of the requested propertyfullBinding
- - information about qualified binding from root of the form
java.lang.RuntimeException
- if property with given name cannot be accessedprotected void setValueToBoundObject(java.lang.Object object, java.lang.String propertyName, java.lang.Object value, java.lang.String fullBinding)
ValueObject
, sets its property with given
name
object
- - container for given valuepropertyName
- - name of the propertyvalue
- - value to setfullBinding
- - information about qualified binding from root of the form
java.lang.RuntimeException
- if property with given name cannot be accessedprotected void setBoundValueToComponent(java.lang.Object value, java.lang.String fullBinding)
value
- - a value to setfullBinding
- - binding to given value from root form objectprotected java.lang.Object getBoundValueFromComponent(java.util.Set<java.lang.Object> changedObjects, java.lang.String fullBinding)
changedObjects
- - collection of changed data objects, add your data object to
this if your component's value was changed by userfullBinding
- - binding to component's value from root form object
protected java.lang.Object convertValue(java.lang.Object value, java.lang.Class<?> targetClass, java.lang.String fullBinding)
value
- - a value to converttargetClass
- - a type to which should be given value convertedfullBinding
- - binding to given value from root form object
|
JavaGantt 2011.1 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |