Search in sources :

Example 1 with PropertiesConfiguration

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();
}
Also used : IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) PropertiesConfiguration(org.eclipse.sirius.components.collaborative.forms.api.PropertiesConfiguration) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Aggregations

IRepresentationEventProcessor (org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)1 FormCreationParameters (org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters)1 IFormEventProcessor (org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor)1 PropertiesConfiguration (org.eclipse.sirius.components.collaborative.forms.api.PropertiesConfiguration)1 FormDescription (org.eclipse.sirius.components.forms.description.FormDescription)1