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);
}
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();
}
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);
}
Aggregations