use of com.codename1.rad.nodes.PropertyNode in project CodeRAD by shannah.
the class EntityListTableModel method getValueAt.
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Entity e = entities.get(rowIndex);
FieldNode column = columns.getColumn(columnIndex);
PropertyNode prop = column.getProperty();
if (prop != null) {
return prop.getValue().getValue(e.getEntity());
} else {
return "";
}
}
use of com.codename1.rad.nodes.PropertyNode in project CodeRAD by shannah.
the class FieldNode method getProperty.
/**
* Gets the property for this field. First this will check for an explicit
* property setting using {@link #getProperty()}, and if none is foune, it will
* resolve the tags against the given entity type to find the appropriate property
* of the entity type.
* @param context The entity type to find the property from, in case no property is explicitly set.
* @return The property or null.
*/
public Property getProperty(EntityType context) {
PropertyNode explicitProperty = getProperty();
if (explicitProperty != null) {
return explicitProperty.getValue();
}
if (context == null) {
return null;
}
Tags tags = getTags();
if (tags != null && !tags.isEmpty()) {
for (Property prop : context) {
Tags propTags = prop.getTags();
if (tags.intersects(propTags)) {
return prop;
}
}
}
return null;
}
use of com.codename1.rad.nodes.PropertyNode in project CodeRAD by shannah.
the class FieldNode method getPropertySelector.
/**
* Gets a property selector for this field node. If the field contained
* a PropertyNode or a Tags node, then it will construct a selector from those.
*
* Otherwise it will check for a {@link ProeprtySelectorAttribute}, and return
* a selector constructed form that, with the provided entity root.
* @param context
* @return A property selector, or null if no property or tag is set, and no property selector is set.
*/
public PropertySelector getPropertySelector(Entity context) {
if (context == null) {
return null;
}
Property prop = getProperty(context.getEntity().getEntityType());
if (prop != null) {
return new PropertySelector(context, prop);
}
Tags tags = getTags();
if (tags != null) {
return new PropertySelector(context, tags.toArray());
}
PropertySelectorAttribute selectorProvider = (PropertySelectorAttribute) findAttribute(PropertySelectorAttribute.class);
if (selectorProvider != null) {
return selectorProvider.getValue(context);
}
return null;
}
use of com.codename1.rad.nodes.PropertyNode in project CodeRAD by shannah.
the class Node method createPropertySelector.
/**
* Creates a property selector on the given entity using (in order of decreasing precedence):
*
* 1. A {@link PropertyNode} attribute on the node.
* 2. A {@link Tags} attribute on the node.
* 3. A {@link PropertySelectorAttribute} on the node.
*
* @param entity The entity on which the property selector should be created.
* @return The property selector.
*/
public PropertySelector createPropertySelector(Entity entity) {
PropertyNode prop = findAttribute(PropertyNode.class);
if (prop != null) {
return new PropertySelector(entity, prop.getValue());
}
Tags tags = findAttribute(Tags.class);
if (tags != null) {
return new PropertySelector(entity, tags.toArray());
}
PropertySelectorAttribute att = (PropertySelectorAttribute) findAttribute(PropertySelectorAttribute.class);
if (att != null) {
return att.getValue(entity);
}
return null;
}
Aggregations