gumbo.visualize.data
Class WholeModel

java.lang.Object
  |
  +--gumbo.util.AbstractDisposable
        |
        +--gumbo.visualize.data.DataModel
              |
              +--gumbo.visualize.data.WholeModel
All Implemented Interfaces:
Disposable, java.io.Serializable
Direct Known Subclasses:
GraphModel, GroupModel, SuperModel

public abstract class WholeModel
extends DataModel

An abstract data model representing a meaningful and self-consistent set of client data suitable for viewing as a whole. This is an important distinction for view layout and display, where all of a model's parts must be considered together, as a complete set.

A whole model is a node in a "whole model tree", and a root node in a "part model tree". The whole model tree contains nested whole models. The part model tree contains nested part models that make up the whole model. Subclasses of whole and part models can impose restrictions on how the trees can be structured.

Version:
$Revision: 1.19 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.
See Also:
Serialized Form

Nested Class Summary
static class WholeModel.GlobalWholeTree
          Global tree used for all whole model tree nodes.
 
Method Summary
protected  void addPartModel(PartModel child)
          Used by subclasses to add a part model as a child in this model's part model tree.
protected  void checkAddPartModel(PartModel child)
          Safely returns if a part model can be added as a child in this model's part model tree.
 void disposeAll()
          Like dispose(), but also recursively disposes any child whole models.
 java.util.List findAllPartModelSubs(java.util.Collection types, java.util.List retVal)
          Convenience method that calls findPartModelSubs on all descendants in this model's whole model tree.
 java.util.List findPartModelSubs(java.util.Collection types, java.util.List retVal)
          Finds descendants in this model's part model tree.
 WholeModel findWholeModelRoot()
          Convenience method for getting the root in this model's whole model tree.
 java.util.List findWholeModelSubs(java.util.Collection types, java.util.List retVal)
          Finds descendants in this model's whole model tree.
 java.util.List findWholeModelSupers(java.util.Collection types, java.util.List retVal)
          Finds ancestors in this model's whole model tree.
abstract  PartModelField.EventOut getAddedPartModelOut()
          Sends the part model after it is added to this whole model.
 Group getPartModelChildren()
          Gets an immutable view of the children of this model in its part model tree.
abstract  PartModelField.EventOut getRemovingPartModelOut()
          Sends the part model before it is removed from this whole model.
 Group getWholeModelChildren()
          Gets an immutable view of the children of this model in its whole model tree.
 WholeModel getWholeModelParent()
          Gets the parent of this model in its whole model tree.
protected  void implDispose()
          Disposes part model children (recursively), and then disposes this model.
protected  void removePartModel(PartModel child)
          Used by subclasses to remove a part model as a child in this model's part model tree, and to dispose it.
 
Methods inherited from class gumbo.visualize.data.DataModel
getClientData, getClientId, initDataModel, setClientData
 
Methods inherited from class gumbo.util.AbstractDisposable
dispose, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getWholeModelParent

public WholeModel getWholeModelParent()
Gets the parent of this model in its whole model tree.

Returns:
The parent model. Null if none (this model is a whole model tree root).

getWholeModelChildren

public Group getWholeModelChildren()
Gets an immutable view of the children of this model in its whole model tree.

Returns:
The children (WholeModel). Never null.

findWholeModelRoot

public WholeModel findWholeModelRoot()
Convenience method for getting the root in this model's whole model tree.

Returns:
The root. Possibly this model. Never null.

findWholeModelSupers

public java.util.List findWholeModelSupers(java.util.Collection types,
                                           java.util.List retVal)
Finds ancestors in this model's whole model tree. The result will include models that are assignable to (instance of) any one of a group of types.

Parameters:
types - Whole model types (Class) to include. If null, all types are included (a normal trace).
retVal - Return value object. The models (WholeModel), possibly including this model. Reflects the relative height of the models in the lineage. Use a SetList for speed. Never null.
Returns:
Reference to retVal. Never null.

findWholeModelSubs

public java.util.List findWholeModelSubs(java.util.Collection types,
                                         java.util.List retVal)
Finds descendants in this model's whole model tree. The result will include models that are assignable to (instance of) any one of a group of types.

Parameters:
types - Part model types (Class) to include. If null, all types are included (a normal trace).
retVal - Return value object. The models (WholeModel), possibly including this model. Reflects the relative depth of the models in the subtree. Use a SetList for speed. Never null.
Returns:
Reference to retVal. Never null.

getPartModelChildren

public Group getPartModelChildren()
Gets an immutable view of the children of this model in its part model tree.

Returns:
The children (PartModel). Never null.

findPartModelSubs

public java.util.List findPartModelSubs(java.util.Collection types,
                                        java.util.List retVal)
Finds descendants in this model's part model tree. The result will include models that are assignable to (instance of) any one of a group of types.

Parameters:
types - Part model types (Class) to include. If null, all types are included (a normal trace).
retVal - Return value object. The models (PartModel), excluding this model. Reflects the relative depth of the models in the subtree. Use a SetList for speed. Never null.
Returns:
Reference to retVal. Never null.

findAllPartModelSubs

public java.util.List findAllPartModelSubs(java.util.Collection types,
                                           java.util.List retVal)
Convenience method that calls findPartModelSubs on all descendants in this model's whole model tree. The result will include part models that are assignable to (instance of) any one of a group of types.

Parameters:
types - Part model types (Class) to include. If null, all types are included (a normal trace).
retVal - Return value object. The models (PartModel). Reflects the relative order and depth of the whole and part models in their subtrees. Use a SetList for speed. Never null.
Returns:
Reference to retVal. Never null.

disposeAll

public void disposeAll()
Like dispose(), but also recursively disposes any child whole models.


getAddedPartModelOut

public abstract PartModelField.EventOut getAddedPartModelOut()
Sends the part model after it is added to this whole model. Never null.


getRemovingPartModelOut

public abstract PartModelField.EventOut getRemovingPartModelOut()
Sends the part model before it is removed from this whole model. Never null.


checkAddPartModel

protected void checkAddPartModel(PartModel child)
Safely returns if a part model can be added as a child in this model's part model tree. To be valid, this model must not be disposed, and child must not be null. Override to add further qualifications.

Parameters:
child - The potential child model. Never null.
Throws:
java.lang.IllegalStateException - This object has been disposed.
java.lang.IllegalArgumentException - Child is null.

addPartModel

protected final void addPartModel(PartModel child)
Used by subclasses to add a part model as a child in this model's part model tree. Must satisfy this node's checkAddPartModel() and the child node's checkParentPartModel() and checkRootPartModel().

Parameters:
child - The model to be added. Never null.
Returns:
Reference to child. Never null.

removePartModel

protected final void removePartModel(PartModel child)
Used by subclasses to remove a part model as a child in this model's part model tree, and to dispose it.

Parameters:
child - The model to be removed. Ignored if null or missing.

implDispose

protected void implDispose()
Disposes part model children (recursively), and then disposes this model.

Overrides:
implDispose in class DataModel