com.extjs.gxt.ui.client.data
Class BaseTreeModel

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
All Implemented Interfaces:
ChangeEventSource, Model, ModelData, TreeModel, java.io.Serializable
Direct Known Subclasses:
TreeStoreModel

public class BaseTreeModel
extends BaseModel
implements TreeModel

Default implementation of the TreeModel interface.

See Also:
Serialized Form

Field Summary
protected  java.util.List<ModelData> children
          The model's children.
protected  TreeModel parent
          The model's parent.
 
Fields inherited from class com.extjs.gxt.ui.client.data.BaseModel
changeEventSupport
 
Fields inherited from class com.extjs.gxt.ui.client.data.BaseModelData
allowNestedValues, map
 
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(TreeModel parent)
          Creates a new model instance.
 
Method Summary
 void add(ModelData child)
          Adds a child to the model and fires an ChangeEventSource.Add event.
 ModelData 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<ModelData> getChildren()
          Returns the model's children.
 TreeModel getParent()
          Returns the model's parent or null if no parent.
 int indexOf(ModelData child)
          Returns the index of the child.
 void insert(ModelData 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(ModelData child)
          Removes the child from the model and fires a ChangeEventSource.Remove event.
 void removeAll()
          Removes all the children.
 void setChildren(java.util.List<ModelData> children)
          Sets the model's children.
 void setParent(TreeModel parent)
          Sets the model's parent.
 
Methods inherited from class com.extjs.gxt.ui.client.data.BaseModel
addChangeListener, addChangeListener, fireEvent, fireEvent, isSilent, notifyPropertyChanged, 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
clone, equals, finalize, 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
 

Field Detail

parent

protected TreeModel parent
The model's parent.


children

protected java.util.List<ModelData> children
The model's children.

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(TreeModel parent)
Creates a new model instance.

Parameters:
parent - the parent
Method Detail

add

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

Specified by:
add in interface TreeModel
Parameters:
child - the child to be added

getChild

public ModelData 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
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
Returns:
the number of children

getChildren

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

Specified by:
getChildren in interface TreeModel
Returns:
the children

getParent

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

Specified by:
getParent in interface TreeModel
Returns:
the parent

indexOf

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

Specified by:
indexOf in interface TreeModel
Parameters:
child - the child
Returns:
the index

insert

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

Specified by:
insert in interface 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
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(ModelData child)
Removes the child from the model and fires a ChangeEventSource.Remove event.

Specified by:
remove in interface 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

setChildren

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

Parameters:
children - the children to be set

setParent

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

Specified by:
setParent in interface TreeModel
Parameters:
parent - the new parent