Search in sources :

Example 11 with Attribute

use of com.codename1.rad.models.Attribute in project CodeRAD by shannah.

the class FieldNode method copy.

public FieldNode copy() {
    FieldNode out = new FieldNode();
    for (Attribute att : attributes) {
        out.setAttributes(att);
    }
    out.setProxying(getProxying());
    out.setParent(getParent());
    return out;
}
Also used : LabelStyleAttribute(com.codename1.rad.ui.EntityEditor.LabelStyleAttribute) PropertySelectorAttribute(com.codename1.rad.attributes.PropertySelectorAttribute) DescriptionStyleAttribute(com.codename1.rad.ui.EntityEditor.DescriptionStyleAttribute) PropertyImageRendererAttribute(com.codename1.rad.attributes.PropertyImageRendererAttribute) Attribute(com.codename1.rad.models.Attribute)

Example 12 with Attribute

use of com.codename1.rad.models.Attribute in project CodeRAD by shannah.

the class Node method mergeRecursive.

protected static final Attribute[] mergeRecursive(Attribute[]... arrs) {
    LinkedHashMap<Class, Attribute> map = new LinkedHashMap<>();
    for (Attribute[] arr : arrs) {
        for (Attribute att : arr) {
            Attribute existing = map.get(att.getClass());
            if (existing == null) {
                map.put(att.getClass(), att);
                continue;
            }
            if (existing instanceof Node) {
                Node existingNode = (Node) existing;
                Node node = (Node) att;
                existingNode.mergeAttributes(node, true);
            } else {
                map.put(att.getClass(), att);
            }
        }
    }
    return map.values().toArray(new Attribute[map.size()]);
}
Also used : ViewPropertyParameterAttribute(com.codename1.rad.attributes.ViewPropertyParameterAttribute) NodeDecoratorAttribute(com.codename1.rad.attributes.NodeDecoratorAttribute) PropertySelectorAttribute(com.codename1.rad.attributes.PropertySelectorAttribute) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with Attribute

use of com.codename1.rad.models.Attribute in project CodeRAD by shannah.

the class Node method mergeAttributes.

private void mergeAttributes(Node node, boolean recursive) {
    for (Attribute att : node.attributes) {
        if (attributes.getAttribute(att.getClass()) == null) {
            setAttributes(att);
        } else {
            if (recursive && att instanceof Node) {
                Node existing = (Node) attributes.getAttribute(att.getClass());
                Node newNode = (Node) att;
                existing.mergeAttributes(newNode, recursive);
            } else {
                setAttributes(att);
            }
        }
    }
}
Also used : ViewPropertyParameterAttribute(com.codename1.rad.attributes.ViewPropertyParameterAttribute) NodeDecoratorAttribute(com.codename1.rad.attributes.NodeDecoratorAttribute) PropertySelectorAttribute(com.codename1.rad.attributes.PropertySelectorAttribute)

Example 14 with Attribute

use of com.codename1.rad.models.Attribute 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 15 with Attribute

use of com.codename1.rad.models.Attribute in project CodeRAD by shannah.

the class ActionsNode method setAttributes.

@Override
public void setAttributes(Attribute... atts) {
    // super.setAttributes(atts);
    for (Attribute att : atts) {
        if (att == null)
            continue;
        if (att.getClass() == ActionNode.class) {
            ActionNode n = (ActionNode) att;
            if (actions == null) {
                actions = new ArrayList<ActionNode>();
            }
            n = (ActionNode) n.createProxy(this);
            actions.add(n);
        } else {
            super.setAttributes(att);
        }
    }
}
Also used : Attribute(com.codename1.rad.models.Attribute)

Aggregations

FieldNode (com.codename1.rad.nodes.FieldNode)14 PropertySelectorAttribute (com.codename1.rad.attributes.PropertySelectorAttribute)6 Attribute (com.codename1.rad.models.Attribute)6 NodeDecoratorAttribute (com.codename1.rad.attributes.NodeDecoratorAttribute)4 ViewPropertyParameterAttribute (com.codename1.rad.attributes.ViewPropertyParameterAttribute)4 Label (com.codename1.ui.Label)3 BorderLayout (com.codename1.ui.layouts.BorderLayout)3 ActionNode (com.codename1.rad.nodes.ActionNode)2 Container (com.codename1.ui.Container)2 Hashtable (java.util.Hashtable)2 Switch (com.codename1.components.Switch)1 CharArrayReader (com.codename1.io.CharArrayReader)1 Log (com.codename1.io.Log)1 NetworkEvent (com.codename1.io.NetworkEvent)1 DateFormat (com.codename1.l10n.DateFormat)1 RAD (com.codename1.rad.annotations.RAD)1 RADDoc (com.codename1.rad.annotations.RADDoc)1 ActionStyleAttribute (com.codename1.rad.attributes.ActionStyleAttribute)1 PropertyImageRendererAttribute (com.codename1.rad.attributes.PropertyImageRendererAttribute)1 Entity (com.codename1.rad.models.Entity)1