JTree and JTreeItem methods

 

JTree methods

The JTree class specializes the JUserObject class and defines a tree service.  It contains the following operations:

 

addItem (parentItem : inout JTreeItem,

        label : in String, bitmapName : in String,

        selected : in boolean, index : in integer)

return JTreeItem

This adds a "parentItem" parent node to the JTree, by specifying its label, the name of the associated bitmap (empty string if no bitmap is associated), its selection state and an index (starting at 0) indicating its position in the list of nodes of the same level.

 

addRootItem (label : in String, bitmapName : in String,

              selected : in boolean,

index : in integer)

return JTreeItem

This adds a node to the JTree, under the root, by specifying its label, the name of the associated bitmap (empty string if no bitmap is associated), its selection state and an index indicating its position in the list of nodes of the same level.

 

moveItem (item : inout JTreeItem,

        itemParent : inout JTreeItem,

              index : in integer)

This moves a JTreeItem (item) into another JTreeItem (itemParent).  The index determines at which position the item is inserted in the parent item.

 

getRoot ()

return JTreeItem

This retrieves the root of the JTree.  This node is not displayed in the tree, and cannot, therefore, be a ghost item (for further information, please refer to the JTreeItem method list).  To obtain a list of nodes added to the root, the root can be obtained using this method, and then the list of child nodes (for further information, please refer to the "getChildList" method in the JTreeItem method list).

 

removeItem(itemToRemove : inout JTreeItem)

This deletes from the tree the branch whose root it the "itemToRemove" item.

 

getSelectedItems(itemList : inout SetOfJTreeItem)

This retrieves the set of items selected in the JTree from the "itemList" list.

 

getCallbackItem ()

return JTreeItem

This retrieves the tree item on which a call to a callback has been triggered.

ensureVisible(item : inout JTreeItem,

horizontal : in boolean)

This makes visible the item. Horizontal specify the horizontal item visibility. If horizontal is set to true, the horizontal offset of the item can be modified by this method.

 

 

JTreeItem methods

isSelected ()

return boolean

This returns the selection state of an item.

 

setSelected (selected : in boolean)

This changes an item's selection state.

 

getLabel ()

return String

This returns the label associated with the item.

 

setLabel (label : in String)

This modifies the label associated with the item.

 

getBitmapName ()

return String

This returns the name of the bitmap associated with the item.

 

setBitmap (bitmapName : in String)

This modifies the bitmap associated with the item.

 

getParent ()

return JTreeItem

This retrieves the item's parent node.

 

getChildList(itemList : inout SetOfJTreeItem)

This retrieves from the "itemList" list the set of JTreeItem's child items.

 

getChild (index : in integer)

return JTreeItem

This retrieves the JTreeItem child of the current "index" index.

 

setGhostItem (ghostItem : in boolean)

This is used to state whether or not an item is a ghost item.  A ghost item internally manages a "ghost" child.  The item has a "+" symbol, which is used to trigger a Callback (defined through "setTreeExpandGhostItemCallback").  This can be useful, for example, if the user wishes to build his tree directly.  Once the ghost item has been expanded once by the user, it becomes a "normal" item.

 

isGhostItem ()

return boolean

This returns true if the current item is a ghost item.

 

searchSelectedRecursive (itemList : inout SetOfJTreeItem)

This finds the list of selected JTreeItems.  The search is carried out on the branch defined by the JTreeItem.

 

searchDataRecursive (object : inout Object)

return JTreeItem

This finds the JTreeItem to which the Object given as a parameter is associated.  The search is carried out on the branch defined by the JTreeItem.

 

getIndex ()

return integer

This returns the index corresponding to the position of the item in its branch.

 

expand ()

This triggers the expansion of the branch of the tree defined by the JTreeItem.

 

isExpanded ()

return boolean

This returns true if the branch defined by the JTreeItem is expanded.

 

shrink()

This triggers the reduction of the branch defined by the JTreeItem.