use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.
the class EditingContextEventProcessor method handleRepresentationInput.
private void handleRepresentationInput(One<IPayload> payloadSink, IRepresentationInput representationInput) {
Optional<IRepresentationEventProcessor> optionalRepresentationEventProcessor = Optional.ofNullable(this.representationEventProcessors.get(representationInput.getRepresentationId())).map(RepresentationEventProcessorEntry::getRepresentationEventProcessor);
if (optionalRepresentationEventProcessor.isPresent()) {
IRepresentationEventProcessor representationEventProcessor = optionalRepresentationEventProcessor.get();
representationEventProcessor.handle(payloadSink, this.changeDescriptionSink, representationInput);
} else {
// $NON-NLS-1$
this.logger.warn("No representation event processor found for event: {}", representationInput);
}
}
use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor 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.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.
the class DiagramEventProcessorFactory method createRepresentationEventProcessor.
@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
if (IDiagramEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof DiagramConfiguration) {
DiagramConfiguration diagramConfiguration = (DiagramConfiguration) configuration;
var optionalDiagram = this.representationSearchService.findById(editingContext, diagramConfiguration.getId(), Diagram.class);
if (optionalDiagram.isPresent()) {
Diagram diagram = optionalDiagram.get();
// @formatter:off
DiagramContext diagramContext = new DiagramContext(diagram);
IRepresentationEventProcessor diagramEventProcessor = new DiagramEventProcessor(editingContext, diagramContext, this.diagramEventHandlers, this.subscriptionManagerFactory.create(), this.representationDescriptionSearchService, this.representationRefreshPolicyRegistry, this.diagramCreationService);
return Optional.of(diagramEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
// @formatter:on
}
}
return Optional.empty();
}
use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.
the class SelectionEventProcessorFactory method createRepresentationEventProcessor.
@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
if (ISelectionEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof SelectionConfiguration) {
SelectionConfiguration selectionConfiguration = (SelectionConfiguration) configuration;
// @formatter:off
Optional<SelectionDescription> optionalSelectionDescription = this.representationDescriptionSearchService.findById(editingContext, selectionConfiguration.getSelectionId()).filter(SelectionDescription.class::isInstance).map(SelectionDescription.class::cast);
// @formatter:on
Optional<Object> optionalObject = this.objectService.getObject(editingContext, selectionConfiguration.getTargetObjectId());
if (optionalSelectionDescription.isPresent() && optionalObject.isPresent()) {
SelectionDescription selectionDescription = optionalSelectionDescription.get();
Object object = optionalObject.get();
IRepresentationEventProcessor selectionEventProcessor = new SelectionEventProcessor(editingContext, selectionDescription, selectionConfiguration.getId(), object, this.subscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry);
// @formatter:off
return Optional.of(selectionEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
// @formatter:on
}
}
return Optional.empty();
}
use of org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor in project sirius-components by eclipse-sirius.
the class ValidationEventProcessorFactory method createRepresentationEventProcessor.
@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
if (IValidationEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof ValidationConfiguration) {
ValidationDescription validationDescription = this.validationDescriptionProvider.getDescription();
ValidationContext validationContext = new ValidationContext(null);
IRepresentationEventProcessor validationEventProcessor = new ValidationEventProcessor(editingContext, validationDescription, validationContext, this.validationEventHandlers, this.subscriptionManagerFactory.create(), new SimpleMeterRegistry(), this.representationRefreshPolicyRegistry);
// @formatter:off
return Optional.of(validationEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
// @formatter:on
}
return Optional.empty();
}
Aggregations