Search in sources :

Example 1 with FormConfiguration

use of org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration in project sirius-components by eclipse-sirius.

the class FormEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof FormConfiguration) {
        FormConfiguration formConfiguration = (FormConfiguration) configuration;
        Optional<Form> optionalForm = this.representationSearchService.findById(editingContext, formConfiguration.getId(), Form.class);
        if (optionalForm.isPresent()) {
            Form form = optionalForm.get();
            // @formatter:off
            Optional<FormDescription> optionalFormDescription = this.representationDescriptionSearchService.findById(editingContext, form.getDescriptionId()).filter(FormDescription.class::isInstance).map(FormDescription.class::cast);
            // @formatter:on
            Optional<Object> optionalObject = this.objectService.getObject(editingContext, form.getTargetObjectId());
            if (optionalFormDescription.isPresent() && optionalObject.isPresent()) {
                FormDescription formDescription = optionalFormDescription.get();
                Object object = optionalObject.get();
                // @formatter:off
                FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(formConfiguration.getId()).editingContext(editingContext).formDescription(formDescription).objects(List.of(object)).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) Form(org.eclipse.sirius.components.forms.Form) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) FormConfiguration(org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Aggregations

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