org.apache.wicket.extensions.markup.html.repeater.util
Class TreeModelProvider<T>

java.lang.Object
  extended by org.apache.wicket.extensions.markup.html.repeater.util.TreeModelProvider<T>
Type Parameters:
T - model object type
All Implemented Interfaces:
Serializable, ITreeProvider<T>, IDetachable, IClusterable

public abstract class TreeModelProvider<T>
extends Object
implements ITreeProvider<T>

A provider wrapping a Swing TreeModel. EXPERIMENTAL !

Author:
svenmeier
See Also:
Serialized Form

Field Summary
protected  List<T> branchUpdates
           
protected  boolean completeUpdate
           
protected  List<T> nodeUpdates
           
 
Constructor Summary
TreeModelProvider(TreeModel treeModel)
          Wrap the given TreeModel.
TreeModelProvider(TreeModel treeModel, boolean rootVisible)
          Wrap the given TreeModel.
 
Method Summary
protected  void branchUpdate(Object branch)
           
protected  T cast(Object object)
           
 void detach()
          Detaches model after use.
 Iterator<T> getChildren(T object)
          Get the children of the given node.
 Iterator<T> getRoots()
          Get the roots of the tree.
 boolean hasChildren(T object)
          Does the given object have children - note that this method may return true even if ITreeProvider.getChildren(Object) returns an empty iterator.
abstract  IModel<T> model(T object)
          Callback used by the consumer of this tree provider to wrap objects retrieved from ITreeProvider.getRoots() or ITreeProvider.getChildren(Object) with a model (usually a detachable one).
protected  void nodeUpdate(Object[] nodes)
           
 void update(AbstractTree<T> tree, AjaxRequestTarget target)
          Call this method after all change to the wrapped TreeModel being initiated via AjaxRequestTarget.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

completeUpdate

protected boolean completeUpdate

nodeUpdates

protected List<T> nodeUpdates

branchUpdates

protected List<T> branchUpdates
Constructor Detail

TreeModelProvider

public TreeModelProvider(TreeModel treeModel)
Wrap the given TreeModel.

Parameters:
treeModel - model to wrap

TreeModelProvider

public TreeModelProvider(TreeModel treeModel,
                         boolean rootVisible)
Wrap the given TreeModel.

Parameters:
treeModel - the wrapped model
rootVisible - should the root be visible
Method Detail

getRoots

public Iterator<T> getRoots()
Description copied from interface: ITreeProvider
Get the roots of the tree.

Specified by:
getRoots in interface ITreeProvider<T>
Returns:
roots

hasChildren

public boolean hasChildren(T object)
Description copied from interface: ITreeProvider
Does the given object have children - note that this method may return true even if ITreeProvider.getChildren(Object) returns an empty iterator.

Specified by:
hasChildren in interface ITreeProvider<T>
Parameters:
object - the node to check for children
Returns:
true if node has children

getChildren

public Iterator<T> getChildren(T object)
Description copied from interface: ITreeProvider
Get the children of the given node.

Specified by:
getChildren in interface ITreeProvider<T>
Parameters:
object - node to get children for
Returns:
children of node

cast

protected T cast(Object object)

model

public abstract IModel<T> model(T object)
Description copied from interface: ITreeProvider
Callback used by the consumer of this tree provider to wrap objects retrieved from ITreeProvider.getRoots() or ITreeProvider.getChildren(Object) with a model (usually a detachable one).

Important note: The model must implement Object.equals(Object) and Object.hashCode() !

Specified by:
model in interface ITreeProvider<T>
Parameters:
object - the object that needs to be wrapped
Returns:
the model representation of the object

detach

public void detach()
Description copied from interface: IDetachable
Detaches model after use. This is generally used to null out transient references that can be re-attached later.

Specified by:
detach in interface IDetachable

update

public void update(AbstractTree<T> tree,
                   AjaxRequestTarget target)
Call this method after all change to the wrapped TreeModel being initiated via AjaxRequestTarget.

Parameters:
tree - the tree utilizing this ITreeProvider
target - the AjaxRequestTarget which initiated the changes

nodeUpdate

protected void nodeUpdate(Object[] nodes)

branchUpdate

protected void branchUpdate(Object branch)


Copyright © 2006-2012 Apache Software Foundation. All Rights Reserved.