Search in sources :

Example 1 with ValidationElementProps

use of org.eclipse.sirius.components.validation.elements.ValidationElementProps in project sirius-components by eclipse-sirius.

the class ValidationComponent method render.

@Override
public Element render() {
    VariableManager variableManager = this.props.getVariableManager();
    ValidationDescription validationDescription = this.props.getValidationDescription();
    Optional<Validation> optionalPreviousValidation = this.props.getPreviousValidation();
    // $NON-NLS-1$
    String id = optionalPreviousValidation.map(Validation::getId).orElseGet(() -> "validation");
    String label = validationDescription.getLabel();
    List<?> diagnostics = validationDescription.getDiagnosticsProvider().apply(variableManager);
    List<Element> children = new ArrayList<>(diagnostics.size());
    for (Object diagnostic : diagnostics) {
        DiagnosticComponentProps diagnosticComponentProps = new DiagnosticComponentProps(diagnostic, validationDescription);
        children.add(new Element(DiagnosticComponent.class, diagnosticComponentProps));
    }
    // @formatter:off
    ValidationElementProps validationElementProps = ValidationElementProps.newValidationElementProps(id).label(label).descriptionId(validationDescription.getId()).children(children).build();
    return new Element(ValidationElementProps.TYPE, validationElementProps);
}
Also used : VariableManager(org.eclipse.sirius.components.representations.VariableManager) Validation(org.eclipse.sirius.components.validation.Validation) Element(org.eclipse.sirius.components.representations.Element) ArrayList(java.util.ArrayList) ValidationDescription(org.eclipse.sirius.components.validation.description.ValidationDescription) ValidationElementProps(org.eclipse.sirius.components.validation.elements.ValidationElementProps)

Aggregations

ArrayList (java.util.ArrayList)1 Element (org.eclipse.sirius.components.representations.Element)1 VariableManager (org.eclipse.sirius.components.representations.VariableManager)1 Validation (org.eclipse.sirius.components.validation.Validation)1 ValidationDescription (org.eclipse.sirius.components.validation.description.ValidationDescription)1 ValidationElementProps (org.eclipse.sirius.components.validation.elements.ValidationElementProps)1