Search in sources :

Example 1 with SelectionConfiguration

use of org.eclipse.sirius.components.collaborative.selection.api.SelectionConfiguration in project sirius-components by eclipse-sirius.

the class SelectionEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (ISelectionEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof SelectionConfiguration) {
        SelectionConfiguration selectionConfiguration = (SelectionConfiguration) configuration;
        // @formatter:off
        Optional<SelectionDescription> optionalSelectionDescription = this.representationDescriptionSearchService.findById(editingContext, selectionConfiguration.getSelectionId()).filter(SelectionDescription.class::isInstance).map(SelectionDescription.class::cast);
        // @formatter:on
        Optional<Object> optionalObject = this.objectService.getObject(editingContext, selectionConfiguration.getTargetObjectId());
        if (optionalSelectionDescription.isPresent() && optionalObject.isPresent()) {
            SelectionDescription selectionDescription = optionalSelectionDescription.get();
            Object object = optionalObject.get();
            IRepresentationEventProcessor selectionEventProcessor = new SelectionEventProcessor(editingContext, selectionDescription, selectionConfiguration.getId(), object, this.subscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry);
            // @formatter:off
            return Optional.of(selectionEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
        // @formatter:on
        }
    }
    return Optional.empty();
}
Also used : ISelectionEventProcessor(org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor) SelectionDescription(org.eclipse.sirius.components.selection.description.SelectionDescription) SelectionConfiguration(org.eclipse.sirius.components.collaborative.selection.api.SelectionConfiguration) ISelectionEventProcessor(org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor) IRepresentationEventProcessor(org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)

Aggregations

IRepresentationEventProcessor (org.eclipse.sirius.components.collaborative.api.IRepresentationEventProcessor)1 ISelectionEventProcessor (org.eclipse.sirius.components.collaborative.selection.api.ISelectionEventProcessor)1 SelectionConfiguration (org.eclipse.sirius.components.collaborative.selection.api.SelectionConfiguration)1 SelectionDescription (org.eclipse.sirius.components.selection.description.SelectionDescription)1