java-gnome version 4.0.19

org.gnome.gtk
Class TreePath

Object
  extended by org.freedesktop.bindings.Pointer
      extended by org.gnome.glib.Boxed
          extended by org.gnome.gtk.TreePath

public final class TreePath
extends Boxed

A logical but abstract representation of a row in a TreeModel. TreePaths can be expressed as Strings.

Paths in ListStores are quite simple. They are a simple number, incrementing from zero, indicating the row number. For example, TreePath("8") is the ninth row in the model.

Paths for TreeStores are more complex. They are of the form "first:second:third:..." where each of first, second, and third denote the number of steps in from the first at each level of the hierarchy. For example, TreePath("2:4:0") represents the first third level element in the fifth second level element in the third row.

TreePaths are given to you as a row address in signals like TreeView.RowActivated. Usually you need the row expressed as a TreeIter (ie to get a value out of the row);to do that call the underlying TreeModel's getIter() method.

Since:
4.0.5
Author:
Andrew Cowie, Stefan Prelle

Constructor Summary
TreePath(String path)
          Create a TreePath object from the String form.
 
Method Summary
 boolean equals(Object other)
          Return true of this TreePath represents the same logical path as the other does.
 int getDepth()
          Returns the depth of node identified by this TreePath within the tree.
 int[] getIndices()
          Returns the indices the path consists of as an array of integer.
 String toString()
          Return the text form represented by this TreePath.
 
Methods inherited from class Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreePath

public TreePath(String path)
Create a TreePath object from the String form. Note that TreePaths are abstract and independent of a particular model; if you want to look up a given path in a TreeModel use the resultant object with its getIter() method.

Throws:
IllegalArgumentException - if the path fails to parse as a valid TreePath.
Method Detail

equals

public boolean equals(Object other)
Return true of this TreePath represents the same logical path as the other does.

Overrides:
equals in class Object

getDepth

public int getDepth()
Returns the depth of node identified by this TreePath within the tree. Or with other words, the number of elements in the TreePath.

Since:
4.0.9

getIndices

public int[] getIndices()
Returns the indices the path consists of as an array of integer. If for example the path would be "1:4:2" you would get {1,4,2}.

Returns:
The indices of the nodes or null if nothing is selected.
Since:
4.0.9

toString

public String toString()
Return the text form represented by this TreePath. For example, a TreePath pointing at the third row's second child row's fifth child row in a TreeStore would be "2:1:4"; the 16th row of a ListStore would be "15".

Overrides:
toString in class org.freedesktop.bindings.Pointer
Since:
4.0.6


java-gnome