Search in sources :

Example 1 with ValidationDescription

use of org.eclipse.sirius.components.validation.description.ValidationDescription 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)

Example 2 with ValidationDescription

use of org.eclipse.sirius.components.validation.description.ValidationDescription in project sirius-components by eclipse-sirius.

the class ValidationEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IValidationEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof ValidationConfiguration) {
        ValidationDescription validationDescription = this.validationDescriptionProvider.getDescription();
        ValidationContext validationContext = new ValidationContext(null);
        IRepresentationEventProcessor validationEventProcessor = new ValidationEventProcessor(editingContext, validationDescription, validationContext, this.validationEventHandlers, this.subscriptionManagerFactory.create(), new SimpleMeterRegistry(), this.representationRefreshPolicyRegistry);
        // @formatter:off
        return Optional.of(validationEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
    // @formatter:on
    }
    return Optional.empty();
}
Also used : ValidationDescription(org.eclipse.sirius.components.validation.description.ValidationDescription) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) IValidationEventProcessor(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor) ValidationConfiguration(org.eclipse.sirius.components.collaborative.validation.api.ValidationConfiguration) IValidationEventProcessor(org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Example 3 with ValidationDescription

use of org.eclipse.sirius.components.validation.description.ValidationDescription in project sirius-components by eclipse-sirius.

the class DiagnosticComponent method render.

@Override
public Element render() {
    Object diagnostic = this.props.getDiagnostic();
    ValidationDescription validationDescription = this.props.getValidationDescription();
    String kind = validationDescription.getKindProvider().apply(diagnostic);
    String message = validationDescription.getMessageProvider().apply(diagnostic);
    // @formatter:off
    DiagnosticElementProps diagnosticElementProps = DiagnosticElementProps.newDiagnosticElementProps(UUID.randomUUID()).kind(kind).message(message).build();
    return new Element(DiagnosticElementProps.TYPE, diagnosticElementProps);
}
Also used : ValidationDescription(org.eclipse.sirius.components.validation.description.ValidationDescription) DiagnosticElementProps(org.eclipse.sirius.components.validation.elements.DiagnosticElementProps) Element(org.eclipse.sirius.components.representations.Element)

Aggregations

ValidationDescription (org.eclipse.sirius.components.validation.description.ValidationDescription)3 Element (org.eclipse.sirius.components.representations.Element)2 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 ArrayList (java.util.ArrayList)1 IRepresentationEventProcessor (org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)1 IValidationEventProcessor (org.eclipse.sirius.components.collaborative.validation.api.IValidationEventProcessor)1 ValidationConfiguration (org.eclipse.sirius.components.collaborative.validation.api.ValidationConfiguration)1 VariableManager (org.eclipse.sirius.components.representations.VariableManager)1 Validation (org.eclipse.sirius.components.validation.Validation)1 DiagnosticElementProps (org.eclipse.sirius.components.validation.elements.DiagnosticElementProps)1 ValidationElementProps (org.eclipse.sirius.components.validation.elements.ValidationElementProps)1