use of org.eclipse.sirius.components.forms.elements.ListElementProps in project sirius-components by eclipse-sirius.
the class ListComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
ListDescription listDescription = this.props.getListDescription();
String id = listDescription.getIdProvider().apply(variableManager);
String label = listDescription.getLabelProvider().apply(variableManager);
List<?> itemCandidates = listDescription.getItemsProvider().apply(variableManager);
List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(listDescription, variableManager)));
List<ListItem> items = new ArrayList<>(itemCandidates.size());
for (Object itemCandidate : itemCandidates) {
VariableManager itemVariableManager = variableManager.createChild();
itemVariableManager.put(CANDIDATE_VARIABLE, itemCandidate);
String itemId = listDescription.getItemIdProvider().apply(itemVariableManager);
String itemLabel = listDescription.getItemLabelProvider().apply(itemVariableManager);
String itemKind = listDescription.getItemKindProvider().apply(itemVariableManager);
String itemImageURL = listDescription.getItemImageURLProvider().apply(itemVariableManager);
boolean isItemDeletable = listDescription.getItemDeletableProvider().apply(itemVariableManager);
Function<VariableManager, IStatus> genericHandler = listDescription.getItemDeleteHandlerProvider();
Supplier<IStatus> specializedHandler = () -> {
return genericHandler.apply(itemVariableManager);
};
// @formatter:off
ListItem item = ListItem.newListItem(itemId).label(itemLabel).kind(itemKind).imageURL(itemImageURL).deletable(isItemDeletable).deleteHandler(specializedHandler).build();
// @formatter:on
items.add(item);
}
// @formatter:off
ListElementProps listElementProps = ListElementProps.newListElementProps(id).label(label).items(items).children(children).build();
return new Element(ListElementProps.TYPE, listElementProps);
}
Aggregations