use of com.codename1.rad.nodes.Node 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;
}
use of com.codename1.rad.nodes.Node in project CodeRAD by shannah.
the class DefaultEntityListCellRenderer method makeSwipeable.
private EntityView makeSwipeable(Entity entity, ViewNode node, Component view) {
// Check for swipeable container
SwipeContainer swipe = (SwipeContainer) node.findAttribute(SwipeContainer.class);
if (swipe != null) {
EntityView leftCnt = null;
EntityView rightCnt = null;
ViewNode leftNode = swipe.getLeft();
if (leftNode != null) {
leftCnt = leftNode.createView(entity);
}
ViewNode rightNode = swipe.getRight();
if (rightNode != null) {
rightCnt = rightNode.createView(entity);
}
SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
return new WrapperEntityView(swipeWrapper, entity, node);
}
ActionNode deleteAction = node.getInheritedAction(ActionCategories.LIST_REMOVE_ACTION);
Actions leftSwipeActions = node.getActions(ActionCategories.LEFT_SWIPE_MENU);
if (deleteAction != null) {
leftSwipeActions.add(deleteAction);
}
Actions rightSwipeActions = node.getActions(ActionCategories.RIGHT_SWIPE_MENU);
if (!leftSwipeActions.isEmpty() || !rightSwipeActions.isEmpty()) {
Container leftCnt = null;
Container rightCnt = null;
if (!leftSwipeActions.isEmpty()) {
leftCnt = new Container(new GridLayout(leftSwipeActions.size()));
for (ActionNode action : leftSwipeActions) {
leftCnt.add(action.getViewFactory().createActionView(entity, action));
}
}
if (!rightSwipeActions.isEmpty()) {
rightCnt = new Container(new GridLayout(rightSwipeActions.size()));
for (ActionNode action : rightSwipeActions) {
rightCnt.add(action.getViewFactory().createActionView(entity, action));
}
}
SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
return new WrapperEntityView(swipeWrapper, entity, node);
} else {
// System.out.println("Swipe actions not present");
}
return (EntityView) view;
}
use of com.codename1.rad.nodes.Node in project CodeRAD by shannah.
the class DefaultEntityViewFactory method createView.
@Override
public EntityView createView(Entity entity, ViewNode node) {
ViewType type = (ViewType) node.findAttribute(ViewType.class);
if (type == null) {
type = ViewType.MULTIBUTTON;
}
EntityViewFactory f = registry.get(type);
if (f == null) {
throw new IllegalArgumentException("Factory doesn't know how to build view " + type);
}
EntityView out = f.createView(entity, node);
return makeSwipeable(entity, node, (Component) out);
}
use of com.codename1.rad.nodes.Node in project CodeRAD by shannah.
the class DefaultEntityViewFactory method makeSwipeable.
private EntityView makeSwipeable(Entity entity, ViewNode node, Component view) {
// Check for swipeable container
SwipeContainer swipe = (SwipeContainer) node.findAttribute(SwipeContainer.class);
if (swipe != null) {
EntityView leftCnt = null;
EntityView rightCnt = null;
ViewNode leftNode = swipe.getLeft();
if (leftNode != null) {
leftCnt = leftNode.createView(entity, this);
}
ViewNode rightNode = swipe.getRight();
if (rightNode != null) {
rightCnt = rightNode.createView(entity, this);
}
SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
return new WrapperEntityView(swipeWrapper, entity, node);
}
Actions leftSwipeActions = node.getActions(ActionCategories.LEFT_SWIPE_MENU);
Actions rightSwipeActions = node.getActions(ActionCategories.RIGHT_SWIPE_MENU);
if (!leftSwipeActions.isEmpty() || !rightSwipeActions.isEmpty()) {
Container leftCnt = null;
Container rightCnt = null;
if (!leftSwipeActions.isEmpty()) {
leftCnt = new Container(BoxLayout.y());
NodeUtilFunctions.buildActionsBar(node, leftCnt, entity, null, leftSwipeActions, null);
}
if (!rightSwipeActions.isEmpty()) {
rightCnt = new Container(BoxLayout.y());
NodeUtilFunctions.buildActionsBar(node, leftCnt, entity, rightSwipeActions, null, null);
}
SwipeableContainer swipeWrapper = new SwipeableContainer((Component) leftCnt, (Component) rightCnt, view);
return new WrapperEntityView(swipeWrapper, entity, node);
}
return (EntityView) view;
}
use of com.codename1.rad.nodes.Node in project CodeRAD by shannah.
the class NodeUtilFunctions method buildBottomActionsBar.
static void buildBottomActionsBar(Node node, Container target, Entity entity) {
Layout targetLayout = target.getLayout();
if (targetLayout instanceof BorderLayout) {
Container south = new Container(BoxLayout.y());
target.add(SOUTH, south);
target = south;
}
buildActionsBar(node, target, entity, node.getActions(FormNode.BOTTOM_RIGHT_MENU), node.getActions(FormNode.BOTTOM_LEFT_MENU), null, node.getActions(FormNode.BOTTOM_MENU));
}
Aggregations