com.sri.emo.controller
Class TreeViewVisitor

java.lang.Object
  extended by com.sri.emo.controller.TreeViewVisitor
All Implemented Interfaces:
ModelVisitor, TreeTraversalListener

public class TreeViewVisitor
extends Object
implements ModelVisitor, TreeTraversalListener

TreeView Visitor transforms the model tree into a unified hiearchial tree that TreeMenuTag can understand for rendering a javascript tree.

Design-wise, it is useful because it separates all the view from the model: the tree model knows nothing about stylesheets, current URLs, etc

This visitor is slightly different from the GoF pattern in that it is reponsible for traversing the data structure and maintaining its own state while traversing, although for clarification, the ModelNode provides an Iterator that is used.

Author:
Michael Rimov

Field Summary
(package private) static String EMPTY_NODE_CLOSED
          CSS Style: un-completed node de-selected.
(package private) static String EMPTY_NODE_OPEN
          CSS Style: un-completed node selected.
(package private) static String EMPTY_SLOT_SELECTED
          CSS Style: multiple attribute not filled out selected.
(package private) static String EMPTY_SLOT_UNSELECTED
          CSS Style: multiple attribute not filled out unselected.
(package private) static String FILLED_NODE_CLOSED
          CSS Style: Completed Node de-selected.
(package private) static String FILLED_NODE_OPEN
          CSS Style: Completed Node selected.
(package private) static String FILLED_SLOT_CLOSED
          CSS Style: multiple attribute completed unselected.
(package private) static String FILLED_SLOT_SELECTED
          CSS Style: multiple attribute completed selected.
(package private) static String PARTIAL_NODE_CLOSED
          CSS Style: Partially-completed node de-selected.
(package private) static String PARTIAL_NODE_OPEN
          CSS Style: Partially-completed node selected.
(package private) static String PARTIAL_SLOT_CLOSED
          CSS Style: multiple attribute partially filled unselected.
(package private) static String PARTIAL_SLOT_OPEN
          CSS Style: multiple attribute partially filled selected.
(package private) static String SINGLE_SELECTED
          CSS Style: single attribute selected.
(package private) static String SINGLE_UNSELECTED
          CSS Style: single attribute unselected.
(package private) static String TRUNCATED_STYLE
          CSS Style: Truncated nodes
(package private)  DefaultTreeNode viewRoot
          The root of the 'view tree' we're building.
 
Fields inherited from interface com.sri.emo.dbobj.model_tree.TreeTraversalListener
NULL_LISTENER
 
Constructor Summary
TreeViewVisitor(ExpressoResponse response)
          Default constructor.
 
Method Summary
 void ascendModelTree(ModelNode newCurrentNode)
          Registers a pop back up the tree.
 void descendModelTree(ModelNode newCurrentNode)
          Registers descending through the tree.
 ExpressoResponse getControllerResponse()
           
 ModelNode getCurrentModelNode()
           
 TreeNode getTree()
          Retrieve the tree that is suitable for viewing.that has been built.
 void setCurrentModelNode(ModelNode nextModelNode)
           
 TreeNode traverseModelTree(Model modelToTraverse)
          Traverse the model tree.
 void visitAttribute(Attribute dataAttribute)
          Visits an attribute.
 void visitNode(Node dataNode)
          Visits a Node.
 void visitNodeType(NodeType nodeType)
          Visits a node type.
 void visitPart(Part part)
          Populates the view with a Part (or Slot)
 void visitPickList(PickList picklist)
          Visits a picklist.
 void visitRelation(Relation relation)
          Visits a Relation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILLED_NODE_OPEN

static final String FILLED_NODE_OPEN
CSS Style: Completed Node selected.

See Also:
Constant Field Values

FILLED_NODE_CLOSED

static final String FILLED_NODE_CLOSED
CSS Style: Completed Node de-selected.

See Also:
Constant Field Values

PARTIAL_NODE_OPEN

static final String PARTIAL_NODE_OPEN
CSS Style: Partially-completed node selected.

See Also:
Constant Field Values

PARTIAL_NODE_CLOSED

static final String PARTIAL_NODE_CLOSED
CSS Style: Partially-completed node de-selected.

See Also:
Constant Field Values

EMPTY_NODE_OPEN

static final String EMPTY_NODE_OPEN
CSS Style: un-completed node selected.

See Also:
Constant Field Values

EMPTY_NODE_CLOSED

static final String EMPTY_NODE_CLOSED
CSS Style: un-completed node de-selected.

See Also:
Constant Field Values

SINGLE_SELECTED

static final String SINGLE_SELECTED
CSS Style: single attribute selected.

See Also:
Constant Field Values

SINGLE_UNSELECTED

static final String SINGLE_UNSELECTED
CSS Style: single attribute unselected.

See Also:
Constant Field Values

FILLED_SLOT_SELECTED

static final String FILLED_SLOT_SELECTED
CSS Style: multiple attribute completed selected.

See Also:
Constant Field Values

FILLED_SLOT_CLOSED

static final String FILLED_SLOT_CLOSED
CSS Style: multiple attribute completed unselected.

See Also:
Constant Field Values

EMPTY_SLOT_SELECTED

static final String EMPTY_SLOT_SELECTED
CSS Style: multiple attribute not filled out selected.

See Also:
Constant Field Values

EMPTY_SLOT_UNSELECTED

static final String EMPTY_SLOT_UNSELECTED
CSS Style: multiple attribute not filled out unselected.

See Also:
Constant Field Values

PARTIAL_SLOT_OPEN

static final String PARTIAL_SLOT_OPEN
CSS Style: multiple attribute partially filled selected.

See Also:
Constant Field Values

PARTIAL_SLOT_CLOSED

static final String PARTIAL_SLOT_CLOSED
CSS Style: multiple attribute partially filled unselected.

See Also:
Constant Field Values

TRUNCATED_STYLE

static final String TRUNCATED_STYLE
CSS Style: Truncated nodes

See Also:
Constant Field Values

viewRoot

DefaultTreeNode viewRoot
The root of the 'view tree' we're building.

Constructor Detail

TreeViewVisitor

public TreeViewVisitor(ExpressoResponse response)
Default constructor.

Parameters:
response - The ControllerResponse object for use in building Transitions.
Method Detail

getTree

public TreeNode getTree()
Retrieve the tree that is suitable for viewing.that has been built.

Returns:
TreeNode

visitAttribute

public void visitAttribute(Attribute dataAttribute)
Visits an attribute.

Specified by:
visitAttribute in interface ModelVisitor
Parameters:
dataAttribute - Attribute

visitNode

public void visitNode(Node dataNode)
Visits a Node. Creates a new level inside the tree for each node visited.

Specified by:
visitNode in interface ModelVisitor
Parameters:
dataNode - Node

visitNodeType

public void visitNodeType(NodeType nodeType)
Visits a node type. In this case, we don't create any view for the node types we encounter in the model so we do nothing.

Specified by:
visitNodeType in interface ModelVisitor
Parameters:
nodeType - NodeType
Throws:
ViewVisitorException - upon error.

visitPart

public void visitPart(Part part)
Populates the view with a Part (or Slot)

Specified by:
visitPart in interface ModelVisitor
Parameters:
part - Part
Throws:
ViewVisitorException - upon error.

visitPickList

public void visitPickList(PickList picklist)
Visits a picklist.

Specified by:
visitPickList in interface ModelVisitor
Parameters:
picklist - PickList

visitRelation

public void visitRelation(Relation relation)
Description copied from interface: ModelVisitor
Visits a Relation

Specified by:
visitRelation in interface ModelVisitor
Parameters:
relation - Relation
Throws:
ViewVisitorException - upon error.

traverseModelTree

public TreeNode traverseModelTree(Model modelToTraverse)
Traverse the model tree.

Parameters:
modelToTraverse - Model
Returns:
TreeNode

descendModelTree

public void descendModelTree(ModelNode newCurrentNode)
Registers descending through the tree. In this case, a signal that the next node coming should be a child.

Specified by:
descendModelTree in interface TreeTraversalListener
Parameters:
newCurrentNode - the new current node in the model that the iterator has descended to.

ascendModelTree

public void ascendModelTree(ModelNode newCurrentNode)
Registers a pop back up the tree.

Specified by:
ascendModelTree in interface TreeTraversalListener
Parameters:
newCurrentNode - the new current model node that the iterator as popped up to.

getCurrentModelNode

public ModelNode getCurrentModelNode()

setCurrentModelNode

public void setCurrentModelNode(ModelNode nextModelNode)

getControllerResponse

public ExpressoResponse getControllerResponse()


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.