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;
}
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()]);
}
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);
}
}
}
}
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);
}
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);
}
}
}
Aggregations