use of com.codename1.rad.nodes.ViewNode in project CodeRAD by shannah.
the class Controller method getViewNode.
/**
* Gets the {@link ViewNode} that should be used as the view model for views of this controller. Subclasses should override {@link #createViewNode() }
* to define the view node for the controller. This method will defer to that for the initial view node creation, and then just return
* that view node on subsequeuent calls.
*
* NOTE: This will automatically set the parent node of the view node to the view node of the parent controller.
* @return
*/
public ViewNode getViewNode() {
startControllerInternal();
if (node == null) {
node = createViewNode();
ViewNode parentNode = null;
if (parent != null) {
parentNode = parent.getViewNode();
}
node.setParent(parentNode);
}
return node;
}
use of com.codename1.rad.nodes.ViewNode 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.ViewNode 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.ViewNode 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.ViewNode in project CodeRAD by shannah.
the class ProfileAvatarBuilder method build.
@Override
public ProfileAvatarView build() {
ViewNode n = new ViewNode();
n.setParent(node);
if (nameTag != null) {
n.setAttributes(UI.param(ProfileAvatarView.NAME_PROPERTY_TAGS, nameTag));
}
if (iconTag != null) {
n.setAttributes(UI.param(ProfileAvatarView.ICON_PROPERTY_TAGS, iconTag));
}
return new ProfileAvatarView(entity, n, size);
}
Aggregations