use of org.eclipse.sirius.components.trees.Tree 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.trees.Tree in project sirius-components by eclipse-sirius.
the class TreeEventProcessor method refreshTree.
private Tree refreshTree() {
Tree tree = this.treeService.create(this.treeCreationParameters);
// $NON-NLS-1$
this.logger.trace("Tree refreshed: {}", this.treeCreationParameters.getEditingContext().getId());
return tree;
}
use of org.eclipse.sirius.components.trees.Tree in project sirius-components by eclipse-sirius.
the class TreeEventProcessor method refresh.
@Override
public void refresh(ChangeDescription changeDescription) {
if (this.shouldRefresh(changeDescription)) {
long start = System.currentTimeMillis();
Tree tree = this.refreshTree();
this.currentTree.set(tree);
if (this.sink.currentSubscriberCount() > 0) {
EmitResult emitResult = this.sink.tryEmitNext(new TreeRefreshedEventPayload(changeDescription.getInput().getId(), tree));
if (emitResult.isFailure()) {
// $NON-NLS-1$
String pattern = "An error has occurred while emitting a TreeRefreshedEventPayload: {}";
this.logger.warn(pattern, emitResult);
}
}
long end = System.currentTimeMillis();
this.timer.record(end - start, TimeUnit.MILLISECONDS);
}
}
Aggregations