de.jaret.util.ui.table.model
Class StdHierarchicalTableModel

java.lang.Object
  extended by de.jaret.util.ui.table.model.AbstractJaretTableModel
      extended by de.jaret.util.ui.table.model.StdHierarchicalTableModel
All Implemented Interfaces:
IHierarchicalTableViewStateListener, IJaretTableModel, ITableNodeListener, java.beans.PropertyChangeListener, java.util.EventListener

public class StdHierarchicalTableModel
extends AbstractJaretTableModel
implements IHierarchicalTableViewStateListener, ITableNodeListener, java.beans.PropertyChangeListener

Implementation of a "normal" jaret table model based on a hierarchical jaret table model. The StdHierarchicalmodel will listen on propchanges if the nodes are PropertyObservables.

Version:
$Id: StdHierarchicalTableModel.java 1076 2010-12-05 13:34:42Z kliem $
Author:
Peter Kliem

Field Summary
protected  java.util.List<IColumn> _cols
          the list of columns.
protected  boolean _excludeRootNode
           
protected  IHierarchicalJaretTableModel _hModel
          the hierarchical model this "normal" model maps.
protected  IHierarchicalTableViewState _hvs
          the hierarchical viewstate responsible for node visibility.
protected  java.util.List<ITableNode> _rows
          Current row list = list of visible nodes.
 
Fields inherited from class de.jaret.util.ui.table.model.AbstractJaretTableModel
_listeners
 
Constructor Summary
StdHierarchicalTableModel(IHierarchicalJaretTableModel hModel, IHierarchicalTableViewState hvs)
          Construct a new stdhierarchical table model for a viewstate and a hierarchical model.
 
Method Summary
 void addColumn(IColumn column)
          Add a column to the list of columns.
 IColumn getColumn(int idx)
          Retrieve a column specified by it's index.
 int getColumnCount()
          Retrieve the number of columns.
 boolean getExcludeRootNode()
          Check whether the root node should be excluded.
 ITableNode getNextSibling(ITableNode node)
          Return the next sibling of a node.
 IRow getRow(int rowIdx)
          Retrieve a specific row.
 int getRowCount()
          Return the number of rows in the model.
 boolean isVisible(ITableNode node)
          Check whether a node is visible.
 boolean moreSiblings(ITableNode node, int level)
          Check whether more siblings exist for a given node on a given level.
 void nodeAdded(ITableNode parent, ITableNode newChild)
          Called when a node has been added.
 void nodeExpanded(ITableNode node)
          Node has been expanded.
 void nodeFolded(ITableNode node)
          Node has been folded/collapsed.
 void nodeRemoved(ITableNode parent, ITableNode removedChild)
          Called whenever a node is removed.
 void propertyChange(java.beans.PropertyChangeEvent evt)
          
 void setExcludeRootNode(boolean excludeRootNode)
          Set whether the rot node should be excluded in the display.
 
Methods inherited from class de.jaret.util.ui.table.model.AbstractJaretTableModel
addJaretTableModelListener, fireCellChanged, fireColumnAdded, fireColumnChanged, fireColumnRemoved, fireRowAdded, fireRowChanged, fireRowRemoved, fireTableDataChanged, getColumn, isEditable, removeJaretTableModelListener, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rows

protected java.util.List<ITableNode> _rows
Current row list = list of visible nodes.


_hModel

protected IHierarchicalJaretTableModel _hModel
the hierarchical model this "normal" model maps.


_hvs

protected IHierarchicalTableViewState _hvs
the hierarchical viewstate responsible for node visibility.


_cols

protected java.util.List<IColumn> _cols
the list of columns.


_excludeRootNode

protected boolean _excludeRootNode
Constructor Detail

StdHierarchicalTableModel

public StdHierarchicalTableModel(IHierarchicalJaretTableModel hModel,
                                 IHierarchicalTableViewState hvs)
Construct a new stdhierarchical table model for a viewstate and a hierarchical model.

Parameters:
hModel - hierarchical table model
hvs - hierarchical viewstate
Method Detail

moreSiblings

public boolean moreSiblings(ITableNode node,
                            int level)
Check whether more siblings exist for a given node on a given level.

Parameters:
node - node
level - level
Returns:
true if more siblings exist (even with other parent)

getNextSibling

public ITableNode getNextSibling(ITableNode node)
Return the next sibling of a node.

Parameters:
node - node to get the next sibling for
Returns:
the sibling or null if there is none

isVisible

public boolean isVisible(ITableNode node)
Check whether a node is visible.

Parameters:
node - node to check
Returns:
true if the node is visible

getRow

public IRow getRow(int rowIdx)
Retrieve a specific row.

Specified by:
getRow in interface IJaretTableModel
Parameters:
rowIdx - index of the row
Returns:
the row

getRowCount

public int getRowCount()
Return the number of rows in the model.

Specified by:
getRowCount in interface IJaretTableModel
Returns:
number of rows

nodeAdded

public void nodeAdded(ITableNode parent,
                      ITableNode newChild)
Called when a node has been added.

Specified by:
nodeAdded in interface ITableNodeListener
Parameters:
parent - Parent of the new node.
newChild - the new node.

nodeRemoved

public void nodeRemoved(ITableNode parent,
                        ITableNode removedChild)
Called whenever a node is removed.

Specified by:
nodeRemoved in interface ITableNodeListener
Parameters:
parent - parent of the removed node.
removedChild - the removed node.

nodeExpanded

public void nodeExpanded(ITableNode node)
Node has been expanded.Handle expansion of a node. This means adding all rows that become visible when expanding.

Specified by:
nodeExpanded in interface IHierarchicalTableViewStateListener
Parameters:
node - node that has been expanded.

nodeFolded

public void nodeFolded(ITableNode node)
Node has been folded/collapsed. Handle folding of a node. This means removing all rows that "disappear" with folding.

Specified by:
nodeFolded in interface IHierarchicalTableViewStateListener
Parameters:
node - node that had been folded

getColumnCount

public int getColumnCount()
Retrieve the number of columns.

Specified by:
getColumnCount in interface IJaretTableModel
Returns:
the number of columns.

getColumn

public IColumn getColumn(int idx)
Retrieve a column specified by it's index.

Specified by:
getColumn in interface IJaretTableModel
Parameters:
idx - index of the column to retrieve
Returns:
column at index idx

addColumn

public void addColumn(IColumn column)
Add a column to the list of columns.

Specified by:
addColumn in interface IJaretTableModel
Parameters:
column - column to add

getExcludeRootNode

public boolean getExcludeRootNode()
Check whether the root node should be excluded.

Returns:
true if the root node should be excluded

setExcludeRootNode

public void setExcludeRootNode(boolean excludeRootNode)
Set whether the rot node should be excluded in the display.

Parameters:
excludeRootNode - true to hide the root node

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)

Specified by:
propertyChange in interface java.beans.PropertyChangeListener


Copyright © 2012. All Rights Reserved.