Search in sources :

Example 1 with ClearExpressionTypeCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.context.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.

the class ContextGridTest 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(ContextUIModelMapperHelper.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();
}
Also used : ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.context.ClearExpressionTypeCommand) Test(org.junit.Test)

Example 2 with ClearExpressionTypeCommand

use of org.kie.workbench.common.dmn.client.commands.expressions.types.context.ClearExpressionTypeCommand in project kie-wb-common by kiegroup.

the class ContextGrid method clearExpressionType.

void clearExpressionType(final int uiRowIndex) {
    final GridCellTuple gc = new GridCellTuple(uiRowIndex, ContextUIModelMapperHelper.EXPRESSION_COLUMN_INDEX, this);
    getExpression().get().ifPresent(context -> {
        final HasExpression hasExpression = context.getContextEntry().get(uiRowIndex);
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> {
            resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
            selectExpressionEditorFirstCell(uiRowIndex, ContextUIModelMapperHelper.EXPRESSION_COLUMN_INDEX);
        }, () -> {
            resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
            selectExpressionEditorFirstCell(uiRowIndex, ContextUIModelMapperHelper.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.context.ClearExpressionTypeCommand)

Aggregations

ClearExpressionTypeCommand (org.kie.workbench.common.dmn.client.commands.expressions.types.context.ClearExpressionTypeCommand)2 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