All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.trumphurst.controls.TTreeListDocument

java.lang.Object
   |
   +----com.trumphurst.controls.TDocument
           |
           +----com.trumphurst.controls.TRowDocument
                   |
                   +----com.trumphurst.controls.TTreeListDocument

public class TTreeListDocument
extends TRowDocument
implements KeyListener
A TRowDocument which contains a list of Tree structures. Note that this is a list of tree structures, not a single tree with one root. It was developed to show message threads in a Usenet News reader.

When an item is double-clicked, the item will be expanded to show its children (or contracted, if it is already expanded).

Perhaps, in a pure Document/View architecture, the expand/ contract functionality would be entirely contained in the view. However, this way of doing things works fine, and enables lists of trees to be displayed by the MultiColumnList without a single change to the code.

See Also:
Tree, TMultiColumnList

Constructor Index

 o TTreeListDocument(String)

Method Index

 o action(int)
The given row has been actioned (double-clicked).
 o addElement(Object, int)
Add an object to the list at the specified row.
 o contract(int)
Contract the given row.
 o expand(int, boolean)
Expand the given row.
 o keyPressed(KeyEvent)
Handle standard list keyboard stuff.
 o keyReleased(KeyEvent)
 o keyTyped(KeyEvent)
 o parentIndex(int)
 o rootIndex(int)

Constructors

 o TTreeListDocument
 public TTreeListDocument(String name)

Methods

 o addElement
 public void addElement(Object item,
                        int index)
Add an object to the list at the specified row. Overrides the base class, in order to check the item being added is a Tree.

Throws: ClassCastException
If the item being added is not an instance of Tree.
Overrides:
addElement in class TRowDocument
 o expand
 public synchronized int expand(int row,
                                boolean children)
Expand the given row.

Parameters:
row - The row to expand.
children - True if the children are also to be expanded recursively.
Returns:
The row number of tha last row added to the list.
 o contract
 public synchronized void contract(int row)
Contract the given row.

Parameters:
row - The row to contract.
 o action
 public void action(int row)
The given row has been actioned (double-clicked). Expands or contracts the row as necessary.

Parameters:
row - The row actioned.
Overrides:
action in class TRowDocument
 o keyPressed
 public void keyPressed(KeyEvent e)
Handle standard list keyboard stuff.

 o keyReleased
 public void keyReleased(KeyEvent e)
 o keyTyped
 public void keyTyped(KeyEvent e)
 o parentIndex
 public synchronized int parentIndex(int row)
 o rootIndex
 public synchronized int rootIndex(int row)

All Packages  Class Hierarchy  This Package  Previous  Next  Index