use of org.eclipse.sirius.components.forms.description.ListDescription in project sirius-components by eclipse-sirius.
the class WidgetComponent method render.
@Override
public Element render() {
VariableManager variableManager = this.props.getVariableManager();
AbstractWidgetDescription widgetDescription = this.props.getWidgetDescription();
Element element = null;
if (widgetDescription instanceof TextfieldDescription) {
TextfieldComponentProps textfieldProps = new TextfieldComponentProps(variableManager, (TextfieldDescription) widgetDescription);
element = new Element(TextfieldComponent.class, textfieldProps);
} else if (widgetDescription instanceof TextareaDescription) {
TextareaComponentProps textareaProps = new TextareaComponentProps(variableManager, (TextareaDescription) widgetDescription);
element = new Element(TextareaComponent.class, textareaProps);
} else if (widgetDescription instanceof CheckboxDescription) {
CheckboxComponentProps checkboxProps = new CheckboxComponentProps(variableManager, (CheckboxDescription) widgetDescription);
element = new Element(CheckboxComponent.class, checkboxProps);
} else if (widgetDescription instanceof SelectDescription) {
SelectComponentProps selectProps = new SelectComponentProps(variableManager, (SelectDescription) widgetDescription);
element = new Element(SelectComponent.class, selectProps);
} else if (widgetDescription instanceof MultiSelectDescription) {
MultiSelectComponentProps multiSelectProps = new MultiSelectComponentProps(variableManager, (MultiSelectDescription) widgetDescription);
element = new Element(MultiSelectComponent.class, multiSelectProps);
} else if (widgetDescription instanceof RadioDescription) {
RadioComponentProps radioProps = new RadioComponentProps(variableManager, (RadioDescription) widgetDescription);
element = new Element(RadioComponent.class, radioProps);
} else if (widgetDescription instanceof ListDescription) {
ListComponentProps listProps = new ListComponentProps(variableManager, (ListDescription) widgetDescription);
element = new Element(ListComponent.class, listProps);
} else if (widgetDescription instanceof LinkDescription) {
LinkComponentProps linkProps = new LinkComponentProps(variableManager, (LinkDescription) widgetDescription);
element = new Element(LinkComponent.class, linkProps);
} else {
// $NON-NLS-1$
String pattern = "Unsupported widget description: {}";
this.logger.warn(pattern, widgetDescription.getClass().getSimpleName());
}
return element;
}
use of org.eclipse.sirius.components.forms.description.ListDescription in project sirius-web by eclipse-sirius.
the class RepresentationsDescriptionProvider method getGroupDescription.
private GroupDescription getGroupDescription() {
List<AbstractControlDescription> controlDescriptions = new ArrayList<>();
// @formatter:off
ListDescription listDescription = // $NON-NLS-1$
ListDescription.newListDescription("RepresentationsList").idProvider(new WidgetIdProvider()).labelProvider(// $NON-NLS-1$
(variableManager) -> "Representations").itemsProvider(this.getItemsProvider()).itemIdProvider(this.getItemIdProvider()).itemLabelProvider(this.getItemLabelProvider()).itemImageURLProvider(this.getItemImageURLProvider()).itemDeletableProvider(this.getItemDeletableProvider()).itemDeleteHandlerProvider(this.getItemDeleteHandlerProvider()).itemKindProvider(this.getItemKindProvider()).diagnosticsProvider((variableManager) -> List.of()).kindProvider(// $NON-NLS-1$
(object) -> "").messageProvider(// $NON-NLS-1$
(object) -> "").build();
// @formatter:on
controlDescriptions.add(listDescription);
// @formatter:off
return // $NON-NLS-1$
GroupDescription.newGroupDescription("representationsGroupId").idProvider(// $NON-NLS-1$
variableManager -> "Representations Group").labelProvider(// $NON-NLS-1$
variableManager -> "Representations Group").semanticElementsProvider(variableManager -> Collections.singletonList(variableManager.getVariables().get(VariableManager.SELF))).controlDescriptions(controlDescriptions).build();
// @formatter:on
}
use of org.eclipse.sirius.components.forms.description.ListDescription 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