use of org.eclipse.sirius.viewpoint.description.tool.ExternalJavaActionParameter in project sirius-components by eclipse-sirius.
the class ExternalJavaActionOperationHandler method handle.
@Override
public IStatus handle(Map<String, Object> variables) {
// @formatter:off
var optionalExternalJavaAction = this.externalJavaActionProviders.stream().map(provider -> provider.findById(this.externalJavaAction.getId())).flatMap(Optional::stream).findFirst();
if (optionalExternalJavaAction.isEmpty()) {
// $NON-NLS-1$
this.logger.warn("Unable to find external java action from id:{}", this.externalJavaAction.getId());
// $NON-NLS-1$
return new Failure("");
} else {
IExternalJavaAction javaAction = optionalExternalJavaAction.get();
Map<String, Object> parameters = new HashMap<>();
for (ExternalJavaActionParameter parameter : this.externalJavaAction.getParameters()) {
Optional<Object> value = this.interpreter.evaluateExpression(variables, parameter.getValue()).asObject();
value.ifPresent(it -> parameters.put(parameter.getName(), it));
}
Object object = variables.get(VariableManager.SELF);
if (object instanceof EObject && javaAction.canExecute(List.of((EObject) object))) {
javaAction.execute(List.of((EObject) object), parameters);
}
}
List<ModelOperation> subModelOperations = this.externalJavaAction.getSubModelOperations();
return this.childModelOperationHandler.handle(this.objectService, this.representationMetadataSearchService, this.identifierProvider, this.interpreter, variables, subModelOperations);
}
Aggregations