Search in sources :

Example 1 with TextfieldElementProps

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

the class TextfieldComponent method render.

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

Aggregations

List (java.util.List)1 Objects (java.util.Objects)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 TextfieldDescription (org.eclipse.sirius.components.forms.description.TextfieldDescription)1 TextfieldElementProps (org.eclipse.sirius.components.forms.elements.TextfieldElementProps)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