Search in sources :

Example 1 with FormCreationParameters

use of org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters 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)

Example 2 with FormCreationParameters

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

the class FormEventProcessorTests method testCompleteOnDispose.

@Test
public void testCompleteOnDispose() {
    FormEventInput input = new FormEventInput(UUID.randomUUID(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
    // @formatter:off
    FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(FORM_ID).formDescription(this.getFormDescription()).editingContext(new IEditingContext.NoOp()).objects(List.of(new Object())).build();
    // @formatter:on
    FormEventProcessor formEventProcessor = new FormEventProcessor(formCreationParameters, List.of(), new SubscriptionManager(), new WidgetSubscriptionManager(), new RepresentationRefreshPolicyRegistry());
    Runnable disposeFormEventProcessor = () -> formEventProcessor.dispose();
    // @formatter:off
    StepVerifier.create(formEventProcessor.getOutputEvents(input)).expectNextMatches(this.getRefreshFormEventPayloadPredicate()).then(disposeFormEventProcessor).expectComplete().verify();
// @formatter:on
}
Also used : FormEventInput(org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) RepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.representations.RepresentationRefreshPolicyRegistry) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) SubscriptionManager(org.eclipse.sirius.components.collaborative.representations.SubscriptionManager) Test(org.junit.jupiter.api.Test)

Example 3 with FormCreationParameters

use of org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters 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)

Example 4 with FormCreationParameters

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

the class RepresentationsEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof RepresentationsConfiguration) {
        RepresentationsConfiguration representationsConfiguration = (RepresentationsConfiguration) configuration;
        FormDescription formDescription = this.representationsDescriptionProvider.getRepresentationsDescription();
        Optional<Object> optionalObject = this.objectService.getObject(editingContext, representationsConfiguration.getObjectId());
        if (optionalObject.isPresent()) {
            Object object = optionalObject.get();
            // @formatter:off
            FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(representationsConfiguration.getId()).editingContext(editingContext).formDescription(formDescription).objects(List.of(object)).build();
            // @formatter:on
            FormEventProcessor 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) RepresentationsConfiguration(org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration)

Example 5 with FormCreationParameters

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

the class FormEventProcessorTests method testEmitFormOnSubscription.

@Test
public void testEmitFormOnSubscription() {
    IInput input = new FormEventInput(UUID.randomUUID(), UUID.randomUUID().toString(), UUID.randomUUID().toString());
    // @formatter:off
    FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(FORM_ID).formDescription(this.getFormDescription()).editingContext(new IEditingContext.NoOp()).objects(List.of(new Object())).build();
    // @formatter:on
    FormEventProcessor formEventProcessor = new FormEventProcessor(formCreationParameters, List.of(), new SubscriptionManager(), new WidgetSubscriptionManager(), new RepresentationRefreshPolicyRegistry());
    // @formatter:off
    StepVerifier.create(formEventProcessor.getOutputEvents(input)).expectNextMatches(this.getRefreshFormEventPayloadPredicate()).thenCancel().verify();
// @formatter:on
}
Also used : FormEventInput(org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) RepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.representations.RepresentationRefreshPolicyRegistry) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) IInput(org.eclipse.sirius.components.core.api.IInput) SubscriptionManager(org.eclipse.sirius.components.collaborative.representations.SubscriptionManager) Test(org.junit.jupiter.api.Test)

Aggregations

FormCreationParameters (org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters)6 IFormEventProcessor (org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor)3 FormEventInput (org.eclipse.sirius.components.collaborative.forms.dto.FormEventInput)3 RepresentationRefreshPolicyRegistry (org.eclipse.sirius.components.collaborative.representations.RepresentationRefreshPolicyRegistry)3 SubscriptionManager (org.eclipse.sirius.components.collaborative.representations.SubscriptionManager)3 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)3 FormDescription (org.eclipse.sirius.components.forms.description.FormDescription)3 Test (org.junit.jupiter.api.Test)3 IRepresentationEventProcessor (org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)2 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 FormConfiguration (org.eclipse.sirius.components.collaborative.forms.api.FormConfiguration)1 PropertiesConfiguration (org.eclipse.sirius.components.collaborative.forms.api.PropertiesConfiguration)1 RepresentationsConfiguration (org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration)1 IInput (org.eclipse.sirius.components.core.api.IInput)1 Form (org.eclipse.sirius.components.forms.Form)1