Search in sources :

Example 1 with IDiagramEventHandler

use of org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler in project sirius-components by eclipse-sirius.

the class DiagramEventProcessor method handle.

@Override
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IRepresentationInput representationInput) {
    IRepresentationInput effectiveInput = representationInput;
    if (representationInput instanceof RenameRepresentationInput) {
        RenameRepresentationInput renameRepresentationInput = (RenameRepresentationInput) representationInput;
        effectiveInput = new RenameDiagramInput(renameRepresentationInput.getId(), renameRepresentationInput.getEditingContextId(), renameRepresentationInput.getRepresentationId(), renameRepresentationInput.getNewLabel());
    }
    if (effectiveInput instanceof IDiagramInput) {
        IDiagramInput diagramInput = (IDiagramInput) effectiveInput;
        Optional<IDiagramEventHandler> optionalDiagramEventHandler = this.diagramEventHandlers.stream().filter(handler -> handler.canHandle(diagramInput)).findFirst();
        if (optionalDiagramEventHandler.isPresent()) {
            IDiagramEventHandler diagramEventHandler = optionalDiagramEventHandler.get();
            diagramEventHandler.handle(payloadSink, changeDescriptionSink, this.editingContext, this.diagramContext, diagramInput);
        } else {
            // $NON-NLS-1$
            this.logger.warn("No handler found for event: {}", diagramInput);
        }
    }
}
Also used : IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) IDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput) LoggerFactory(org.slf4j.LoggerFactory) One(reactor.core.publisher.Sinks.One) DiagramDescription(org.eclipse.sirius.components.diagrams.description.DiagramDescription) IInput(org.eclipse.sirius.components.core.api.IInput) Diagram(org.eclipse.sirius.components.diagrams.Diagram) IRepresentation(org.eclipse.sirius.components.representations.IRepresentation) IRepresentationRefreshPolicyRegistry(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry) IDiagramEventProcessor(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor) ChangeKind(org.eclipse.sirius.components.collaborative.api.ChangeKind) ISubscriptionManager(org.eclipse.sirius.components.collaborative.api.ISubscriptionManager) Logger(org.slf4j.Logger) IDiagramContext(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext) ChangeDescription(org.eclipse.sirius.components.collaborative.api.ChangeDescription) RenameRepresentationInput(org.eclipse.sirius.components.collaborative.dto.RenameRepresentationInput) IRepresentationDescriptionSearchService(org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) IRepresentationRefreshPolicy(org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy) IDiagramCreationService(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramCreationService) Objects(java.util.Objects) RenameDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.dto.RenameDiagramInput) Flux(reactor.core.publisher.Flux) List(java.util.List) IPayload(org.eclipse.sirius.components.core.api.IPayload) IDiagramEventHandler(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler) Many(reactor.core.publisher.Sinks.Many) Optional(java.util.Optional) RenameDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.dto.RenameDiagramInput) IDiagramInput(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput) IDiagramEventHandler(org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler) IRepresentationInput(org.eclipse.sirius.components.core.api.IRepresentationInput) RenameRepresentationInput(org.eclipse.sirius.components.collaborative.dto.RenameRepresentationInput)

Aggregations

List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ChangeDescription (org.eclipse.sirius.components.collaborative.api.ChangeDescription)1 ChangeKind (org.eclipse.sirius.components.collaborative.api.ChangeKind)1 IRepresentationRefreshPolicy (org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicy)1 IRepresentationRefreshPolicyRegistry (org.eclipse.sirius.components.collaborative.api.IRepresentationRefreshPolicyRegistry)1 ISubscriptionManager (org.eclipse.sirius.components.collaborative.api.ISubscriptionManager)1 IDiagramContext (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramContext)1 IDiagramCreationService (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramCreationService)1 IDiagramEventHandler (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventHandler)1 IDiagramEventProcessor (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramEventProcessor)1 IDiagramInput (org.eclipse.sirius.components.collaborative.diagrams.api.IDiagramInput)1 RenameDiagramInput (org.eclipse.sirius.components.collaborative.diagrams.dto.RenameDiagramInput)1 RenameRepresentationInput (org.eclipse.sirius.components.collaborative.dto.RenameRepresentationInput)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 IInput (org.eclipse.sirius.components.core.api.IInput)1 IPayload (org.eclipse.sirius.components.core.api.IPayload)1 IRepresentationDescriptionSearchService (org.eclipse.sirius.components.core.api.IRepresentationDescriptionSearchService)1 IRepresentationInput (org.eclipse.sirius.components.core.api.IRepresentationInput)1