use of org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand 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;
}));
});
}
use of org.kie.workbench.common.dmn.client.commands.expressions.types.undefined.SetCellValueCommand in project kie-wb-common by kiegroup.
the class UndefinedExpressionGridTest method assertOnExpressionTypeChanged.
@SuppressWarnings("unchecked")
private void assertOnExpressionTypeChanged(final int nesting) {
setupGrid(nesting);
grid.onExpressionTypeChanged(ExpressionType.LITERAL_EXPRESSION);
verify(sessionCommandManager).execute(eq(canvasHandler), setCellValueCommandArgumentCaptor.capture());
final SetCellValueCommand setCellValueCommand = setCellValueCommandArgumentCaptor.getValue();
setCellValueCommand.execute(canvasHandler);
verify(literalExpressionEditorDefinition).getEditor(eq(parent), eq(nesting == 0 ? Optional.of(NODE_UUID) : Optional.empty()), eq(hasExpression), eq(hasName), eq(false), eq(nesting));
assertResize(BaseExpressionGrid.RESIZE_EXISTING);
verify(literalExpressionEditor).selectCell(eq(0), eq(0), eq(false), eq(false));
verify(literalExpressionEditor).selectFirstCell();
verify(gridPanel).setFocus(true);
reset(gridPanel, gridLayer, parent);
setupParent();
setCellValueCommand.undo(canvasHandler);
assertResize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
verify(gridLayer).select(grid);
verify(grid).selectCell(eq(0), eq(0), eq(false), eq(false));
}
Aggregations