use of org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.
the class ListGrid method clearExpressionType.
void clearExpressionType(final int uiRowIndex) {
final GridCellTuple gc = new GridCellTuple(uiRowIndex, ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX, this);
getExpression().get().ifPresent(list -> {
final HasExpression hasExpression = list.getExpression().get(uiRowIndex);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX);
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX);
}));
});
}
use of org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.
the class ListGridTest method clearRowExpression.
private ClearExpressionTypeCommand clearRowExpression(final int index) {
grid.clearExpressionType(index);
verify(sessionCommandManager).execute(eq(canvasHandler), clearExpressionTypeCommandCaptor.capture());
final ClearExpressionTypeCommand clearExpressionTypeCommand = clearExpressionTypeCommandCaptor.getValue();
clearExpressionTypeCommand.execute(canvasHandler);
return clearExpressionTypeCommand;
}
use of org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.
the class ListGridTest method testClearExpressionType.
@Test
public void testClearExpressionType() {
setupGrid();
final ClearExpressionTypeCommand clearExpressionTypeCommand = clearRowExpression(0);
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 LiteralExpressionEditor resized
assertThat(grid.getModel().getColumns().get(EXPRESSION_COLUMN_INDEX).getWidth()).isEqualTo(ExpressionEditorColumn.DEFAULT_WIDTH);
verify(grid).resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
verify(grid).selectExpressionEditorFirstCell(eq(0), eq(ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX));
verify(gridLayer).select(literalExpressionEditor);
verify(literalExpressionEditor).selectFirstCell();
verify(gridLayer).batch(redrawCommandCaptor.capture());
assertThat(redrawCommandCaptor.getAllValues()).hasSize(2);
redrawCommandCaptor.getAllValues().get(1).execute();
verify(gridLayer).draw();
}
Aggregations