fri.gui.swing.polytreetable
Class AbstractPolyTreeTableUserObject

java.lang.Object
  |
  +--fri.gui.swing.polytreetable.AbstractPolyTreeTableUserObject
All Implemented Interfaces:
PolyTreeTableUserObject

public abstract class AbstractPolyTreeTableUserObject
extends java.lang.Object
implements PolyTreeTableUserObject

A default PolyTreeTableUserObject that takes arrays as column names and classes and implements most of the static part of the interface: returning column names, column classes and column count. Implement listChildren() and listParents() to fill tree nodes with elements and pass an instance of this class to PolyTreeTable constructor. Implement getColumnObject(int column) to show a node label.

This class provides two lists for buffering children and parents, that get allocated when getChildCount() or getParentCount() is called. The abstract methods listChildren() and listParents() must fill these protected lists. (Mind: they get called just once!)

This userObject is not editable, as isColumnEditable() default returns false. Override it to set the object editable.

Default this object returns true for getAllowsChildren() if getChildCount() is bigger than zero (same for parents).

You need to implement equals() and hashCode(), as these nodes are managed in a Hashtable. Else there will be multiple appearances of one node.


Field Summary
protected  java.util.Vector children
          The children list that gets pre-allocated in getChildCount().
protected  java.lang.Class[] columnClasses
          Classes of columns for PolyTreeTable.
protected  java.lang.String[] columnNames
          Names of columns for PolyTreeTable.
protected  java.util.Vector parents
          The parents list that gets pre-allocated in getParentCount().
 
Constructor Summary
AbstractPolyTreeTableUserObject()
          Construct a userObject for PolyTreeTable that has no column header.
AbstractPolyTreeTableUserObject(java.lang.String[] columnNames, java.lang.Class[] columnClasses)
          Construct a userObject for PolyTreeTable by passing column names and classes, which must be of the same length.
 
Method Summary
 boolean getAllowsChildren()
          Returns true if the receiver allows children, i.e. it is a child "folder".
 boolean getAllowsParents()
          Returns true if the receiver allows parents, i.e. it is a parent "folder".
 java.lang.Object getChildAt(int index)
          Returns the child object at given index of this userObject.
 int getChildCount()
          Allocates a children Vector, calls listChildren() and then returns the number of children list.
 java.lang.Class getColumnClass(int column)
          Returns the class for given column.
 int getColumnCount()
          Returns the number of columns for this userObject.
 java.lang.String getColumnName(int column)
          Returns the name for given column.
 java.lang.Object getParentAt(int index)
          Returns the parent object at given index of this userObject.
 int getParentCount()
          Allocates a parents Vector, calls listParents() and then returns the number of parents list.
 boolean isColumnEditable(int column)
          Returns false: not editable.
protected abstract  void listChildren()
          MUST be overridden to fill a pre-allocated children Vector.
protected abstract  void listParents()
          MUST be overridden to fill a pre-allocated parents Vector.
 java.lang.Object setColumnObject(int column, java.lang.Object aValue)
          Returns "this" Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fri.gui.swing.polytreetable.PolyTreeTableUserObject
getColumnObject
 

Field Detail

columnNames

protected java.lang.String[] columnNames
Names of columns for PolyTreeTable.


columnClasses

protected java.lang.Class[] columnClasses
Classes of columns for PolyTreeTable.


children

protected java.util.Vector children
The children list that gets pre-allocated in getChildCount().


parents

protected java.util.Vector parents
The parents list that gets pre-allocated in getParentCount().

Constructor Detail

AbstractPolyTreeTableUserObject

public AbstractPolyTreeTableUserObject()
Construct a userObject for PolyTreeTable that has no column header.


AbstractPolyTreeTableUserObject

public AbstractPolyTreeTableUserObject(java.lang.String[] columnNames,
                                       java.lang.Class[] columnClasses)
Construct a userObject for PolyTreeTable by passing column names and classes, which must be of the same length.

Method Detail

listChildren

protected abstract void listChildren()
MUST be overridden to fill a pre-allocated children Vector.


listParents

protected abstract void listParents()
MUST be overridden to fill a pre-allocated parents Vector.


isColumnEditable

public boolean isColumnEditable(int column)
Returns false: not editable.

Specified by:
isColumnEditable in interface PolyTreeTableUserObject

setColumnObject

public java.lang.Object setColumnObject(int column,
                                        java.lang.Object aValue)
Returns "this" Object.

Specified by:
setColumnObject in interface PolyTreeTableUserObject
Returns:
new PolyTreeTableUserObject if it had to be changed completely, else "this".

getColumnCount

public int getColumnCount()
Returns the number of columns for this userObject.

Specified by:
getColumnCount in interface PolyTreeTableUserObject

getColumnClass

public java.lang.Class getColumnClass(int column)
Returns the class for given column.

Specified by:
getColumnClass in interface PolyTreeTableUserObject

getColumnName

public java.lang.String getColumnName(int column)
Returns the name for given column.

Specified by:
getColumnName in interface PolyTreeTableUserObject

getChildCount

public int getChildCount()
Allocates a children Vector, calls listChildren() and then returns the number of children list. This method is assumed to be called before getChildAt().

Specified by:
getChildCount in interface PolyTreeTableUserObject

getChildAt

public java.lang.Object getChildAt(int index)
Returns the child object at given index of this userObject.

Specified by:
getChildAt in interface PolyTreeTableUserObject

getAllowsChildren

public boolean getAllowsChildren()
Returns true if the receiver allows children, i.e. it is a child "folder".

Specified by:
getAllowsChildren in interface PolyTreeTableUserObject

getParentCount

public int getParentCount()
Allocates a parents Vector, calls listParents() and then returns the number of parents list. This method is assumed to be called before getParentAt().

Specified by:
getParentCount in interface PolyTreeTableUserObject

getParentAt

public java.lang.Object getParentAt(int index)
Returns the parent object at given index of this userObject.

Specified by:
getParentAt in interface PolyTreeTableUserObject

getAllowsParents

public boolean getAllowsParents()
Returns true if the receiver allows parents, i.e. it is a parent "folder".

Specified by:
getAllowsParents in interface PolyTreeTableUserObject