Search in sources :

Example 1 with PageElementProps

use of org.eclipse.sirius.components.forms.elements.PageElementProps in project sirius-components by eclipse-sirius.

the class PageComponent method render.

@Override
public Element render() {
    VariableManager variableManager = this.props.getVariableManager();
    PageDescription pageDescription = this.props.getPageDescription();
    List<?> semanticElements = pageDescription.getSemanticElementsProvider().apply(variableManager);
    List<Element> children = new ArrayList<>(semanticElements.size());
    for (Object semanticElement : semanticElements) {
        VariableManager pageVariableManager = variableManager.createChild();
        pageVariableManager.put(VariableManager.SELF, semanticElement);
        String id = pageDescription.getIdProvider().apply(pageVariableManager);
        String label = pageDescription.getLabelProvider().apply(pageVariableManager);
        // @formatter:off
        List<Element> groupComponents = pageDescription.getGroupDescriptions().stream().map(groupDescription -> {
            GroupComponentProps groupComponentProps = new GroupComponentProps(pageVariableManager, groupDescription);
            return new Element(GroupComponent.class, groupComponentProps);
        }).collect(Collectors.toList());
        PageElementProps pageElementProps = PageElementProps.newPageElementProps(id).label(label).children(groupComponents).build();
        Element pageElement = new Element(PageElementProps.TYPE, pageElementProps);
        // @formatter:on
        children.add(pageElement);
    }
    FragmentProps fragmentProps = new FragmentProps(children);
    return new Fragment(fragmentProps);
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Objects(java.util.Objects) List(java.util.List) Fragment(org.eclipse.sirius.components.representations.Fragment) PageDescription(org.eclipse.sirius.components.forms.description.PageDescription) PageElementProps(org.eclipse.sirius.components.forms.elements.PageElementProps) FragmentProps(org.eclipse.sirius.components.representations.FragmentProps) VariableManager(org.eclipse.sirius.components.representations.VariableManager) Collectors(java.util.stream.Collectors) Element(org.eclipse.sirius.components.representations.Element) IComponent(org.eclipse.sirius.components.representations.IComponent) ArrayList(java.util.ArrayList) Element(org.eclipse.sirius.components.representations.Element) ArrayList(java.util.ArrayList) PageDescription(org.eclipse.sirius.components.forms.description.PageDescription) Fragment(org.eclipse.sirius.components.representations.Fragment) PageElementProps(org.eclipse.sirius.components.forms.elements.PageElementProps) FragmentProps(org.eclipse.sirius.components.representations.FragmentProps)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 PageDescription (org.eclipse.sirius.components.forms.description.PageDescription)1 PageElementProps (org.eclipse.sirius.components.forms.elements.PageElementProps)1 Element (org.eclipse.sirius.components.representations.Element)1 Fragment (org.eclipse.sirius.components.representations.Fragment)1 FragmentProps (org.eclipse.sirius.components.representations.FragmentProps)1 IComponent (org.eclipse.sirius.components.representations.IComponent)1 VariableManager (org.eclipse.sirius.components.representations.VariableManager)1