Search in sources :

Example 1 with CheckboxElementProps

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

the class CheckboxComponent method render.

@Override
public Element render() {
    VariableManager variableManager = this.props.getVariableManager();
    CheckboxDescription checkboxDescription = this.props.getCheckboxDescription();
    String id = checkboxDescription.getIdProvider().apply(variableManager);
    String label = checkboxDescription.getLabelProvider().apply(variableManager);
    Boolean value = checkboxDescription.getValueProvider().apply(variableManager);
    BiFunction<VariableManager, Boolean, IStatus> genericHandler = checkboxDescription.getNewValueHandler();
    Function<Boolean, IStatus> specializedHandler = newValue -> genericHandler.apply(variableManager, newValue);
    List<Element> children = List.of(new Element(DiagnosticComponent.class, new DiagnosticComponentProps(checkboxDescription, variableManager)));
    // @formatter:off
    CheckboxElementProps checkboxElementProps = CheckboxElementProps.newCheckboxElementProps(id).label(label).value(value.booleanValue()).newValueHandler(specializedHandler).children(children).build();
    return new Element(CheckboxElementProps.TYPE, checkboxElementProps);
// @formatter:on
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) Objects(java.util.Objects) List(java.util.List) IStatus(org.eclipse.sirius.components.representations.IStatus) DiagnosticComponentProps(org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps) BiFunction(java.util.function.BiFunction) CheckboxElementProps(org.eclipse.sirius.components.forms.elements.CheckboxElementProps) VariableManager(org.eclipse.sirius.components.representations.VariableManager) Function(java.util.function.Function) CheckboxDescription(org.eclipse.sirius.components.forms.description.CheckboxDescription) Element(org.eclipse.sirius.components.representations.Element) IComponent(org.eclipse.sirius.components.representations.IComponent) DiagnosticComponent(org.eclipse.sirius.components.forms.validation.DiagnosticComponent) IStatus(org.eclipse.sirius.components.representations.IStatus) Element(org.eclipse.sirius.components.representations.Element) DiagnosticComponentProps(org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps) DiagnosticComponent(org.eclipse.sirius.components.forms.validation.DiagnosticComponent) CheckboxElementProps(org.eclipse.sirius.components.forms.elements.CheckboxElementProps)

Aggregations

List (java.util.List)1 Objects (java.util.Objects)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 CheckboxDescription (org.eclipse.sirius.components.forms.description.CheckboxDescription)1 CheckboxElementProps (org.eclipse.sirius.components.forms.elements.CheckboxElementProps)1 DiagnosticComponent (org.eclipse.sirius.components.forms.validation.DiagnosticComponent)1 DiagnosticComponentProps (org.eclipse.sirius.components.forms.validation.DiagnosticComponentProps)1 Element (org.eclipse.sirius.components.representations.Element)1 IComponent (org.eclipse.sirius.components.representations.IComponent)1 IStatus (org.eclipse.sirius.components.representations.IStatus)1 VariableManager (org.eclipse.sirius.components.representations.VariableManager)1