ITPElement

An ITPElement represents a node in the tree, which knows both its parent and its children. It has a unique id and holds a class type, an info structure and a collection of associated screen elements. It supports asynchronous initialization. It can deal with messages that bubble up and are broadcasted down the tree.

constructor

ITPElement(pInfo)

Simple initialization of local variables.

public methods

getId()

Returns the elementid from the info structure.

getType()

Returns the class type. Class types should reflect the class hierarchy, by listing all ancestor classes, separated by a dot e.g., ITPElement.ITPRootElement.ITPPage.

ofType(pType)

Returns whether the object is of the class type pType, or of a descendant type.

getInfo()

Returns the info structure.

initialize(pCallback, pSuppressImmediateCallback)

Initializes the object by calling initScreenElements, registering pCallback as the callback method. For ITPElement, which does not have any asynchronous initialization, the callback method is called immediately, unless pSuppressImmediateCallback equals true.

other methods

synchronize()

Triggers sending of all messages that may be relevant to other nodes in the tree. To be overridden in descendant classes.

registerParent(pElement)

Associates the node with parent node pElement, which should be a descendant of ITPElement.

registerChild(pElement)

Associates the node with child node pElement, which should be a descendant of ITPElement.

getDescendant(pId, pRequiredType)

Returns a node from the subtrees defined by the children of the current node if it has the object id equal to pId and if it is of type pRequiredType. Returns null if such a node cannot be found.

bubbleUp(pMessage)

Passes the message pMessage on to the parent of the current node, if the current node has been associated with a parent and allowBubbleUp(pMessage) returns true. Calls broadcastDown(pMessage) otherwise.

broadcastDown(pMessage)

Calls processMessage(pMessage), before calling broadcastDown(pMessage) for each of the associated children. Note that processMessage may tag the message to "shouldStop()", in which case the broadcasting will be aborted.

allowBubbleUp(pMessage)

Returns whether the message is allowed to be bubbled up. Can be used to limit the range of a message to a subtree. To be overridden in descendant classes.

processMessage(pMessage)

Is called for each message that is broadcasted through the node. Should return pMessage, possibly after modifying it. Can be used to respond to messages. To be overridden in descendant classes.

initScreenElements()

Returns a collection of screen elements, which will be stored in the attribute screenelements of the object. Is called as a first step in the initialization process.