use of com.codename1.rad.nodes.SwipeContainer 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.SwipeContainer 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;
}
Aggregations