use of org.eclipse.sirius.components.forms.elements.GroupElementProps in project sirius-components by eclipse-sirius.
the class GroupComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
GroupDescription groupDescription = this.props.getGroupDescription();
WidgetIdCounter widgetIdCounter = new WidgetIdCounter();
List<?> semanticElements = groupDescription.getSemanticElementsProvider().apply(variableManager);
List<Element> children = new ArrayList<>(semanticElements.size());
for (Object semanticElement : semanticElements) {
VariableManager groupVariableManager = variableManager.createChild();
groupVariableManager.put(VariableManager.SELF, semanticElement);
groupVariableManager.put(WIDGET_ID_PROVIDER_COUNTER, widgetIdCounter);
String id = groupDescription.getIdProvider().apply(groupVariableManager);
String label = groupDescription.getLabelProvider().apply(groupVariableManager);
// @formatter:off
List<Element> groupChildren = new ArrayList<>();
List<AbstractControlDescription> controlDescriptions = groupDescription.getControlDescriptions();
for (AbstractControlDescription controlDescription : controlDescriptions) {
if (controlDescription instanceof AbstractWidgetDescription) {
AbstractWidgetDescription widgetDescription = (AbstractWidgetDescription) controlDescription;
WidgetComponentProps widgetComponentProps = new WidgetComponentProps(groupVariableManager, widgetDescription);
groupChildren.add(new Element(WidgetComponent.class, widgetComponentProps));
} else if (controlDescription instanceof ForDescription) {
ForDescription forDescription = (ForDescription) controlDescription;
ForComponentProps forComponentProps = new ForComponentProps(groupVariableManager, forDescription);
groupChildren.add(new Element(ForComponent.class, forComponentProps));
}
}
GroupElementProps groupElementProps = GroupElementProps.newGroupElementProps(id).label(label).children(groupChildren).build();
Element groupElement = new Element(GroupElementProps.TYPE, groupElementProps);
// @formatter:on
children.add(groupElement);
}
FragmentProps fragmentProps = new FragmentProps(children);
return new Fragment(fragmentProps);
}
Aggregations