Search in sources :

Example 6 with ViewNode

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;
}
Also used : ViewNode(com.codename1.rad.nodes.ViewNode)

Example 7 with ViewNode

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;
}
Also used : WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) SwipeContainer(com.codename1.rad.nodes.SwipeContainer) SwipeableContainer(com.codename1.ui.SwipeableContainer) Container(com.codename1.ui.Container) GridLayout(com.codename1.ui.layouts.GridLayout) WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) MultiButtonEntityView(com.codename1.rad.ui.entityviews.MultiButtonEntityView) ActionNode(com.codename1.rad.nodes.ActionNode) ViewNode(com.codename1.rad.nodes.ViewNode) SwipeableContainer(com.codename1.ui.SwipeableContainer) SwipeContainer(com.codename1.rad.nodes.SwipeContainer)

Example 8 with ViewNode

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);
}
Also used : WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) MultiButtonEntityView(com.codename1.rad.ui.entityviews.MultiButtonEntityView) ViewType(com.codename1.rad.attributes.ViewType)

Example 9 with ViewNode

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;
}
Also used : WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) Container(com.codename1.ui.Container) SwipeContainer(com.codename1.rad.nodes.SwipeContainer) SwipeableContainer(com.codename1.ui.SwipeableContainer) WrapperEntityView(com.codename1.rad.ui.entityviews.WrapperEntityView) MultiButtonEntityView(com.codename1.rad.ui.entityviews.MultiButtonEntityView) ViewNode(com.codename1.rad.nodes.ViewNode) SwipeableContainer(com.codename1.ui.SwipeableContainer) SwipeContainer(com.codename1.rad.nodes.SwipeContainer)

Example 10 with ViewNode

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);
}
Also used : ProfileAvatarView(com.codename1.rad.ui.entityviews.ProfileAvatarView) ViewNode(com.codename1.rad.nodes.ViewNode)

Aggregations

ViewNode (com.codename1.rad.nodes.ViewNode)9 MultiButtonEntityView (com.codename1.rad.ui.entityviews.MultiButtonEntityView)3 WrapperEntityView (com.codename1.rad.ui.entityviews.WrapperEntityView)3 Attribute (com.codename1.rad.models.Attribute)2 Entity (com.codename1.rad.models.Entity)2 ActionNode (com.codename1.rad.nodes.ActionNode)2 SwipeContainer (com.codename1.rad.nodes.SwipeContainer)2 Container (com.codename1.ui.Container)2 SwipeableContainer (com.codename1.ui.SwipeableContainer)2 Switch (com.codename1.components.Switch)1 Log (com.codename1.io.Log)1 ViewType (com.codename1.rad.attributes.ViewType)1 EntityList (com.codename1.rad.models.EntityList)1 EntityTypeBuilder.entityTypeBuilder (com.codename1.rad.models.EntityTypeBuilder.entityTypeBuilder)1 PropertySelector (com.codename1.rad.models.PropertySelector)1 Tag (com.codename1.rad.models.Tag)1 ListNode (com.codename1.rad.nodes.ListNode)1 Node (com.codename1.rad.nodes.Node)1 Thing (com.codename1.rad.schemas.Thing)1 AbstractEntityView (com.codename1.rad.ui.AbstractEntityView)1