use of org.eclipse.sirius.components.collaborative.forms.api.PropertiesConfiguration in project sirius-components by eclipse-sirius.
the class PropertiesEventProcessorFactory method createRepresentationEventProcessor.
@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof PropertiesConfiguration) {
PropertiesConfiguration propertiesConfiguration = (PropertiesConfiguration) configuration;
List<FormDescription> formDescriptions = this.propertiesDescriptionService.getPropertiesDescriptions();
// @formatter:off
var objects = propertiesConfiguration.getObjectIds().stream().map(objectId -> this.objectService.getObject(editingContext, objectId)).flatMap(Optional::stream).collect(Collectors.toList());
// @formatter:on
if (!objects.isEmpty()) {
Optional<FormDescription> optionalFormDescription = Optional.empty();
if (!formDescriptions.isEmpty()) {
optionalFormDescription = new FormDescriptionAggregator().aggregate(formDescriptions, objects, this.objectService);
}
FormDescription formDescription = optionalFormDescription.orElse(this.propertiesDefaultDescriptionProvider.getFormDescription());
// @formatter:off
FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(propertiesConfiguration.getId()).editingContext(editingContext).formDescription(formDescription).objects(objects).build();
// @formatter:on
IRepresentationEventProcessor formEventProcessor = new FormEventProcessor(formCreationParameters, this.formEventHandlers, this.subscriptionManagerFactory.create(), this.widgetSubscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry);
// @formatter:off
return Optional.of(formEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
// @formatter:on
}
}
return Optional.empty();
}
Aggregations