Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## echopointng
Class TreeTable

    java.lang.Object
      nextapp.echo2.app.Component
          nextapp.echo2.app.Table
              echopointng.table.TableEx
                  echopointng.TreeTable

All Implemented Interfaces:
  Attributeable, java.io.Serializable, RenderIdSupport

    public class TreeTable

extends TableEx

`TreeTable` is a specialized `table` consisting of a single column in which to display hierarchical data, and any number of other columns in which to display regular data.

The interface for the data model used by a `TreeTable` is `TreeTableModel`. It extends the `TreeModel`interface to allow access to cell data by column indices within each node of the tree hierarchy.

The most straightforward way create and use a `TreeTable`, is to first create a suitable data model for it, and pass that to a `TreeTable` constructor

A single treetable model instance may be shared among more than one `TreeTable` instances. To access the treetable model, always call `getTreeTableModel`and `setTreeTableModel`. `TreeTable` wraps the supplied treetable model inside a private adapter class to adapt it to a `TableModel`. Although the model adapter is accessible through the `getModel`method, you should avoid accessing and manipulating it in any way. In particular, each model adapter instance is tightly bound to a single table instance, and any attempt to share it with another table (for example, by calling `setModel`) will throw an `IllegalArgumentException`!

See Also:
  Serialized Form

Field Summary

Fields inherited from class nextapp.echo2.app.Table
`ACTION_LISTENERS_CHANGED_PROPERTY, AUTO_CREATE_COLUMNS_FROM_MODEL_CHANGED_PROPERTY, COLUMN_MODEL_CHANGED_PROPERTY, DEFAULT_HEADER_RENDERER_CHANGED_PROPERTY, DEFAULT_RENDERER_CHANGED_PROPERTY, DEFAULT_TABLE_CELL_RENDERER, HEADER_ROW, HEADER_VISIBLE_CHANGED_PROPERTY, INPUT_ACTION, MODEL_CHANGED_PROPERTY, PROPERTY_ACTION_COMMAND, PROPERTY_BORDER, PROPERTY_INSETS, PROPERTY_ROLLOVER_BACKGROUND, PROPERTY_ROLLOVER_BACKGROUND_IMAGE, PROPERTY_ROLLOVER_ENABLED, PROPERTY_ROLLOVER_FONT, PROPERTY_ROLLOVER_FOREGROUND, PROPERTY_SELECTION_BACKGROUND, PROPERTY_SELECTION_BACKGROUND_IMAGE, PROPERTY_SELECTION_ENABLED, PROPERTY_SELECTION_FONT, PROPERTY_SELECTION_FOREGROUND, PROPERTY_WIDTH, SELECTION_CHANGED_PROPERTY, SELECTION_MODEL_CHANGED_PROPERTY`

Fields inherited from class nextapp.echo2.app.Component
`CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FOCUS_TRAVERSAL_INDEX_CHANGED_PROPERTY, FOCUS_TRAVERSAL_PARTICIPANT_CHANGED_PROPERTY, LAYOUT_DIRECTION_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, PROPERTY_BACKGROUND, PROPERTY_FONT, PROPERTY_FOREGROUND, PROPERTY_LAYOUT_DATA, STYLE_CHANGED_PROPERTY, STYLE_NAME_CHANGED_PROPERTY, VISIBLE_CHANGED_PROPERTY`

Constructor Summary
`TreeTable()` Constructs a TreeTable using a `DefaultTreeTableModel`.
`TreeTable(TreeTableModel treeModel)` Constructs a TreeTable using the specified `TreeTableModel`.

Method Summary
`void` | `collapseAll()` Collapses all nodes in the treetable.
`void` | `collapsePath(TreePath path)` Collapses the node at the specified path in the treetable.
`void` | `collapseRow(int row)` Collapses the row in the treetable.
`void` | `expandAll()` Expands all nodes in the treetable.
`void` | `expandPath(TreePath path)` Expands the the node at the specified path in the treetable.
`void` | `expandRow(int row)` Expands the specified row in the treetable.
`java.util.Enumeration` | `getExpandedDescendants(TreePath parent)` Returns an `Enumeration` of the descendants of the path `parent` that are currently expanded.
`TreePath` | `getPathForRow(int row)` Returns the TreePath for a given row.
`boolean` | `getShowsRootHandles()` Returns the value of the `showsRootHandles` property.
`TreeSelectionModel` | `getTreeSelectionModel()` Returns the selection model for the tree portion of the this treetable.
`TreeTableModel` | `getTreeTableModel()` Returns the underlying TreeTableModel for this TreeTable.
`boolean` | `isCollapsed(int row)` Returns true if the node at the specified display row is collapsed.
`boolean` | `isCollapsed(TreePath path)` Returns true if the node identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.
`boolean` | `isExpanded(int row)` Returns true if the node at the specified display row is currently expanded.
`boolean` | `isExpanded(TreePath path)` Returns true if the node identified by path is currently expanded.
`boolean` | `isHierarchical(int column)` Determines if the specified column contains hierarchical nodes.
`boolean` | `isRootAutoExpanded()` Returns true if the root node of the tree is expanded when the TreeModel is first set.
`boolean` | `isRootVisible()` Returns true if the root node of the tree is displayed.
`boolean` | `isVisible(TreePath path)` Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded.
`void` | `processInput(java.lang.String inputName, java.lang.Object inputValue)` We forward the TreePath input into out internal Tree.
`void` | `setCellRenderer(TreeCellRenderer cellRenderer)` Sets the specified TreeCellRenderer
`void` | `setModel(TableModel tableModel)` Overrides superclass version to make sure that the specified `TableModel`is compatible with TreeTable before invoking the inherited version.
`void` | `setRootAutoExpanded(boolean rootExpanded)` Determines whether or not the root node from the TreeModel is automatically expanded when the model is set into the Tree.
`void` | `setRootVisible(boolean visible)` Determines whether or not the root node from the TreeModel is visible.
`void` | `setSelectionMode(int mode)` Overridden to ensure that private treeAndTableCellRenderer state is kept in sync with the state of the component.
`void` | `setShowsRootHandles(boolean visible)` Sets the value of the `showsRootHandles` property for the tree part.
`void` | `setTreeTableModel(TreeTableModel treeModel)` Sets the data model for this TreeTable to the specified `TreeTableModel`.
`void` | `validate()` A life-cycle method invoked before the component is rendered to ensure it is in a valid state.

Methods inherited from class echopointng.table.TableEx
`getAttribute, getAttributeNames, init, setAttribute`

Methods inherited from class nextapp.echo2.app.Table
`addActionListener, createDefaultColumnsFromModel, doRender, getActionCommand, getBorder, getCellComponent, getColumnModel, getDefaultHeaderRenderer, getDefaultRenderer, getInsets, getModel, getRolloverBackground, getRolloverBackgroundImage, getRolloverFont, getRolloverForeground, getSelectionBackground, getSelectionBackgroundImage, getSelectionFont, getSelectionForeground, getSelectionModel, getWidth, hasActionListeners, invalidate, isAutoCreateColumnsFromModel, isHeaderVisible, isRolloverEnabled, isSelectionEnabled, removeActionListener, setActionCommand, setAutoCreateColumnsFromModel, setBorder, setColumnModel, setDefaultHeaderRenderer, setDefaultRenderer, setHeaderVisible, setInsets, setRolloverBackground, setRolloverBackgroundImage, setRolloverEnabled, setRolloverFont, setRolloverForeground, setSelectionBackground, setSelectionBackgroundImage, setSelectionEnabled, setSelectionFont, setSelectionForeground, setSelectionModel, setWidth`

Methods inherited from class nextapp.echo2.app.Component
`add, add, addPropertyChangeListener, dispose, firePropertyChange, getApplicationInstance, getBackground, getComponent, getComponent, getComponentCount, getComponents, getEventListenerList, getFocusTraversalIndex, getFont, getForeground, getId, getIndexedProperty, getLayoutData, getLayoutDirection, getLocale, getParent, getProperty, getRenderId, getRenderIndexedProperty, getRenderIndexedProperty, getRenderLayoutDirection, getRenderLocale, getRenderProperty, getRenderProperty, getStyle, getStyleName, getVisibleComponent, getVisibleComponentCount, getVisibleComponents, hasEventListenerList, indexOf, isAncestorOf, isEnabled, isFocusTraversalParticipant, isRegistered, isRenderEnabled, isRenderVisible, isValidChild, isValidParent, isVisible, remove, remove, removeAll, removePropertyChangeListener, setBackground, setEnabled, setFocusTraversalIndex, setFocusTraversalParticipant, setFont, setForeground, setId, setIndexedProperty, setLayoutData, setLayoutDirection, setLocale, setProperty, setStyle, setStyleName, setVisible, verifyInput, visibleIndexOf`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TreeTable

    public TreeTable()

  Constructs a TreeTable using a `DefaultTreeTableModel`.

### TreeTable

    public TreeTable(TreeTableModel treeModel)

  Constructs a TreeTable using the specified `TreeTableModel`.

  Parameters:
    `treeModel` - model for the TreeTable

Method Detail

### processInput

    public void processInput(java.lang.String inputName,
                             java.lang.Object inputValue)

  We forward the TreePath input into out internal Tree.

  Overrides:
    `processInput` in class `Table`
  Parameters:
    `inputName` - the name of the input
    `inputValue` - the value of the input
  See Also:
    `Table.processInput(java.lang.String, java.lang.Object)`

### setTreeTableModel

    public void setTreeTableModel(TreeTableModel treeModel)

  Sets the data model for this TreeTable to the specified `TreeTableModel`. The same data model may be shared by any number of TreeTable instances.

  Parameters:
    `treeModel` - data model for this TreeTable

### getTreeTableModel

    public TreeTableModel getTreeTableModel()

  Returns the underlying TreeTableModel for this TreeTable.

  Returns:
    the underlying TreeTableModel for this TreeTable

### setModel

    public final void setModel(TableModel tableModel)

  Overrides superclass version to make sure that the specified `TableModel`is compatible with TreeTable before invoking the inherited version.

  Because TreeTable internally adapts an `TreeTableModel`to make it a compatible TableModel, this method should never be called directly . Use `setTreeTableModel` instead.

  While it is possible to obtain a reference to this adapted version of the TableModel by calling `Table.getModel()`, any attempt to call setModel() with that adapter will fail because the adapter might have been bound to a different TreeTable instance. If you want to extract the underlying TreeTableModel, which, by the way, can be shared, use `getTreeTableModel`instead

  .

  Overrides:
    `setModel` in class `Table`
  Parameters:
    `tableModel` - must be a TreeTableModelAdapter, which general calles will not have access to.
  Throws:
    `java.lang.IllegalArgumentException` - if the specified tableModel is not an instance of TreeTableModelAdapter

### setSelectionMode

    public void setSelectionMode(int mode)

  Overridden to ensure that private treeAndTableCellRenderer state is kept in sync with the state of the component. Calls the inherited version after performing the necessary synchronization. If you override this method, make sure you call this version from your version of this method.

  This version maps the selection mode used by the treeAndTableCellRenderer to match the selection mode specified for the table. Specifically, the modes are mapped as follows:

            ListSelectionModel.SINGLE_SELECTION: TreeSelectionModel.CONTIGUOUS_TREE_SELECTION;
            ListSelectionModel.MULTIPLE__SELECTION: TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION;
            any other (default): TreeSelectionModel.SINGLE_TREE_SELECTION;

  Parameters:
    `mode` - any of the table selection modes

### setCellRenderer

    public void setCellRenderer(TreeCellRenderer cellRenderer)

  Sets the specified TreeCellRenderer

  Parameters:
    `cellRenderer` - to use for rendering tree cells.

### collapseAll

    public void collapseAll()

  Collapses all nodes in the treetable.

### expandAll

    public void expandAll()

  Expands all nodes in the treetable.

### collapsePath

    public void collapsePath(TreePath path)

  Collapses the node at the specified path in the treetable.

  Parameters:
    `path` - path of the node to collapse

### expandPath

    public void expandPath(TreePath path)

  Expands the the node at the specified path in the treetable.

  Parameters:
    `path` - path of the node to expand

### collapseRow

    public void collapseRow(int row)

  Collapses the row in the treetable. If the specified row index is not valid, this method will have no effect.

### expandRow

    public void expandRow(int row)

  Expands the specified row in the treetable. If the specified row index is not valid, this method will have no effect.

### setRootVisible

    public void setRootVisible(boolean visible)

  Determines whether or not the root node from the TreeModel is visible.

  Parameters:
    `visible` - true, if the root node is visible; false, otherwise

### isRootVisible

    public boolean isRootVisible()

  Returns true if the root node of the tree is displayed.

  Returns:
    true if the root node of the tree is displayed

### isVisible

    public boolean isVisible(TreePath path)

  Returns true if the value identified by path is currently viewable, which means it is either the root or all of its parents are expanded. Otherwise, this method returns false.

  Returns:
    true, if the value identified by path is currently viewable; false, otherwise

### isExpanded

    public boolean isExpanded(TreePath path)

  Returns true if the node identified by path is currently expanded. Otherwise, this method returns false.

  Parameters:
    `path` - path
  Returns:
    true, if the value identified by path is currently expanded; false, otherwise

### isExpanded

    public boolean isExpanded(int row)

  Returns true if the node at the specified display row is currently expanded. Otherwise, this method returns false.

  Parameters:
    `row` - row
  Returns:
    true, if the node at the specified display row is currently expanded. false, otherwise

### isCollapsed

    public boolean isCollapsed(TreePath path)

  Returns true if the node identified by path is currently collapsed, this will return false if any of the values in path are currently not being displayed.

  Parameters:
    `path` - path
  Returns:
    true, if the value identified by path is currently collapsed; false, otherwise

### isCollapsed

    public boolean isCollapsed(int row)

  Returns true if the node at the specified display row is collapsed.

  Parameters:
    `row` - row
  Returns:
    true, if the node at the specified display row is currently collapsed. false, otherwise

### getExpandedDescendants

    public java.util.Enumeration getExpandedDescendants(TreePath parent)

  Returns an `Enumeration` of the descendants of the path `parent` that are currently expanded. If `parent` is not currently expanded, this will return `null`. If you expand/collapse nodes while iterating over the returned `Enumeration` this may not return all the expanded paths, or may return paths that are no longer expanded.

  Parameters:
    `parent` - the path which is to be examined
  Returns:
    an `Enumeration` of the descendents of `parent`, or `null` if `parent` is not currently expanded

### getPathForRow

    public TreePath getPathForRow(int row)

  Returns the TreePath for a given row.

  Parameters:
    `row` -
  Returns:
    the `TreePath` for the given row.

### setShowsRootHandles

    public void setShowsRootHandles(boolean visible)

  Sets the value of the `showsRootHandles` property for the tree part. This property specifies whether the node handles should be displayed. If handles are not supported by a particular look and feel, this property may be ignored.

  Parameters:
    `visible` - true, if root handles should be shown; false, otherwise

### getShowsRootHandles

    public boolean getShowsRootHandles()

  Returns the value of the `showsRootHandles` property.

  Returns:
    the value of the `showsRootHandles` property

### isRootAutoExpanded

    public boolean isRootAutoExpanded()

  Returns true if the root node of the tree is expanded when the TreeModel is first set.

### setRootAutoExpanded

    public void setRootAutoExpanded(boolean rootExpanded)

  Determines whether or not the root node from the TreeModel is automatically expanded when the model is set into the Tree.

  By default it is and hence the 2nd child level of the TreeModel will be accessed and shown.

  If this is false, then only the root node will be accessed and displayed when a TreeModel is first set and the Tree is rendered.

### getTreeSelectionModel

    public TreeSelectionModel getTreeSelectionModel()

  Returns the selection model for the tree portion of the this treetable.

  Returns:
    selection model for the tree portion of the this treetable

### isHierarchical

    public boolean isHierarchical(int column)

  Determines if the specified column contains hierarchical nodes.

  Parameters:
    `column` - zero-based index of the column
  Returns:
    true if the class of objects in the specified column implement the `TreeNode`interface; false otherwise.

### validate

    public void validate()

  Description copied from class: `Component`
  A life-cycle method invoked before the component is rendered to ensure it is in a valid state. Default implementation is empty. Overriding implementations should ensure to invoke `super.validate()` out of convention.

  Overrides:
    `validate` in class `Table`
  See Also:
    `Table.validate()`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD