Search in sources :

Example 1 with ClearExpressionTypeCommand

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);
        }));
    });
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand)

Example 2 with 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 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;
}
Also used : ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand)

Example 3 with 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();
}
Also used : ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand) Test(org.junit.Test)

Aggregations

ClearExpressionTypeCommand (org.kie.workbench.common.dmn.client.commands.expressions.types.list.ClearExpressionTypeCommand)3 Test (org.junit.Test)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)1