java.mct.MlTree

Component
    Container
        Panel
            MlPanel
                MlGrid
                    MlTree

A Tree is a subclass of the Grid which displays a hierarchical tree with an Image, String, connecting lines and possibly an expand/collapse graphic in the cells of its first column. Each row in the Tree has a position and level which is used to determine its relationship to other rows in the Tree. Rows may be expanded or collapsed by clicking on an expand/collapse graphic or by activating a row with the keyboard. The Tree inherits all the abilities of the Grid, allowing it to contain multiple columns and rows of varying types, heading/footer and fixed rows and columns, interactive row and column resizing, cell borders, etc.

The Tree resources defined below affect its overall layout and appearance. Definitions of resources affecting rows follow the Tree resource definitions.

In addition to the resources shown below, the Tree inherits all the resources of the Grid, including all row, column and cell resources.

Resources

Name                  Type                     Default
connectingLineColor   Color                    #464646
levelSpacing          Integer                  9
plusMinusColor        Color                    #000000

connectingLineColor
The color of the line which is drawn connecting parents, children and siblings in the first column of the Tree.

levelSpacing
The indent in pixels for each level in the Tree.

plusMinusColor
The color of the plus and minus expand/collapse graphics drawn next to parent nodes which may be expanded.

Row Resources

Tree defines the resources in the table below affecting rows. In addition to these row resources, the Tree inherits all the row, column and cell resources which exist in the Grid.

Name                   Type                      Default
rowExpands             Boolean                   false
rowIsExpanded          Boolean                   true
rowLevel               Integer                   0

rowExpands
true if the row may expand (it is a parent) and false otherwise.

rowIsExpanded
true if the row is currently expanded and false otherwise. If this resource is set to false, the Tree will hide all children of this row. Children of this row are determined to be all rows which are of a level greater than this row's until we find the next row which is of this row's level or less (a sibling or parent of this row). Rows are hidden by setting their rowHeight to 0. If this resource is set to true, the Tree will show all children of this row. Rows are shown by setting their rowHeight to 1. The value of this resource has no meaning if rowExpands is false.

rowLevel
The level of the row in the Tree.

Events

Tree posts the following Events:

Event                 Called When
EXPAND_ROW            Row is expanded
COLLAPSE_ROW          Row is collapsed
Each of the above events are posted with an MlTreeEvent object. An MlTreeEvent is an extension of an Event (actually MlGridEvent) which holds additional row and/or column information. Its basic structure is shown below:
    public class MlTreeEvent (extends MlGridEvent)
    {
    public int rowType;
    public int row;
    public int columnType;
    public int column;
    }
In addition to the above events, the Tree will post/receive all MlGrid events for selection, scrolling, editing, etc.

Public Methods

public void addRow(int level, boolean expands, String string)
Adds a row of level to end of the Tree displaying the string passed. If expands is true, the row may be expanded by the user.

public void addRow(int level, boolean expands, boolean isExpanded, int position, Image image, String string)
Adds a row of level to the Tree at position. A position of -1 specifies after the last content row. The image and string will appear in the first cell of the row. The image value may be null, in which case, the default image will be displayed. If expands is true, the row may be expanded by the user. The isExpanded flag indicates if the row is currently expanded (true) or not (false).

public void addRows(MlTreeRowDefinition rows[], int position)
Adds rows to the tree at the given position. A position of -1 specifies after the last content row. The elements of the rows array are defined as:

    public class MlTreeRowDefinition
    {
    public boolean expands;
    public Image image;
    public boolean isExpanded;
    public int level;
    public String string;
    }

public void collapseRow(int row, boolean notify)
Collapses the given row. If notify is true, and the row is currently expanded, a COLLAPSE_ROW event will be posted.

public int countRowChildren(int row)
Returns the number of children of the row passed. The children of a parent row are defined as all rows following the parent row which have a level greater than the parent row until a row with a level equal to or less than the parent row is found.

public void expandRow(int row, boolean notify)
Expands the given row. If notify is true, and the row is currently collapsed, an EXPAND_ROW event will be posted.