use of org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionType in project kie-wb-common by kiegroup.
the class UndefinedExpressionGrid method onExpressionTypeChanged.
public void onExpressionTypeChanged(final ExpressionType type) {
final Optional<Expression> expression = expressionEditorDefinitionsSupplier.get().stream().filter(e -> e.getType().equals(type)).map(ExpressionEditorDefinition::getModelClass).findFirst().get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetCellValueCommand(parent, nodeUUID, hasExpression, () -> expression, expressionGridCache, (editor) -> {
resize(BaseExpressionGrid.RESIZE_EXISTING);
editor.ifPresent(BaseExpressionGrid::selectFirstCell);
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectCell(0, 0, false, false);
}, () -> {
Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = Optional.empty();
if (nodeUUID.isPresent()) {
final String uuid = nodeUUID.get();
editor = expressionGridCache.getExpressionGrid(uuid);
}
if (!editor.isPresent()) {
ed.enrich(nodeUUID, hasExpression, expression);
editor = ed.getEditor(parent, nodeUUID, hasExpression, hasName, isOnlyVisualChangeAllowed, nesting);
}
return editor;
}));
});
}
Aggregations