use of com.codename1.rad.models.Entity in project CodeRAD by shannah.
the class DefaultEntityListCellRenderer method getListCellRendererComponent.
@Override
public EntityView getListCellRendererComponent(EntityListView list, Entity value, int index, boolean isSelected, boolean isFocused) {
ListNode listNode = (ListNode) list.getViewNode();
MultiButtonEntityView out = new MultiButtonEntityView(value, listNode.getRowTemplate());
ActionNode node = listNode.getAction(ActionCategories.LIST_SELECT_ACTION);
if (node != null) {
out.setAction(node);
}
return makeSwipeable(value, listNode.getRowTemplate(), out);
}
use of com.codename1.rad.models.Entity in project CodeRAD by shannah.
the class DefaultPropertyViewFactory method createPropertyView.
@Override
public PropertyView createPropertyView(Entity entity, FieldNode field) {
PropertyViewFactory typeFactory = registry.get(field.getWidgetType(entity.getEntity().getEntityType()));
if (typeFactory == null) {
throw new IllegalArgumentException("Type " + field.getWidgetType() + " not supported");
}
PropertyView out = typeFactory.createPropertyView(entity, field);
PropertyViewDecoratorAttribute decoratorAtt = (PropertyViewDecoratorAttribute) field.findAttribute(PropertyViewDecoratorAttribute.class);
if (decoratorAtt != null) {
out = decoratorAtt.getValue().decorate(out);
}
NodeList decorators = field.getChildNodes(PropertyViewDecoratorNode.class);
if (decorators != null) {
for (Node n : decorators) {
out = ((PropertyViewDecoratorNode) n).getValue().decorate(out);
}
}
return out;
}
use of com.codename1.rad.models.Entity in project CodeRAD by shannah.
the class EntityEditor method build.
private void build() {
if (built) {
return;
}
built = true;
removeAll();
buildTopActionsBar(rootNode, this, entity);
if (getRootView() != null) {
setLayout(new BorderLayout());
buildView();
} else if (getRootList() != null) {
setLayout(new BorderLayout());
buildList();
} else {
setLayout(BoxLayout.y());
buildSections();
}
buildBottomActionsBar(rootNode, this, entity);
}
use of com.codename1.rad.models.Entity in project CodeRAD by shannah.
the class EntityEditor method buildList.
private void buildList() {
if (entity instanceof EntityList) {
EntityListView listView = new EntityListView((EntityList) entity, getRootList());
add(BorderLayout.CENTER, listView);
}
}
use of com.codename1.rad.models.Entity in project CodeRAD by shannah.
the class ResultParserTest method simpleJSONTest.
private void simpleJSONTest() throws Exception {
EntityType personType = new EntityTypeBuilder().string(Person.name).string(Person.email).Date(Person.birthDate).build();
ResultParser parser = new ResultParser(personType).property("name", Person.name).property("email", Person.email).property("dob", Person.birthDate, dateStr -> {
if (!(dateStr instanceof String)) {
return null;
}
String str = (String) dateStr;
if (str.isEmpty()) {
return null;
}
SimpleDateFormat fmt = new SimpleDateFormat("MMM d, yyyy");
try {
return fmt.parse(str);
} catch (ParseException ex) {
Log.e(ex);
return null;
}
});
String json = "{\"name\":\"Paul\", \"email\":\"paul@example.com\", \"dob\" : \"December 27, 1978\"}";
Entity person = parser.parseRow(Result.fromContent(json, Result.JSON), personType.newInstance());
assertEqual("Paul", person.getEntity().getText(Person.name));
assertEqual("paul@example.com", person.getEntity().getText(Person.email));
}
Aggregations