use of org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.
the class InvocationGrid method clearExpressionType.
void clearExpressionType(final int uiRowIndex) {
final GridCellTuple gc = new GridCellTuple(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX, this);
getExpression().get().ifPresent(invocation -> {
final HasExpression hasExpression = invocation.getBinding().get(uiRowIndex);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX);
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX);
}));
});
}
use of org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.
the class InvocationGridTest method testClearExpressionType.
@Test
public void testClearExpressionType() {
setupGrid(0);
grid.clearExpressionType(0);
verify(sessionCommandManager).execute(eq(canvasHandler), clearExpressionTypeCommandCaptor.capture());
final ClearExpressionTypeCommand clearExpressionTypeCommand = clearExpressionTypeCommandCaptor.getValue();
clearExpressionTypeCommand.execute(canvasHandler);
verify(grid).resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
verify(gridLayer).select(undefinedExpressionEditor);
verify(undefinedExpressionEditor).selectFirstCell();
verify(gridLayer).batch(redrawCommandCaptor.capture());
redrawCommandCaptor.getValue().execute();
verify(gridLayer).draw();
// Check undo operation
reset(grid, gridLayer);
clearExpressionTypeCommand.undo(canvasHandler);
// Verify Expression has been restored and UndefinedExpressionEditor resized
assertThat(grid.getModel().getColumns().get(2).getWidth()).isEqualTo(UndefinedExpressionColumn.DEFAULT_WIDTH);
verify(grid).resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
verify(grid).selectExpressionEditorFirstCell(eq(0), eq(InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX));
verify(gridLayer).select(undefinedExpressionEditor);
verify(undefinedExpressionEditor, times(2)).selectFirstCell();
verify(gridLayer).batch(redrawCommandCaptor.capture());
assertThat(redrawCommandCaptor.getAllValues()).hasSize(2);
redrawCommandCaptor.getAllValues().get(1).execute();
verify(gridLayer).draw();
}
Aggregations