use of org.eclipse.sirius.components.core.api.IInput in project sirius-components by eclipse-sirius.
the class QueryBasedIntEventHandlerTests method handle.
private void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IQueryService queryService) {
QueryBasedIntEventHandler queryBasedIntEventHandler = new QueryBasedIntEventHandler(new ICollaborativeMessageService.NoOp(), new SimpleMeterRegistry(), queryService);
// $NON-NLS-1$
IInput input = new QueryBasedIntInput(UUID.randomUUID(), "", Map.of());
assertThat(queryBasedIntEventHandler.canHandle(new IEditingContext.NoOp(), input)).isTrue();
IEditingContext editingContext = () -> UUID.randomUUID().toString();
queryBasedIntEventHandler.handle(payloadSink, changeDescriptionSink, editingContext, input);
}
use of org.eclipse.sirius.components.core.api.IInput in project sirius-components by eclipse-sirius.
the class QueryBasedStringEventHandlerTests method handle.
private void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IQueryService queryService) {
QueryBasedStringEventHandler queryBasedStringEventHandler = new QueryBasedStringEventHandler(new ICollaborativeMessageService.NoOp(), new SimpleMeterRegistry(), queryService);
// $NON-NLS-1$
IInput input = new QueryBasedStringInput(UUID.randomUUID(), "", Map.of());
assertThat(queryBasedStringEventHandler.canHandle(new IEditingContext.NoOp(), input)).isTrue();
IEditingContext editingContext = () -> UUID.randomUUID().toString();
queryBasedStringEventHandler.handle(payloadSink, changeDescriptionSink, editingContext, input);
}
use of org.eclipse.sirius.components.core.api.IInput in project sirius-components by eclipse-sirius.
the class EditingContextEventProcessor method handleInput.
private void handleInput(One<IPayload> payloadSink, IInput input) {
if (input instanceof DeleteRepresentationInput) {
DeleteRepresentationInput deleteRepresentationInput = (DeleteRepresentationInput) input;
this.disposeRepresentation(deleteRepresentationInput.getRepresentationId());
}
// @formatter:off
Optional<IEditingContextEventHandler> optionalEditingContextEventHandler = this.editingContextEventHandlers.stream().filter(handler -> handler.canHandle(this.editingContext, input)).findFirst();
if (optionalEditingContextEventHandler.isPresent()) {
IEditingContextEventHandler editingContextEventHandler = optionalEditingContextEventHandler.get();
editingContextEventHandler.handle(payloadSink, this.changeDescriptionSink, this.editingContext, input);
} else {
// $NON-NLS-1$
this.logger.warn("No handler found for event: {}", input);
}
}
use of org.eclipse.sirius.components.core.api.IInput in project sirius-components by eclipse-sirius.
the class SubscriptionManager method getFlux.
@Override
public Flux<IPayload> getFlux(IInput input) {
return this.sink.asFlux().doOnSubscribe(subscription -> {
this.subscriptionCount.getAndIncrement();
// $NON-NLS-1$
this.logger.trace("A new subscription to the representation has occurred {}", this.subscriptionCount.intValue());
}).doOnCancel(() -> {
this.subscriptionCount.updateAndGet(current -> Math.max(0, current - 1));
// $NON-NLS-1$
this.logger.trace("A new cancellation from the representation has occurred {}", this.subscriptionCount.intValue());
if (this.subscriptionCount.get() == 0) {
EmitResult emitResult = this.canBeDisposedSink.tryEmitNext(Boolean.TRUE);
if (emitResult.isFailure()) {
// $NON-NLS-1$
String pattern = "An error has occurred while emitting that the processor can be disposed: {}";
this.logger.warn(pattern, emitResult);
}
}
});
}
use of org.eclipse.sirius.components.core.api.IInput in project sirius-web by eclipse-sirius.
the class RenameDocumentEventHandlerTests method testRenameDocument.
@Test
public void testRenameDocument() {
IDocumentService noOpDocumentService = new IDocumentService.NoOp() {
@Override
public Optional<Document> rename(UUID documentId, String newName) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return Optional.of(new Document(documentId, new Project(UUID.randomUUID(), "", new Profile(UUID.randomUUID(), "username"), Visibility.PUBLIC), newName, "noContent"));
}
};
RenameDocumentEventHandler handler = new RenameDocumentEventHandler(noOpDocumentService, new NoOpServicesMessageService(), new SimpleMeterRegistry());
UUID documentId = UUID.randomUUID();
IInput input = new RenameDocumentInput(UUID.randomUUID(), documentId, NEW_NAME);
AdapterFactoryEditingDomain editingDomain = new EditingDomainFactory().create();
DocumentMetadataAdapter adapter = new DocumentMetadataAdapter(OLD_NAME);
Resource resource = new SiriusWebJSONResourceFactoryImpl().createResource(URI.createURI(documentId.toString()));
resource.eAdapters().add(adapter);
editingDomain.getResourceSet().getResources().add(resource);
assertThat(editingDomain.getResourceSet().getResources().size()).isEqualTo(1);
assertThat(adapter.getName()).isEqualTo(OLD_NAME);
IEditingContext editingContext = new EditingContext(UUID.randomUUID().toString(), editingDomain);
Many<ChangeDescription> changeDescriptionSink = Sinks.many().unicast().onBackpressureBuffer();
One<IPayload> payloadSink = Sinks.one();
assertThat(handler.canHandle(editingContext, input)).isTrue();
handler.handle(payloadSink, changeDescriptionSink, editingContext, input);
assertThat(editingDomain.getResourceSet().getResources().size()).isEqualTo(1);
assertThat(adapter.getName()).isEqualTo(NEW_NAME);
ChangeDescription changeDescription = changeDescriptionSink.asFlux().blockFirst();
assertThat(changeDescription.getKind()).isEqualTo(ChangeKind.SEMANTIC_CHANGE);
IPayload payload = payloadSink.asMono().block();
assertThat(payload).isInstanceOf(RenameDocumentSuccessPayload.class);
}
Aggregations