org.gnu.gtk
Class TreeStore

java.lang.Object
  extended byorg.gnu.glib.GObject
      extended byorg.gnu.gtk.TreeModel
          extended byorg.gnu.gtk.TreeStore
All Implemented Interfaces:
TreeDragDest, TreeDragSource, TreeSortable

public class TreeStore
extends TreeModel
implements TreeSortable, TreeDragDest, TreeDragSource

The TreeStore is a Model used for storing data which will be displayed in any number of TreeView widgets. For an overview of how the tree and list objects fit together, see the TreeView description.

Data is stored within this object in DataColumns. This data is displayed in the widgets via CellRenderer's; the mapping between this data and the cell renderers of each treeview column is done in the TreeViewColumn class.


Field Summary
 
Fields inherited from class org.gnu.glib.GObject
eventsInitialized
 
Constructor Summary
TreeStore(DataColumn[] dataColumns)
          Constructs a new TreeStore, defining the types for each datablock.
 
Method Summary
 TreeIter appendRow(TreeIter parent)
          Appends a new row to tree_store.
 void clear()
          Removes all items from the treestore.
 int getIteratorDepth(TreeIter iter)
          Returns the depth of the iterator.
 DataColumn getSortColumn()
          Get a DataColumn object representing the currently sorted column.
 SortType getSortOrder()
          Get the current sorting order of the store.
static Type getType()
          Retrieve the runtime type used by the GLib library.
protected static Handle gtk_tree_store_append(Handle treeStore, Handle parent)
           
protected static void gtk_tree_store_clear(Handle treeStore)
           
protected static int gtk_tree_store_get_type()
           
protected static Handle gtk_tree_store_insert_after(Handle treeStore, Handle parent, Handle sibling)
           
protected static Handle gtk_tree_store_insert_before(Handle treeStore, Handle parent, Handle sibling)
           
protected static Handle gtk_tree_store_insert(Handle treeStore, Handle parent, int position)
           
protected static boolean gtk_tree_store_is_ancestor(Handle treeStore, Handle iter, Handle descendant)
           
protected static int gtk_tree_store_iter_depth(Handle treeStore, Handle iter)
           
protected static boolean gtk_tree_store_iter_is_valid(Handle treeStore, Handle iter)
           
protected static void gtk_tree_store_move_after(Handle treeStore, Handle iter, Handle position)
           
protected static void gtk_tree_store_move_before(Handle treeStore, Handle iter, Handle position)
           
protected static Handle gtk_tree_store_newv(int numColumns, int[] types)
           
protected static Handle gtk_tree_store_prepend(Handle treeStore, Handle parent)
           
protected static void gtk_tree_store_remove(Handle treeStore, Handle iter)
           
protected static void gtk_tree_store_reorder(Handle treeStore, Handle iter, int[] newOrder)
           
protected static void gtk_tree_store_set_column_types(Handle treeStore, int numColumns, int[] types)
           
protected static void gtk_tree_store_set_value(Handle treeStore, Handle iter, int columnt, Handle value)
           
protected static void gtk_tree_store_swap(Handle treeStore, Handle iterA, Handle iterB)
           
 int handleCompareFunc(Handle model, Handle aIter, Handle bIter, int col)
          Call-back method invoked by the JNI code when sorting is required.
 TreeIter insertRow(TreeIter parent, int position)
          Creates a new row at position.
 TreeIter insertRowAfter(TreeIter sibling, TreeIter parent)
          Inserts a new row after sibling.
 TreeIter insertRowBefore(TreeIter sibling, TreeIter parent)
          Inserts a new row before sibling.
 boolean isAncestor(TreeIter iter, TreeIter descendant)
          Returns TRUE if iter is an ancestor of descendant.
 boolean isIterValid(TreeIter iter)
           
 void moveRowAfter(TreeIter iter, TreeIter position)
          Moves iter in this store to the position after position.
 void moveRowBefore(TreeIter iter, TreeIter position)
          Moves iter in tree_store to the position before position.
 void moveRowToEnd(TreeIter iter)
          Moves iter to the end of the model
 void moveRowToStart(TreeIter iter)
          Moves iter in this store to the start of the store.
 TreeIter prependRow(TreeIter parent)
          Prepends a new row to the store.
 void removeRow(TreeIter iter)
          Removes a row from the tree store.
 void reorder(TreeIter iter, int[] newOrder)
           
 void setColumnTypes(DataColumn[] dataColumns)
           
 void setDragDestListener(TreeDragDestListener listener)
           
 void setDragSourceListener(TreeDragSourceListener listener)
           
 void setSortColumn(DataColumn column, SortType order)
          Set the column in the list to sort on.
 void setSortMethod(TreeIterComparison method, DataColumn column)
          Set the class used to sort the list according to the values stored in the given DataColumn.
 void setValue(TreeIter iter, DataColumnBoolean dataBlock, boolean value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnDouble dataBlock, double value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnIconSize dataBlock, IconSize value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnInt dataBlock, int value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnObject dataBlock, java.lang.Object value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnPixbuf dataBlock, Pixbuf value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnStockItem dataBlock, GtkStockItem value)
          Sets a value in the dataStore.
 void setValue(TreeIter iter, DataColumnString dataBlock, java.lang.String value)
          Sets a value in the dataStore.
 void swapRows(TreeIter a, TreeIter b)
          Swaps a and b in the same level of tree_store.
 
Methods inherited from class org.gnu.gtk.TreeModel
addListener, findListener, fireTreeModelEvent, getDataBlockCount, getEventListenerClass, getEventType, getFirstIter, getIter, getIter, getType, getValue, getValue, getValue, getValue, getValue, gtk_tree_model_get_column_type, gtk_tree_model_get_iter_first, gtk_tree_model_get_iter_from_string, gtk_tree_model_get_iter, gtk_tree_model_get_n_columns, gtk_tree_model_get_path, gtk_tree_model_get_string_from_iter, gtk_tree_model_get_value, gtk_tree_model_iter_children, gtk_tree_model_iter_has_child, gtk_tree_model_iter_n_children, gtk_tree_model_iter_next, gtk_tree_model_iter_nth_child, gtk_tree_model_iter_parent, removeListener
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, equals, freezeNotify, getBooleanProperty, getData, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getHandle, getIntFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getNullHandle, getPixbufProperty, getProperty, getStringFromHandle, getStringProperty, hashCode, hasProperty, instantiateJGObjectFromGType, notify, removeEventHandler, removeListener, retrieveGObject, setBooleanProperty, setData, setData, setDoubleProperty, setFloatProperty, setHandle, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gnu.gtk.TreeSortable
getHandle
 

Constructor Detail

TreeStore

public TreeStore(DataColumn[] dataColumns)
Constructs a new TreeStore, defining the types for each datablock. Subsequent setting of data to any of the datablocks must follow the types you set out here.

Parameters:
dataColumns - Types for the data to be stored in the TreeStore.
Method Detail

setColumnTypes

public void setColumnTypes(DataColumn[] dataColumns)

setValue

public void setValue(TreeIter iter,
                     DataColumnString dataBlock,
                     java.lang.String value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataColumnStockItem dataBlock,
                     GtkStockItem value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataColumnIconSize dataBlock,
                     IconSize value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataColumnInt dataBlock,
                     int value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataColumnBoolean dataBlock,
                     boolean value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataColumnDouble dataBlock,
                     double value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

setValue

public void setValue(TreeIter iter,
                     DataColumnObject dataBlock,
                     java.lang.Object value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data, starting at 0.
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set. This must match the type for that dataBlock, as set in the constructor.

setValue

public void setValue(TreeIter iter,
                     DataColumnPixbuf dataBlock,
                     Pixbuf value)
Sets a value in the dataStore. The type of the value must match the type set for that dataBlock in the constructor.

This does not make the data visible in any of the widgets which use the class - to do that, you have to construct a TreeViewColumn and add it to the TreeView; construct and add a CellRenderer to that; and finally associate the properties of the CellRenderer with the dataBlocks, using the TreeViewColumn.addAttributeMapping(CellRenderer, CellRendererAttribute, DataColumn) method. @param dataBlock The datablock in which the data should be stored.

Parameters:
dataBlock - The data block in which to store the data, starting at 0.
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow(TreeIter).
value - The value to be set.

removeRow

public void removeRow(TreeIter iter)
Removes a row from the tree store. After being removed, iter is set to the next valid row at that level, or invalidated if it previously pointed to the last one.

Parameters:
iter - TreeIter representing the row.

insertRow

public TreeIter insertRow(TreeIter parent,
                          int position)
Creates a new row at position. If parent is non-NULL, then the row will be made a child of parent. Otherwise, the row will be created at the toplevel. If position is larger than the number of rows at that level, then the new row will be inserted to the end of the list.

Parameters:
parent - A valid TreeIter, or NULL
position - Position to insert the new row
Returns:
Iterator for the new row

insertRowBefore

public TreeIter insertRowBefore(TreeIter sibling,
                                TreeIter parent)
Inserts a new row before sibling. If sibling is NULL, then the row will be appended to parent 's children. If parent and sibling are NULL, then the row will be appended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional

Parameters:
parent - A valid TreeIter, or NULL
sibling - A valid TreeIter, or NULL
Returns:
Iterator for the new row.

insertRowAfter

public TreeIter insertRowAfter(TreeIter sibling,
                               TreeIter parent)
Inserts a new row after sibling. If sibling is NULL, then the row will be prepended to the beginning of the parent 's children. If parent and sibling are NULL, then the row will be prepended to the toplevel. If both sibling and parent are set, then parent must be the parent of sibling. When sibling is set, parent is optional.

Parameters:
parent - A valid TreeIter, or NULL
sibling - A valid GtkTreeIter, or NULL
Returns:
Iterator for the new row.

prependRow

public TreeIter prependRow(TreeIter parent)
Prepends a new row to the store. If parent is non-NULL, then it will prepend the new row before the first child of parent, otherwise it will prepend a row to the top level.

Parameters:
parent - A valid TreeIter, or NULL
Returns:
Iterator for the new row.

appendRow

public TreeIter appendRow(TreeIter parent)
Appends a new row to tree_store. If parent is non-NULL, then it will append the new row after the last child of parent, otherwise it will append a row to the top level.

Parameters:
parent - A valid TreeIter, or NULL
Returns:
Iterator for the new row.

isAncestor

public boolean isAncestor(TreeIter iter,
                          TreeIter descendant)
Returns TRUE if iter is an ancestor of descendant. That is, iter is the parent (or grandparent or great-grandparent) of descendant.

Parameters:
iter - Row to be tested.
descendant - Descendant row for testing
Returns:
True of iter is an ancestor of descendant

getIteratorDepth

public int getIteratorDepth(TreeIter iter)
Returns the depth of the iterator. This will be 0 for anything on the root level, 1 for anything down a level, etc.

Parameters:
iter - The iterator to test the depth of
Returns:
Depth of the iterator.

clear

public void clear()
Removes all items from the treestore.


getType

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


setSortColumn

public void setSortColumn(DataColumn column,
                          SortType order)
Set the column in the list to sort on.

Specified by:
setSortColumn in interface TreeSortable

getSortColumn

public DataColumn getSortColumn()
Get a DataColumn object representing the currently sorted column. This is not the same DataColumn used to create the store. It is only of type DataColumn (not DataColumnString, etc). It can be compared with another DataColumn object using the DataColumn.equals(org.gnu.gtk.DataColumn) method.

Specified by:
getSortColumn in interface TreeSortable
Returns:
A DataColumn object representing the currently sorted column or null if there is no column currently sorted.

getSortOrder

public SortType getSortOrder()
Get the current sorting order of the store.

Specified by:
getSortOrder in interface TreeSortable
Returns:
A SortType object defining the current sorting order of the store or null if there is no current sort order.

setSortMethod

public void setSortMethod(TreeIterComparison method,
                          DataColumn column)
Set the class used to sort the list according to the values stored in the given DataColumn.

Specified by:
setSortMethod in interface TreeSortable

handleCompareFunc

public int handleCompareFunc(Handle model,
                             Handle aIter,
                             Handle bIter,
                             int col)
Call-back method invoked by the JNI code when sorting is required. This is for internal use only.

Specified by:
handleCompareFunc in interface TreeSortable

setDragDestListener

public void setDragDestListener(TreeDragDestListener listener)
Specified by:
setDragDestListener in interface TreeDragDest

setDragSourceListener

public void setDragSourceListener(TreeDragSourceListener listener)
Specified by:
setDragSourceListener in interface TreeDragSource

swapRows

public void swapRows(TreeIter a,
                     TreeIter b)
Swaps a and b in the same level of tree_store. Note that this function only works with unsorted stores.

Since:
2.2

moveRowToEnd

public void moveRowToEnd(TreeIter iter)
Moves iter to the end of the model

Since:
2.2

moveRowAfter

public void moveRowAfter(TreeIter iter,
                         TreeIter position)
Moves iter in this store to the position after position. iter and position should be in the same level. Note that this function only works with unsorted stores.

Since:
2.2

moveRowToStart

public void moveRowToStart(TreeIter iter)
Moves iter in this store to the start of the store.

Since:
2.2

moveRowBefore

public void moveRowBefore(TreeIter iter,
                          TreeIter position)
Moves iter in tree_store to the position before position. iter and position should be in the same level. Note that this function only works with unsorted stores.

Since:
2.2

isIterValid

public boolean isIterValid(TreeIter iter)

reorder

public void reorder(TreeIter iter,
                    int[] newOrder)

gtk_tree_store_get_type

protected static final int gtk_tree_store_get_type()

gtk_tree_store_newv

protected static final Handle gtk_tree_store_newv(int numColumns,
                                                  int[] types)

gtk_tree_store_set_column_types

protected static final void gtk_tree_store_set_column_types(Handle treeStore,
                                                            int numColumns,
                                                            int[] types)

gtk_tree_store_set_value

protected static final void gtk_tree_store_set_value(Handle treeStore,
                                                     Handle iter,
                                                     int columnt,
                                                     Handle value)

gtk_tree_store_remove

protected static final void gtk_tree_store_remove(Handle treeStore,
                                                  Handle iter)

gtk_tree_store_insert

protected static final Handle gtk_tree_store_insert(Handle treeStore,
                                                    Handle parent,
                                                    int position)

gtk_tree_store_insert_before

protected static final Handle gtk_tree_store_insert_before(Handle treeStore,
                                                           Handle parent,
                                                           Handle sibling)

gtk_tree_store_insert_after

protected static final Handle gtk_tree_store_insert_after(Handle treeStore,
                                                          Handle parent,
                                                          Handle sibling)

gtk_tree_store_prepend

protected static final Handle gtk_tree_store_prepend(Handle treeStore,
                                                     Handle parent)

gtk_tree_store_append

protected static final Handle gtk_tree_store_append(Handle treeStore,
                                                    Handle parent)

gtk_tree_store_is_ancestor

protected static final boolean gtk_tree_store_is_ancestor(Handle treeStore,
                                                          Handle iter,
                                                          Handle descendant)

gtk_tree_store_iter_depth

protected static final int gtk_tree_store_iter_depth(Handle treeStore,
                                                     Handle iter)

gtk_tree_store_clear

protected static final void gtk_tree_store_clear(Handle treeStore)

gtk_tree_store_iter_is_valid

protected static final boolean gtk_tree_store_iter_is_valid(Handle treeStore,
                                                            Handle iter)

gtk_tree_store_reorder

protected static final void gtk_tree_store_reorder(Handle treeStore,
                                                   Handle iter,
                                                   int[] newOrder)

gtk_tree_store_swap

protected static final void gtk_tree_store_swap(Handle treeStore,
                                                Handle iterA,
                                                Handle iterB)

gtk_tree_store_move_before

protected static final void gtk_tree_store_move_before(Handle treeStore,
                                                       Handle iter,
                                                       Handle position)

gtk_tree_store_move_after

protected static final void gtk_tree_store_move_after(Handle treeStore,
                                                      Handle iter,
                                                      Handle position)