org.gnu.gtk

Class ListStore

Implemented Interfaces:
TreeDragDest, TreeDragSource, TreeSortable

public class ListStore
extends TreeModel
implements TreeSortable, TreeDragSource, TreeDragDest

The ListStore is the gtk Model used for constructing Lists and tables to be displayed within TreeView widgets. For full details of what objects are needed to construct lists and tables, please see the TreeView description.

The list store has a number of DataColumns, or data 'columns' associated with it. These do not correspond to the organisation of the output into columns. The data store can in fact be used with any number of treeView widgets, each displaying a different part of the data. In these Java bindings, we will try to use the term dataBlock for the data in the ListStore and Column to refer to the columns to be displayed. The data to be displayed is set in the TreeViewColumn objects, by associating properties of CellRenderer's with the data block used in this object.

Field Summary

protected HashMap
sortMethods

Fields inherited from class org.gnu.glib.GObject

eventsInitialized

Constructor Summary

ListStore(DataColumn dataColumns)
Constructs a new ListStore object for storing data in a list style manner.

Method Summary

TreeIter
appendRow()
Appends a new row to the store
void
clear()
Removes all rows from the list store.
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_list_store_append(Handle listStore)
protected static void
gtk_list_store_clear(Handle listStore)
protected static int
gtk_list_store_get_type()
protected static Handle
gtk_list_store_insert(Handle listStore, int position)
protected static Handle
gtk_list_store_insert_after(Handle listStore, Handle sibling)
protected static Handle
gtk_list_store_insert_before(Handle listStore, Handle sibling)
protected static boolean
gtk_list_store_iter_is_valid(Handle listStore, Handle iter)
protected static void
gtk_list_store_move_after(Handle listStore, Handle iter, Handle position)
protected static void
gtk_list_store_move_before(Handle listStore, Handle iter, Handle position)
protected static Handle
gtk_list_store_newv(int numColumns, int[] types)
protected static Handle
gtk_list_store_prepend(Handle listStore)
protected static boolean
gtk_list_store_remove(Handle listStore, Handle iter)
protected static void
gtk_list_store_reorder(Handle listStore, int[] newOrder)
protected static void
gtk_list_store_set_column_types(Handle listStore, int numColumns, int[] types)
protected static void
gtk_list_store_set_value(Handle listStore, Handle iter, int column, Handle value)
protected static void
gtk_list_store_swap(Handle listStore, 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(int position)
Creates a new row at position.
TreeIter
insertRowAfter(TreeIter sibling)
Inserts a new row after sibling.
TreeIter
insertRowBefore(TreeIter sibling)
Inserts a new row before sibling.
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 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()
Prepends a new row to list_store.
boolean
removeRow(TreeIter iter)
Removes the given row from the list store.
void
reorder(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 data store.
void
setValue(TreeIter iter, DataColumnDouble dataBlock, double value)
Sets a value in the data store.
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 data store.
void
setValue(TreeIter iter, DataColumnObject dataBlock, 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, String value)
Sets a value in the data store.
void
swapRows(TreeIter a, TreeIter b)
Swaps a and b in the same level of tree_store.
protected void
tree_sortable_set_sort_column_id(Handle sortable, int col, int order)

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, gtk_tree_model_get_iter_first, gtk_tree_model_get_iter_from_string, 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, getEventListenerClass, getEventType, getFloatProperty, getGObjectFromHandle, getHandle, getIntFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getNullHandle, getPixbufProperty, getProperty, getStringFromHandle, getStringProperty, hasProperty, hashCode, instantiateJGObjectFromGType, notify, removeEventHandler, removeListener, retrieveGObject, setBooleanProperty, setData, setData, setDoubleProperty, setFloatProperty, setHandle, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify

Field Details

sortMethods

protected HashMap sortMethods

Constructor Details

ListStore

public ListStore(DataColumn dataColumns)
Constructs a new ListStore object for storing data in a list style manner. The data is stored in a set of numbered data blocks, each one of which can then be displayed in a column by setting the appropriate attribute mapping of the CellRenderers.

Parameters:
dataColumns - a list of dataColumns for the store. These should be created as private variables of the required type - they will be needed later.

Method Details

appendRow

public TreeIter appendRow()
Appends a new row to the store

Returns:
Iterator for the new row


clear

public void clear()
Removes all rows from the list store.


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(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.


getType

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


gtk_list_store_append

protected static final Handle gtk_list_store_append(Handle listStore)


gtk_list_store_clear

protected static final void gtk_list_store_clear(Handle listStore)


gtk_list_store_get_type

protected static final int gtk_list_store_get_type()


gtk_list_store_insert

protected static final Handle gtk_list_store_insert(Handle listStore,
                                                    int position)


gtk_list_store_insert_after

protected static final Handle gtk_list_store_insert_after(Handle listStore,
                                                          Handle sibling)


gtk_list_store_insert_before

protected static final Handle gtk_list_store_insert_before(Handle listStore,
                                                           Handle sibling)


gtk_list_store_iter_is_valid

protected static final boolean gtk_list_store_iter_is_valid(Handle listStore,
                                                            Handle iter)


gtk_list_store_move_after

protected static final void gtk_list_store_move_after(Handle listStore,
                                                      Handle iter,
                                                      Handle position)


gtk_list_store_move_before

protected static final void gtk_list_store_move_before(Handle listStore,
                                                       Handle iter,
                                                       Handle position)


gtk_list_store_newv

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


gtk_list_store_prepend

protected static final Handle gtk_list_store_prepend(Handle listStore)


gtk_list_store_remove

protected static final boolean gtk_list_store_remove(Handle listStore,
                                                     Handle iter)


gtk_list_store_reorder

protected static final void gtk_list_store_reorder(Handle listStore,
                                                   int[] newOrder)


gtk_list_store_set_column_types

protected static final void gtk_list_store_set_column_types(Handle listStore,
                                                            int numColumns,
                                                            int[] types)


gtk_list_store_set_value

protected static final void gtk_list_store_set_value(Handle listStore,
                                                     Handle iter,
                                                     int column,
                                                     Handle value)


gtk_list_store_swap

protected static final void gtk_list_store_swap(Handle listStore,
                                                Handle iterA,
                                                Handle iterB)


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


insertRow

public TreeIter insertRow(int position)
Creates a new row at position. If position is larger than the number of rows on the list, then the new row will be appended to the list.

Parameters:
position - The position to place the new row, starting at 0.

Returns:
Iterator for the new row


insertRowAfter

public TreeIter insertRowAfter(TreeIter sibling)
Inserts a new row after sibling. If sibling is NULL, then the row will be prepended to the beginning of the list. iter will be changed to point to this new row.

Parameters:
sibling -

Returns:
Iterator for the new row.


insertRowBefore

public TreeIter insertRowBefore(TreeIter sibling)
Inserts a new row before sibling. If sibling is NULL, then the row will be appended to the end of the list. iter will be changed to point to this new row.

Parameters:
sibling -

Returns:
Iterator for the new row


isIterValid

public boolean isIterValid(TreeIter iter)


moveRowAfter

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

Since:
2.2


moveRowBefore

public void moveRowBefore(TreeIter iter,
                          TreeIter position)
Moves iter in store to the position before position. The iter and position should be in the same level. 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


moveRowToStart

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

Since:
2.2


prependRow

public TreeIter prependRow()
Prepends a new row to list_store. The iter will be changed to point to this new row. The row will be empty after this function is called.

Returns:
Iterator for the new row


removeRow

public boolean removeRow(TreeIter iter)
Removes the given row from the list store. After being removed, iter is set to be the next valid row, or invalidated if it pointed to the last row in this store.

Parameters:
iter - iterator for the row to be removed.

Returns:
TRUE if iter is valid, FALSE if not.


reorder

public void reorder(int[] newOrder)


setColumnTypes

public void setColumnTypes(DataColumn dataColumns)


setDragDestListener

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


setDragSourceListener

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


setSortColumn

public void setSortColumn(DataColumn column,
                          SortType order)
Set the column in the list to sort on.
Specified by:
setSortColumn in interface TreeSortable


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


setValue

public void setValue(TreeIter iter,
                     DataColumnBoolean dataBlock,
                     boolean value)
Sets a value in the data store. To display the data in the widget, you need to associate the datablock with the renderer, using methods of the TreeViewColumn. appendRow().

Parameters:
iter - A valid iterator which specifies the row in which the data should be set. Iterators can be gained by using methods such as
dataBlock - The data block to store the value in.
value - The value to store. This must be of the same type for the column as that set in the constructor to the ListStore.


setValue

public void setValue(TreeIter iter,
                     DataColumnDouble dataBlock,
                     double value)
Sets a value in the data store. To display the data in the widget, you need to associate the datablock with the renderer, using methods of the TreeViewColumn. appendRow().

Parameters:
iter - A valid iterator which specifies the row in which the data should be set. Iterators can be gained by using methods such as
dataBlock - The data block to store the value in.
value - The value to store.


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:
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow().
dataBlock - The data block in which to store the data
value - The value to be set.


setValue

public void setValue(TreeIter iter,
                     DataColumnInt dataBlock,
                     int value)
Sets a value in the data store. To display the data in the widget, you need to associate the datablock with the renderer, using methods of the TreeViewColumn. appendRow().

Parameters:
iter - A valid iterator which specifies the row in which the data should be set. Iterators can be gained by using methods such as
dataBlock - The data block to store the value in.
value - The value to store. This must be of the same type for the column as that set in the constructor to the ListStore.


setValue

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

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


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

Parameters:
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow().
dataBlock - The datablock in which the data should be stored.
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,
                     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:
iter - Valid iterator for the data row in which the value is to be set. These can be gotten using methods such as appendRow().
dataBlock - The data block in which to store the data
value - The value to be set.


setValue

public void setValue(TreeIter iter,
                     DataColumnString dataBlock,
                     String value)
Sets a value in the data store. To display the data in the widget, you need to associate the datablock with the renderer, using methods of the TreeViewColumn. appendRow().

Parameters:
iter - A valid iterator which specifies the row in which the data should be set. Iterators can be gained by using methods such as
dataBlock - The data block to store the value in.
value - The value to store. This must be of the same type for the column as that set in the constructor to the ListStore.


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


tree_sortable_set_sort_column_id

protected void tree_sortable_set_sort_column_id(Handle sortable,
                                                int col,
                                                int order)