Search in sources :

Example 1 with NodeDecoratorAttribute

use of com.codename1.rad.attributes.NodeDecoratorAttribute in project CodeRAD by shannah.

the class Node method setAttributes.

/**
 * Sets attributes on this node.
 * @param atts The attributes to set.
 */
public void setAttributes(Attribute... atts) {
    for (Attribute att : atts) {
        if (att == null) {
            continue;
        }
        if (att instanceof Node) {
            Node n = (Node) att;
            if (n.parent != null && n.parent != this) {
                if (n.canProxy()) {
                    n = n.proxy(this);
                } else {
                    throw new IllegalStateException("Node " + n + " already has parent " + n.parent + ".  Cannot be added to " + this);
                }
            } else {
                n.parent = this;
            }
            NodeDecoratorAttribute nodeDecorator = (NodeDecoratorAttribute) n.findAttribute(NodeDecoratorAttribute.class);
            if (nodeDecorator != null) {
                // System.out.println("Decorating node "+n+" with "+nodeDecorator.getValue());
                nodeDecorator.getValue().decorate(n);
            }
            this.childNodes.add(n);
        }
        if (att.getClass() == ViewPropertyParameterAttribute.class) {
            ViewPropertyParameterAttribute valueAtt = (ViewPropertyParameterAttribute) att;
            ViewPropertyParameter val = (ViewPropertyParameter) valueAtt.getValue();
            viewParameters.put(val.getProperty(), val);
        }
        if (att.getClass() == ActionsNode.class) {
            ActionsNode actionsNode = (ActionsNode) att;
            ActionNode.Category category = actionsNode.getCategory();
            if (category != null) {
                actions.put(category, actionsNode);
            }
        }
    }
    this.attributes.setAttributes(atts);
}
Also used : Category(com.codename1.rad.nodes.ActionNode.Category) NodeDecoratorAttribute(com.codename1.rad.attributes.NodeDecoratorAttribute) ViewPropertyParameterAttribute(com.codename1.rad.attributes.ViewPropertyParameterAttribute) NodeDecoratorAttribute(com.codename1.rad.attributes.NodeDecoratorAttribute) PropertySelectorAttribute(com.codename1.rad.attributes.PropertySelectorAttribute) ViewPropertyParameterAttribute(com.codename1.rad.attributes.ViewPropertyParameterAttribute)

Aggregations

NodeDecoratorAttribute (com.codename1.rad.attributes.NodeDecoratorAttribute)1 PropertySelectorAttribute (com.codename1.rad.attributes.PropertySelectorAttribute)1 ViewPropertyParameterAttribute (com.codename1.rad.attributes.ViewPropertyParameterAttribute)1 Category (com.codename1.rad.nodes.ActionNode.Category)1