Search in sources :

Example 31 with Node

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

Example 32 with Node

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;
}
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 33 with Node

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

Example 34 with Node

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;
}
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 35 with Node

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));
}
Also used : Container(com.codename1.ui.Container) BorderLayout(com.codename1.ui.layouts.BorderLayout) Layout(com.codename1.ui.layouts.Layout) BoxLayout(com.codename1.ui.layouts.BoxLayout) BorderLayout(com.codename1.ui.layouts.BorderLayout) GridLayout(com.codename1.ui.layouts.GridLayout)

Aggregations

BorderLayout (com.codename1.ui.layouts.BorderLayout)11 ViewNode (com.codename1.rad.nodes.ViewNode)10 ActionNode (com.codename1.rad.nodes.ActionNode)8 Container (com.codename1.ui.Container)7 ListNode (com.codename1.rad.nodes.ListNode)6 PropertySelectorAttribute (com.codename1.rad.attributes.PropertySelectorAttribute)5 Node (com.codename1.rad.nodes.Node)5 BoxLayout (com.codename1.ui.layouts.BoxLayout)5 MultiButtonEntityView (com.codename1.rad.ui.entityviews.MultiButtonEntityView)4 Label (com.codename1.ui.Label)4 GridLayout (com.codename1.ui.layouts.GridLayout)4 Log (com.codename1.io.Log)3 NodeDecoratorAttribute (com.codename1.rad.attributes.NodeDecoratorAttribute)3 ViewPropertyParameterAttribute (com.codename1.rad.attributes.ViewPropertyParameterAttribute)3 Entity (com.codename1.rad.models.Entity)3 EntityList (com.codename1.rad.models.EntityList)3 EntityTypeBuilder.entityTypeBuilder (com.codename1.rad.models.EntityTypeBuilder.entityTypeBuilder)3 Thing (com.codename1.rad.schemas.Thing)3 WrapperEntityView (com.codename1.rad.ui.entityviews.WrapperEntityView)3 Button (com.codename1.ui.Button)3