T - The type of the wrapped POJOpublic abstract class CommonNode<T> extends Object implements IPresentationSupport, INotificationSupport, IAttributeSupport
The node factory acts as the "role" in which the POJO wants to be wrapped or seen. This allows a POJO to be seen differently in different usage contexts by simply using another factory (role).
There are two main usage scenarios:
Implement a concrete CommonNode and CommonNodeFactory
subclass to determine node behavior. This results in quick and easy to
understand solution. The drawback is the static behavior - if you want to
change some implementation detail down the hierarchy level you have to create
subclasses according to this change up to the root level to ensure the
changed leaf node factory is used.
The second scenario involves a callback to a strategy object
INodeHandler where the node behavior is encapsulated. This allows for
a more generic node implementation with the drawback of a "instanceof" style
of coding in the callback handler.
ATTR_DESCRIPTION, ATTR_ICON, ATTR_LABEL, ATTR_TIP| Modifier and Type | Method and Description |
|---|---|
void |
addNotificationListener(EventType type,
INotificationListener listener)
Add
listener to the collection of objects to be informed
when the receiver triggers an event of type name. |
Object |
getAttribute(Object key)
Get an attribute value from the context
|
CommonNode<?>[] |
getChildren()
Return all child nodes of this.
|
String |
getDescription()
A long, descriptive string representation.
|
String |
getIconName()
A name for an icon.
|
String |
getLabel()
A short string representation (suitable for example for use with an icon
or menu item).
|
static CommonNode<?> |
getNode(CommonNode<?> parent,
CommonNodeFactory<?> role,
Object object)
Return the node associated with object.
|
INodeHandler |
getNodeHandler() |
T |
getObject()
The object represented by this node.
|
CommonNode<?> |
getParent()
The optional parent node.
|
String |
getTip()
An "intermediate" length description (suitable for example with a
tooltip).
|
boolean |
hasChildren()
true if this node has children. |
Object |
removeAttribute(Object key)
Remove an attribute binding in the context
|
void |
removeNotificationListener(EventType type,
INotificationListener listener)
Remove
listener from the collection of objects to be
informed about events of type name. |
Object |
setAttribute(Object key,
Object value)
Set the value of an attribute in the context
|
void |
setNodeHandler(INodeHandler nodeHandler) |
public static CommonNode<?> getNode(CommonNode<?> parent, CommonNodeFactory<?> role, Object object)
The strategy of associating an object o a node is up to the factory.
parent - role - object - public void addNotificationListener(EventType type, INotificationListener listener)
INotificationSupportlistener to the collection of objects to be informed
when the receiver triggers an event of type name.addNotificationListener in interface INotificationSupporttype - The event type we are interested in.listener - The object to be informed about an event occurrencepublic Object getAttribute(Object key)
IAttributeSupportgetAttribute in interface IAttributeSupportkey - the name of the attribute to getkeypublic CommonNode<?>[] getChildren()
public String getDescription()
IPresentationSupportgetDescription in interface IPresentationSupportpublic String getIconName()
IPresentationSupportgetIconName in interface IPresentationSupportpublic String getLabel()
IPresentationSupportgetLabel in interface IPresentationSupportpublic INodeHandler getNodeHandler()
public T getObject()
public CommonNode<?> getParent()
public String getTip()
IPresentationSupportgetTip in interface IPresentationSupportpublic boolean hasChildren()
true if this node has children.true if this node has children.public Object removeAttribute(Object key)
IAttributeSupportremoveAttribute in interface IAttributeSupportkey - the name of the attribute to removekeypublic void removeNotificationListener(EventType type, INotificationListener listener)
INotificationSupportlistener from the collection of objects to be
informed about events of type name.removeNotificationListener in interface INotificationSupporttype - The event type we are no longer interested in.listener - The object registered for the event till now.public Object setAttribute(Object key, Object value)
IAttributeSupportsetAttribute in interface IAttributeSupportkey - the name of the attribute to setvalue - the new value the attributekeypublic void setNodeHandler(INodeHandler nodeHandler)
Copyright © 2013 intarsys consulting GmbH. All Rights Reserved.