use of org.eclipse.sirius.components.compatibility.utils.BooleanValueProvider in project sirius-components by eclipse-sirius.
the class WidgetDescriptionConverter method convertCheckbox.
private CheckboxDescription convertCheckbox(org.eclipse.sirius.properties.CheckboxDescription checkboxDescription) {
StringValueProvider labelProvider = new StringValueProvider(this.interpreter, checkboxDescription.getLabelExpression());
BiFunction<VariableManager, Boolean, IStatus> newValueHandler = (variableManager, newValue) -> {
Map<String, Object> variables = variableManager.getVariables();
variables.put(NEW_VALUE, newValue);
InitialOperation initialOperation = checkboxDescription.getInitialOperation();
ModelOperation modelOperation = initialOperation.getFirstModelOperations();
var modelOperationHandlerSwitch = this.modelOperationHandlerSwitchProvider.getModelOperationHandlerSwitch(this.interpreter);
Optional<IModelOperationHandler> optionalModelOperationHandler = modelOperationHandlerSwitch.apply(modelOperation);
return optionalModelOperationHandler.map(handler -> {
return handler.handle(variables);
}).orElse(// $NON-NLS-1$
new Failure(""));
};
// $NON-NLS-1$
String valueExpression = Optional.ofNullable(checkboxDescription.getValueExpression()).orElse("");
Function<VariableManager, Boolean> valueProvider = new BooleanValueProvider(this.interpreter, valueExpression);
// @formatter:off
return CheckboxDescription.newCheckboxDescription(this.identifierProvider.getIdentifier(checkboxDescription)).idProvider(new WidgetIdProvider()).labelProvider(labelProvider).valueProvider(valueProvider).newValueHandler(newValueHandler).diagnosticsProvider((variableManager) -> List.of()).kindProvider(// $NON-NLS-1$
(object) -> "").messageProvider(// $NON-NLS-1$
(object) -> "").build();
// @formatter:on
}
use of org.eclipse.sirius.components.compatibility.utils.BooleanValueProvider in project sirius-components by eclipse-sirius.
the class IfDescriptionConverter method convert.
public Optional<IfDescription> convert(org.eclipse.sirius.properties.DynamicMappingIfDescription siriusIfDescription) {
BooleanValueProvider predicate = new BooleanValueProvider(this.interpreter, siriusIfDescription.getPredicateExpression());
WidgetDescriptionConverter converter = new WidgetDescriptionConverter(this.interpreter, this.objectService, this.identifierProvider, this.modelOperationHandlerSwitchProvider);
Optional<AbstractWidgetDescription> optionalWidgetDescription = converter.convert(siriusIfDescription.getWidget());
return optionalWidgetDescription.map(widgetDescription -> {
// @formatter:off
return IfDescription.newIfDescription(this.identifierProvider.getIdentifier(siriusIfDescription)).predicate(predicate).widgetDescription(widgetDescription).build();
// @formatter:on
});
}
Aggregations