com.extjs.gxt.ui.client.data
Class BaseTreeModel<T extends TreeModel>

java.lang.Object
  extended by com.extjs.gxt.ui.client.data.BaseModelData
      extended by com.extjs.gxt.ui.client.data.BaseModel
          extended by com.extjs.gxt.ui.client.data.BaseTreeModel<T>
All Implemented Interfaces:
ChangeEventSource, Model, ModelData, TreeModel<T>, java.io.Serializable

public class BaseTreeModel<T extends TreeModel>
extends BaseModel
implements TreeModel<T>

Default implementation of the TreeModel interface.

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface com.extjs.gxt.ui.client.data.ChangeEventSource
Add, Remove, Update
 
Constructor Summary
BaseTreeModel()
          Creates a new model instance.
BaseTreeModel(java.util.Map<java.lang.String,java.lang.Object> properties)
          Creates a new model instance with the specified properties.
BaseTreeModel(T parent)
          Creates a new model instance.
 
Method Summary
 void add(T child)
          Adds a child to the model and fires an ChangeEventSource.Add event.
 T getChild(int index)
          Returns the child at the given index or null if the index is out of range.
 int getChildCount()
          Returns the number of children.
 java.util.List<T> getChildren()
          Returns the model's children.
 T getParent()
          Returns the model's parent or null if no parent.
 int indexOf(T child)
          Returns the index of the child.
 void insert(T child, int index)
          Inserts a child to the model and fires an ChangeEventSource.Add event.
 boolean isLeaf()
          Returns true if the model is a leaf and has children.
 void notify(ChangeEvent evt)
          Notifies listeners of the given change event.
 void remove(int index)
          Removes the child at the given index.
 void remove(T child)
          Removes the child from the model and fires a ChangeEventSource.Remove event.
 void removeAll()
          Removes all the children.
 void setChildren(java.util.List<T> children)
          Sets the model's children.
 void setParent(T parent)
          Sets the model's parent.
 
Methods inherited from class com.extjs.gxt.ui.client.data.BaseModel
addChangeListener, addChangeListener, remove, removeChangeListener, removeChangeListeners, set, setSilent
 
Methods inherited from class com.extjs.gxt.ui.client.data.BaseModelData
get, get, getProperties, getPropertyNames, isAllowNestedValues, setAllowNestedValues, setProperties
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.extjs.gxt.ui.client.data.ModelData
get, getProperties, getPropertyNames, remove, set
 
Methods inherited from interface com.extjs.gxt.ui.client.data.ChangeEventSource
addChangeListener, removeChangeListener, removeChangeListeners, setSilent
 

Constructor Detail

BaseTreeModel

public BaseTreeModel()
Creates a new model instance.


BaseTreeModel

public BaseTreeModel(java.util.Map<java.lang.String,java.lang.Object> properties)
Creates a new model instance with the specified properties.

Parameters:
properties - the initial properties

BaseTreeModel

public BaseTreeModel(T parent)
Creates a new model instance.

Parameters:
parent - the parent
Method Detail

add

public void add(T child)
Adds a child to the model and fires an ChangeEventSource.Add event.

Specified by:
add in interface TreeModel<T extends TreeModel>
Parameters:
child - the child to be added

getChild

public T getChild(int index)
Returns the child at the given index or null if the index is out of range.

Specified by:
getChild in interface TreeModel<T extends TreeModel>
Parameters:
index - the index to be retrieved
Returns:
the model at the index

getChildCount

public int getChildCount()
Returns the number of children.

Specified by:
getChildCount in interface TreeModel<T extends TreeModel>
Returns:
the number of children

getChildren

public java.util.List<T> getChildren()
Returns the model's children.

Specified by:
getChildren in interface TreeModel<T extends TreeModel>
Returns:
the children

getParent

public T getParent()
Returns the model's parent or null if no parent.

Specified by:
getParent in interface TreeModel<T extends TreeModel>
Returns:
the parent

indexOf

public int indexOf(T child)
Description copied from interface: TreeModel
Returns the index of the child.

Specified by:
indexOf in interface TreeModel<T extends TreeModel>
Parameters:
child - the child
Returns:
the index

insert

public void insert(T child,
                   int index)
Inserts a child to the model and fires an ChangeEventSource.Add event.

Specified by:
insert in interface TreeModel<T extends TreeModel>
Parameters:
child - the child to be inserted
index - the location to insert the child

isLeaf

public boolean isLeaf()
Description copied from interface: TreeModel
Returns true if the model is a leaf and has children. The method provides the ability to mark a model as having children before the children have been added.

Specified by:
isLeaf in interface TreeModel<T extends TreeModel>
Returns:
true for leaf

notify

public void notify(ChangeEvent evt)
Description copied from interface: ChangeEventSource
Notifies listeners of the given change event.

Specified by:
notify in interface ChangeEventSource
Overrides:
notify in class BaseModel
Parameters:
evt - the change event

remove

public void remove(int index)
Removes the child at the given index.

Parameters:
index - the child index

remove

public void remove(T child)
Removes the child from the model and fires a ChangeEventSource.Remove event.

Specified by:
remove in interface TreeModel<T extends TreeModel>
Parameters:
child - the child to be removed

removeAll

public void removeAll()
Description copied from interface: TreeModel
Removes all the children.

Specified by:
removeAll in interface TreeModel<T extends TreeModel>

setChildren

public void setChildren(java.util.List<T> children)
Sets the model's children. All existing children are first removed.

Parameters:
children - the children to be set

setParent

public void setParent(T parent)
Description copied from interface: TreeModel
Sets the model's parent.

Specified by:
setParent in interface TreeModel<T extends TreeModel>
Parameters:
parent - the new parent