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