com.virtuosotechnologies.lib.basiccommand.builder
Class AbstractBranchBuilderNode

java.lang.Object
  extended bycom.virtuosotechnologies.lib.basiccommand.builder.AbstractBuilderNode
      extended bycom.virtuosotechnologies.lib.basiccommand.builder.AbstractBranchBuilderNode
All Implemented Interfaces:
CommandNodeListener, EventListener, PropertySetListener
Direct Known Subclasses:
AbstractContainerElementBuilderNode, AbstractGroupBuilderNode

public abstract class AbstractBranchBuilderNode
extends AbstractBuilderNode
implements CommandNodeListener

A skeletal implementation for builder nodes with children. Provides accessors for children as well as position finding. Subclasses need to implement createChildNode() to create child nodes corresponding to child CommandNodes. Subclasses also need to implement the add/set/removeElements methods, as well as getCardinality().


Field Summary
 
Fields inherited from class com.virtuosotechnologies.lib.basiccommand.builder.AbstractBuilderNode
END_POSITION
 
Fields inherited from interface com.virtuosotechnologies.lib.command.CommandNodeListener
ALL_CHILDREN_REMOVED_METHOD, CHILD_ADDED_METHOD, CHILD_REMOVED_METHOD
 
Fields inherited from interface com.virtuosotechnologies.lib.container.PropertySetListener
PROPERTYSET_CHANGED_METHOD
 
Constructor Summary
protected AbstractBranchBuilderNode(CommandNode commandNode, AbstractBranchBuilderNode parent, int index)
          Constructor
 
Method Summary
protected abstract  void addElementAt(int pos, Object element)
          Override this to insert a element at a position.
 void allChildrenRemoved(AllChildrenRemovedEvent ev)
          All children removed.
protected  void buildChildren()
          Build children.
 void childAdded(ChildAddedEvent ev)
          Child added.
 void childRemoved(ChildRemovedEvent ev)
          Child removed.
protected abstract  AbstractBuilderNode createChildNode(CommandNode cn, int index)
          Create a child node.
protected  AbstractBuilderNode getChild(CommandNode cn)
          Get a child given a CommandNode
protected  AbstractBuilderNode getChild(int index)
          Get a child given an index
protected  List getChildren()
          Get an unmodifiable view of the list of children
protected  int getNumChildren()
          Get number of children
protected  int getPosition(AbstractBuilderNode child)
          Get the starting position of a particular child
protected  int getPosition(int index)
          Get the starting position at a particular index
protected abstract  void removeAllElements()
          Override this to remove all child elements.
protected  void removeChildElements(AbstractBuilderNode child)
          Helper method that removes elements within the specified child's area of influence (position and cardinality)
protected abstract  void removeElementAt(int pos)
          Override this to remove an indexed element.
protected  void setElementAt(int pos, Object element)
          Override this to set the element at a position.
 
Methods inherited from class com.virtuosotechnologies.lib.basiccommand.builder.AbstractBuilderNode
decGrayLevel, decMaskLevel, disabledStateChanged, dump, getCardinality, getCommandNode, getParent, hiddenStateChanged, incGrayLevel, incMaskLevel, isDisabled, isHidden, propertySetChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBranchBuilderNode

protected AbstractBranchBuilderNode(CommandNode commandNode,
                                    AbstractBranchBuilderNode parent,
                                    int index)
Constructor

Method Detail

buildChildren

protected final void buildChildren()
Build children. Call this from the constructor of nodes that can have children. Assumes that the node has no children to start off.


getPosition

protected final int getPosition(AbstractBuilderNode child)
Get the starting position of a particular child


getPosition

protected final int getPosition(int index)
Get the starting position at a particular index


getChild

protected final AbstractBuilderNode getChild(int index)
Get a child given an index


getChild

protected final AbstractBuilderNode getChild(CommandNode cn)
Get a child given a CommandNode


getNumChildren

protected final int getNumChildren()
Get number of children


getChildren

protected final List getChildren()
Get an unmodifiable view of the list of children


removeChildElements

protected final void removeChildElements(AbstractBuilderNode child)
Helper method that removes elements within the specified child's area of influence (position and cardinality)


createChildNode

protected abstract AbstractBuilderNode createChildNode(CommandNode cn,
                                                       int index)
Create a child node. Return null if no child is to be created.


addElementAt

protected abstract void addElementAt(int pos,
                                     Object element)
Override this to insert a element at a position.


setElementAt

protected void setElementAt(int pos,
                            Object element)
Override this to set the element at a position. Default implementation calls removeElementAt followed by addElementAt.


removeElementAt

protected abstract void removeElementAt(int pos)
Override this to remove an indexed element.


removeAllElements

protected abstract void removeAllElements()
Override this to remove all child elements.


childAdded

public void childAdded(ChildAddedEvent ev)
Child added. Default method creates a child node, which may result in elements being added.

Specified by:
childAdded in interface CommandNodeListener

childRemoved

public void childRemoved(ChildRemovedEvent ev)
Child removed. Default method removes the child node and removes the elements within the child's area of influence.

Specified by:
childRemoved in interface CommandNodeListener

allChildrenRemoved

public void allChildrenRemoved(AllChildrenRemovedEvent ev)
All children removed. Default method removes all children and all elements under this node.

Specified by:
allChildrenRemoved in interface CommandNodeListener