SPT Core API

com.sptci.echo2.binding
Class ViewUpdater<V,M>

java.lang.Object
  extended by com.sptci.echo2.binding.Updater<V,M>
      extended by com.sptci.echo2.binding.ViewUpdater<V,M>
Type Parameters:
V - The class of the view component being updated.
M - The class of the model object from which to update.

public class ViewUpdater<V,M>
extends Updater<V,M>

An updater used to update UI components with data from their backing model objects.

Copyright 2006 Sans Pareil Technologies, Inc.

Version:
$Id: ViewUpdater.java 4553 2008-12-24 10:34:16Z rakesh $
Author:
Rakesh Vidyadharan 2006-02-07

Field Summary
 
Fields inherited from class com.sptci.echo2.binding.Updater
bean, logger, view
 
Constructor Summary
ViewUpdater(V view, M bean)
          Create a new instance with the specified UI container and java bean.
 
Method Summary
 DefaultMutableTreeNode createChild(Treeable treeable)
          Create tree nodes that represent the Treeable object and its children.
 Object createRootUserObject(String name)
          Create the userObject for a root tree node.
 Object createUserObject(Treeable t)
          Create the userObject for a tree node.
protected  void processMap(Map<String,ToggleButton> ui, Map<String,Boolean> value)
          Update ToggleButton UI components.
 void update()
          Update the fields of the Updater.view with the data in similarly named fields in Updater.bean.
 void update(String baseProperty)
          Update the Updater.view component with data in the specified Updater.bean.
protected  void updateComponent(Object object, Object value)
          Update the value of the specified code using the specified value.
protected  void updateListBox(ListBox listBox, Collection values)
          Update a ListBox UI component.
protected  void updateSelectField(SelectField selectField, Object object)
          Update a SelectField UI component.
protected  void updateTextComponent(TextComponent component, Object value)
          Update text compnents with the value specified.
 void updateTree(Tree tree, Collection<Treeable> collection, String baseProperty)
          Update a Tree with the data in the specified collection.
protected  void updateView(View view, Object value)
          Update a View component.
 
Methods inherited from class com.sptci.echo2.binding.Updater
beanValues, getBean, getView, setBean, setView, viewValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewUpdater

public ViewUpdater(V view,
                   M bean)
Create a new instance with the specified UI container and java bean.

Parameters:
view - The Updater.view to use.
bean - The Updater.bean to use.
Method Detail

update

public void update()
Update the fields of the Updater.view with the data in similarly named fields in Updater.bean.

Specified by:
update in class Updater<V,M>
Throws:
BindingException - If errors are encountered while accessing or setting the fields.
See Also:
ReflectionUtility.fetchField(java.lang.String, java.lang.Object), updateComponent(java.lang.Object, java.lang.Object)

update

public void update(String baseProperty)
Update the Updater.view component with data in the specified Updater.bean. This method should be used to update special components such as tables, trees etc.

Parameters:
baseProperty - The base property used to fetch localised string values. This should include the fully qualified name of the container class as well as the field.

updateComponent

protected void updateComponent(Object object,
                               Object value)
Update the value of the specified code using the specified value.

Parameters:
object - The UI component that is to be updated.
value - The value with which to update the object.
See Also:
updateTextComponent(nextapp.echo2.app.text.TextComponent, java.lang.Object), processMap(java.util.Map, java.util.Map), updateSelectField(nextapp.echo2.app.SelectField, java.lang.Object), updateListBox(nextapp.echo2.app.ListBox, java.util.Collection)

updateTextComponent

protected void updateTextComponent(TextComponent component,
                                   Object value)
Update text compnents with the value specified.

Parameters:
component - The text component that is to be updated.
value - The value to set in the text component.

processMap

protected void processMap(Map<String,ToggleButton> ui,
                          Map<String,Boolean> value)
Update ToggleButton UI components.

Parameters:
ui - The map that contains the name and selected state of the toggle button.
value - The new mappings to apply to the UI component.

updateListBox

protected void updateListBox(ListBox listBox,
                             Collection values)
Update a ListBox UI component.

Parameters:
listBox - The ListBox UI component that is to be updated.
values - The updated collection of selected data to apply to the list box component.

updateSelectField

protected void updateSelectField(SelectField selectField,
                                 Object object)
Update a SelectField UI component.

Parameters:
selectField - The UI component that is to be updated.
object - The object that is to be set as selected in the list.

updateView

protected void updateView(View view,
                          Object value)
Update a View component. Look for a field named model and try to set the value of that field.

Parameters:
view - The view component to update.
value - The value to set for the model backing the view.

updateTree

public void updateTree(Tree tree,
                       Collection<Treeable> collection,
                       String baseProperty)
Update a Tree with the data in the specified collection.

Parameters:
tree - The tree to be updated.
collection - The collection of Treeable instances.
baseProperty - The base name to use to look up localised values.
See Also:
createUserObject(com.sptci.jdo.Treeable), createChild(com.sptci.jdo.Treeable)

createChild

public DefaultMutableTreeNode createChild(Treeable treeable)
Create tree nodes that represent the Treeable object and its children.

Parameters:
treeable - The object for which a corresponding tree node is to be created.
Returns:
The tree node for the specified object.
See Also:
createUserObject(com.sptci.jdo.Treeable)

createRootUserObject

public Object createRootUserObject(String name)
Create the userObject for a root tree node. The user object is different for a general tree from an EditableTree.

Parameters:
name - The title to set for the user object.
Returns:
Returns the node initialised with the custom components.

createUserObject

public Object createUserObject(Treeable t)
Create the userObject for a tree node. The user object is different for a general tree from an EditableTree.

Parameters:
t - The treeable model object to use as the user object.
Returns:
Returns the node initialised with the custom components.

SPT Core API