com.virtuosotechnologies.lib.command
Interface CommandNode

All Superinterfaces:
CommandListener, EventListener, ModifiablePropertySet, PropertySet
All Known Implementing Classes:
AbstractCommandNode

public interface CommandNode
extends ModifiablePropertySet, CommandListener

A node in the command graph. Each node has a flavor, which defines the type of node (e.g. simple command, container, etc.) Each node also extends ModifiablePropertySet, which provides other domain-dependent information about the node, such as title, icon, visibility, etc. ComamndNode also extends CommandListener, which defines the actual command operation. Different flavors have different semantics of responding to command invocation. Each node may have an ordered set of children; hence, the nodes are arranged in a directed acyclic graph. Nodes broadcast events when their child set changes. Most implementations will probably want to subclass AbstractCommandNode, which provides default implementations for all methods except commandInvoked() and getFlavor().


Field Summary
 
Fields inherited from interface com.virtuosotechnologies.lib.command.CommandListener
COMMAND_INVOKED_METHOD
 
Method Summary
 void addChild(CommandNode child)
          Add a child node
 void addNodeListener(CommandNodeListener listener)
          Add listener for node hierarchy events
 CommandNodeFlavor getFlavor()
          Get the flavor of CommandNode
 CommandNode getNthChild(int index)
          Get the indexed child
 int getNumChildren()
          Get the number of children
 void insertChild(int index, CommandNode child)
          Insert a child node at the given index
 void removeAllChildren()
          Remove all children
 void removeNodeListener(CommandNodeListener listener)
          Remove listener for node hierarchy events
 void removeNthChild(int index)
          Remove a child node
 
Methods inherited from interface com.virtuosotechnologies.lib.container.ModifiablePropertySet
putValue, resetValue
 
Methods inherited from interface com.virtuosotechnologies.lib.container.PropertySet
addPropertySetListener, getDefaultValue, getValue, removePropertySetListener
 
Methods inherited from interface com.virtuosotechnologies.lib.command.CommandListener
commandInvoked
 

Method Detail

getFlavor

public CommandNodeFlavor getFlavor()
Get the flavor of CommandNode

Returns:
the flavor as a CommandNodeFlavor

addNodeListener

public void addNodeListener(CommandNodeListener listener)
Add listener for node hierarchy events

Parameters:
listener - listener to add

removeNodeListener

public void removeNodeListener(CommandNodeListener listener)
Remove listener for node hierarchy events

Parameters:
listener - listener to remove

addChild

public void addChild(CommandNode child)
Add a child node

Parameters:
child - CommandNode to add

insertChild

public void insertChild(int index,
                        CommandNode child)
Insert a child node at the given index

Parameters:
index - 0-based index indicating where to add the node
child - CommandNode to add
Throws:
IndexOutOfBoundsException - the index was out of bounds

getNthChild

public CommandNode getNthChild(int index)
Get the indexed child

Parameters:
index - 0-based index indicating which child to get
Returns:
child at that index
Throws:
IndexOutOfBoundsException - the index was out of bounds

getNumChildren

public int getNumChildren()
Get the number of children

Returns:
number of children.

removeNthChild

public void removeNthChild(int index)
Remove a child node

Parameters:
index - 0-based index indicating which child to remove
Throws:
IndexOutOfBoundsException - the index was out of bounds

removeAllChildren

public void removeAllChildren()
Remove all children