Search in sources :

Example 1 with ActionsNode

use of com.codename1.rad.nodes.ActionsNode 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)

Example 2 with ActionsNode

use of com.codename1.rad.nodes.ActionsNode in project CodeRAD by shannah.

the class UI method actions.

public static ActionsNode actions(Category category, Actions actions) {
    ActionsNode out = actions(actions.toArray());
    out.setAttributes(category);
    return out;
}
Also used : ActionsNode(com.codename1.rad.nodes.ActionsNode)

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 ActionsNode (com.codename1.rad.nodes.ActionsNode)1