org.gnu.gtk
Class TreeModel

java.lang.Object
  |
  +--org.gnu.glib.GObject
        |
        +--org.gnu.gtk.TreeModel
Direct Known Subclasses:
ListStore, TreeStore

public class TreeModel
extends GObject

A generic tree interface for use with TreeView widgets. Internally, the TreeStore and ListStore objects are constructed on top of TreeModels. If you were using the C version of gtk, you would be able to construct other objects like those (although I find no reason for doing so). This object provides a number of useful methods which can be used with either the TreeStore or ListStore.

For a full overview of the tree, list and table widgets, please see the TreeView description.


Method Summary
 int getDataBlockCount()
          Returns the number of data blocks supported by the model
 TreeIter getFirstChild(TreeIter parent)
          Returns an iterator for the first child of the given iterator, or null if the iter has no children.
 TreeIter getFirstIter()
          Returns the iterator at the start of the model (the one at the path "0"), or returns null if the tree is empty.
 TreeIter getIter(java.lang.String pathString)
          Returns a valid iterator pointing to the path represented by pathString, or returns null if the path is invalid.
 TreeIter getIter(TreePath path)
          Returns a valid iterator pointing to path, or null/
 int getIterChildCount(TreeIter iter)
          Returns the number of children that iter has
 TreeIter getNextIter(TreeIter iter)
          Returns the next iter pointing to the node following the TreeIter provided at the same level.
 TreePath getPath(TreeIter iter)
          Returns a newly-created TreePath referenced by iter.
static Type getType()
          Retrieve the runtime type used by the GLib library.
 Type getType(int index)
          Returns the type of the data block.
 boolean getValue(TreeIter iter, DataBlockBoolean dataBlock)
          Returns the Value at the given iter in the specified data block.
 double getValue(TreeIter iter, DataBlockDouble dataBlock)
          Returns the Value at the given iter in the specified data block.
 int getValue(TreeIter iter, DataBlockInt dataBlock)
          Returns the Value at the given iter in the specified data block.
 java.lang.Object getValue(TreeIter iter, DataBlockObject dataBlock)
          Returns the Value at the given iter in the specified data block.
 java.lang.String getValue(TreeIter iter, DataBlockString dataBlock)
          Returns the Value at the given iter in the specified data block.
 boolean iterHasChild(TreeIter iter)
          Returns TRUE if iter has children, FALSE otherwise.
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, equals, getData, getHandle, removeEventHandler, setData
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDataBlockCount

public int getDataBlockCount()
Returns the number of data blocks supported by the model


getType

public Type getType(int index)
Returns the type of the data block.

Parameters:
index - The index of the data block

getIter

public TreeIter getIter(TreePath path)
Returns a valid iterator pointing to path, or null/


getIter

public TreeIter getIter(java.lang.String pathString)
Returns a valid iterator pointing to the path represented by pathString, or returns null if the path is invalid.


getFirstIter

public TreeIter getFirstIter()
Returns the iterator at the start of the model (the one at the path "0"), or returns null if the tree is empty.


getPath

public TreePath getPath(TreeIter iter)
Returns a newly-created TreePath referenced by iter.


getValue

public java.lang.String getValue(TreeIter iter,
                                 DataBlockString dataBlock)
Returns the Value at the given iter in the specified data block.


getValue

public int getValue(TreeIter iter,
                    DataBlockInt dataBlock)
Returns the Value at the given iter in the specified data block.


getValue

public boolean getValue(TreeIter iter,
                        DataBlockBoolean dataBlock)
Returns the Value at the given iter in the specified data block.


getValue

public double getValue(TreeIter iter,
                       DataBlockDouble dataBlock)
Returns the Value at the given iter in the specified data block.


getValue

public java.lang.Object getValue(TreeIter iter,
                                 DataBlockObject dataBlock)
Returns the Value at the given iter in the specified data block.


getNextIter

public TreeIter getNextIter(TreeIter iter)
Returns the next iter pointing to the node following the TreeIter provided at the same level. If there is no next iter it will return null.

Use this in combination with getFirstIter() to loop through all values in the model.


iterHasChild

public boolean iterHasChild(TreeIter iter)
Returns TRUE if iter has children, FALSE otherwise.


getFirstChild

public TreeIter getFirstChild(TreeIter parent)
Returns an iterator for the first child of the given iterator, or null if the iter has no children.


getIterChildCount

public int getIterChildCount(TreeIter iter)
Returns the number of children that iter has


getType

public static Type getType()
Retrieve the runtime type used by the GLib library.


Please send any bug reports, comments, or suggestions for the API or documentation to java-gnome-developer@lists.sf.net