use of org.eclipse.sirius.components.selection.description.SelectionDescription 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();
}
use of org.eclipse.sirius.components.selection.description.SelectionDescription in project sirius-components by eclipse-sirius.
the class SelectModelElementVariableConverter method convert.
@Override
public SelectionDescription convert(SelectModelElementVariable selectModelElementVariable, org.eclipse.sirius.diagram.description.DiagramDescription diagramDescription) {
AQLInterpreter interpreter = this.interpreterFactory.create(diagramDescription);
// @formatter:off
SelectionDescription selectionDescription = SelectionDescription.newSelectionDescription(UUID.fromString(this.identifierProvider.getIdentifier(selectModelElementVariable))).objectsProvider(variableManager -> {
Result result = interpreter.evaluateExpression(variableManager.getVariables(), selectModelElementVariable.getCandidatesExpression());
return result.asObjects().orElse(List.of()).stream().filter(Objects::nonNull).collect(Collectors.toList());
}).messageProvider(variableManager -> {
String message = selectModelElementVariable.getMessage();
if (message == null) {
// $NON-NLS-1$
message = "";
}
return message;
}).idProvider(new GetOrCreateRandomIdProvider()).labelProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getLabel).orElse(null)).iconURLProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getImagePath).orElse(null)).targetObjectIdProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null)).selectionObjectsIdProvider(variableManager -> variableManager.get(VariableManager.SELF, Object.class).map(this.objectService::getId).orElse(null)).label(// $NON-NLS-1$
"Selection Description").canCreatePredicate(variableManager -> false).build();
// @formatter:on
return selectionDescription;
}
Aggregations