use of org.eclipse.sirius.components.collaborative.dto.RepresentationRefreshedEvent in project sirius-components by eclipse-sirius.
the class EditingContextEventProcessor method refreshOtherRepresentations.
/**
* Refresh all the representations except the one with the given representationId.
*
* @param input
* The input which has triggered the refresh sequence
* @param representationId
* The identifier of the representation which should not be refreshed
* @param changeDescription
* The description of change to consider in order to determine if the representation should be refreshed
*/
private void refreshOtherRepresentations(ChangeDescription changeDescription) {
// @formatter:off
this.representationEventProcessors.entrySet().stream().filter(entry -> !Objects.equals(entry.getKey(), changeDescription.getSourceId())).map(Entry::getValue).map(RepresentationEventProcessorEntry::getRepresentationEventProcessor).forEach(representationEventProcessor -> {
representationEventProcessor.refresh(changeDescription);
IRepresentation representation = representationEventProcessor.getRepresentation();
this.applicationEventPublisher.publishEvent(new RepresentationRefreshedEvent(this.editingContext.getId(), representation));
});
// @formatter:on
}
use of org.eclipse.sirius.components.collaborative.dto.RepresentationRefreshedEvent in project sirius-components by eclipse-sirius.
the class EditingContextEventProcessor method setupChangeDescriptionSinkConsumer.
@SuppressWarnings("checkstyle:IllegalCatch")
private Disposable setupChangeDescriptionSinkConsumer() {
Consumer<ChangeDescription> consumer = changeDescription -> {
if (ChangeKind.REPRESENTATION_TO_DELETE.equals(changeDescription.getKind())) {
Object representationId = changeDescription.getParameters().get(REPRESENTATION_ID);
if (representationId instanceof String) {
DeleteRepresentationInput deleteRepresentationInput = new DeleteRepresentationInput(UUID.randomUUID(), (String) representationId);
this.doHandle(Sinks.one(), deleteRepresentationInput);
}
} else if (ChangeKind.REPRESENTATION_TO_RENAME.equals(changeDescription.getKind())) {
Object representationId = changeDescription.getParameters().get(REPRESENTATION_ID);
Object representationLabel = changeDescription.getParameters().get(REPRESENTATION_LABEL);
if (representationId instanceof String && representationLabel instanceof String) {
RenameRepresentationInput renameRepresentationInput = new RenameRepresentationInput(UUID.randomUUID(), this.getEditingContextId(), (String) representationId, (String) representationLabel);
this.doHandle(Sinks.one(), renameRepresentationInput);
}
}
this.publishEvent(changeDescription);
this.disposeRepresentationIfNeeded();
RepresentationEventProcessorEntry representationEventProcessorEntry = this.representationEventProcessors.get(changeDescription.getSourceId());
if (representationEventProcessorEntry != null) {
try {
IRepresentationEventProcessor representationEventProcessor = representationEventProcessorEntry.getRepresentationEventProcessor();
representationEventProcessor.refresh(changeDescription);
IRepresentation representation = representationEventProcessor.getRepresentation();
this.applicationEventPublisher.publishEvent(new RepresentationRefreshedEvent(this.editingContext.getId(), representation));
} catch (Exception exception) {
this.logger.warn(exception.getMessage(), exception);
}
}
this.refreshOtherRepresentations(changeDescription);
if (this.shouldPersistTheEditingContext(changeDescription)) {
this.editingContextPersistenceService.persist(this.editingContext);
}
this.danglingRepresentationDeletionService.deleteDanglingRepresentations(this.editingContext.getId());
};
Consumer<Throwable> errorConsumer = throwable -> this.logger.warn(throwable.getMessage(), throwable);
return this.changeDescriptionSink.asFlux().subscribe(consumer, errorConsumer);
}
Aggregations