use of org.eclipse.sirius.components.collaborative.trees.api.ITreeInput in project sirius-components by eclipse-sirius.
the class TreePathEventHandler method handle.
@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, Tree tree, ITreeInput treeInput) {
IPayload payload = new TreePathSuccessPayload(treeInput.getId(), new TreePath(List.of(), 0));
ChangeDescription changeDescription = new ChangeDescription(ChangeKind.NOTHING, treeInput.getRepresentationId(), treeInput);
if (treeInput instanceof TreePathInput) {
TreePathInput input = (TreePathInput) treeInput;
Optional<ITreePathProvider> optionalPathProvider = this.treePathProviders.stream().filter(treePathProvider -> treePathProvider.canHandle(tree)).findFirst();
if (optionalPathProvider.isPresent()) {
IPayload resultPayload = optionalPathProvider.get().handle(editingContext, tree, input);
if (resultPayload instanceof TreePathSuccessPayload) {
payload = resultPayload;
} else if (resultPayload instanceof ErrorPayload) {
ErrorPayload errorPayload = (ErrorPayload) resultPayload;
this.logger.warn(errorPayload.getMessage());
}
}
}
changeDescriptionSink.tryEmitNext(changeDescription);
payloadSink.tryEmitValue(payload);
}
use of org.eclipse.sirius.components.collaborative.trees.api.ITreeInput in project sirius-components by eclipse-sirius.
the class TreeEventProcessor method handle.
@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IRepresentationInput representationInput) {
if (representationInput instanceof ITreeInput) {
ITreeInput treeInput = (ITreeInput) representationInput;
Optional<ITreeEventHandler> optionalTreeEventHandler = this.treeEventHandlers.stream().filter(handler -> handler.canHandle(treeInput)).findFirst();
if (optionalTreeEventHandler.isPresent()) {
ITreeEventHandler treeEventHandler = optionalTreeEventHandler.get();
treeEventHandler.handle(payloadSink, changeDescriptionSink, this.editingContext, this.currentTree.get(), treeInput);
} else {
// $NON-NLS-1$
this.logger.warn("No handler found for event: {}", treeInput);
}
}
}
Aggregations