Search in sources :

Example 36 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple 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);
    final HasExpression hasExpression = expression.get().getBinding().get(uiRowIndex);
    sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> synchroniseViewWhenExpressionEditorChanged(this)));
}
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.general.ClearExpressionTypeCommand)

Example 37 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class CommandUtilsTest method testExtractCellValueNoValue.

@Test
public void testExtractCellValueNoValue() throws Exception {
    final int rowIndex = 123;
    final int columnIndex = 456;
    final GridData gridData = mock(GridData.class);
    final GridWidget gridWidget = mock(GridWidget.class);
    final GridCellTuple cellTuple = new GridCellTuple(rowIndex, columnIndex, gridWidget);
    doReturn(gridData).when(gridWidget).getModel();
    doReturn(null).when(gridData).getCell(rowIndex, columnIndex);
    Assertions.assertThat(CommandUtils.extractGridCellValue(cellTuple)).isEmpty();
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Example 38 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class CommandUtilsTest method testExtractCellValue.

@Test
public void testExtractCellValue() throws Exception {
    final int rowIndex = 123;
    final int columnIndex = 456;
    final GridCellValue gridCellValue = mock(GridCellValue.class);
    final GridCell gridCell = mock(GridCell.class);
    final GridData gridData = mock(GridData.class);
    final GridWidget gridWidget = mock(GridWidget.class);
    final GridCellTuple cellTuple = new GridCellTuple(rowIndex, columnIndex, gridWidget);
    doReturn(gridData).when(gridWidget).getModel();
    doReturn(gridCell).when(gridData).getCell(rowIndex, columnIndex);
    doReturn(gridCellValue).when(gridCell).getValue();
    Assertions.assertThat(CommandUtils.extractGridCellValue(cellTuple)).hasValue(gridCellValue);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) GridCellValue(org.uberfire.ext.wires.core.grids.client.model.GridCellValue) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) Test(org.junit.Test)

Example 39 with GridCellTuple

use of org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple in project kie-wb-common by kiegroup.

the class CommandUtilsTest method testUpdateParentInformation_WithMultipleColumns.

@Test
public void testUpdateParentInformation_WithMultipleColumns() {
    setupUiModel(Pair.newPair(new ExpressionEditorColumn(gridLayer, new BaseHeaderMetaData("column"), gridWidget), (rowIndex) -> {
        final BaseExpressionGrid grid = mock(BaseExpressionGrid.class);
        final GridCellTuple gct = new GridCellTuple(rowIndex, 0, mock(GridWidget.class));
        when(grid.getParentInformation()).thenReturn(gct);
        return new ExpressionCellValue(Optional.of(grid));
    }), Pair.newPair(new RowNumberColumn(), (rowIndex) -> new BaseGridCellValue<>(rowIndex + 1)));
    assertParentInformationValues(0);
    uiModel.moveColumnTo(0, uiModel.getColumns().get(1));
    CommandUtils.updateParentInformation(uiModel);
    assertParentInformationValues(1);
}
Also used : IntStream(java.util.stream.IntStream) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) Arrays(java.util.Arrays) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.layer.GridSelectionManager) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) Function(java.util.function.Function) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ArrayList(java.util.ArrayList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) LienzoMockitoTestRunner(com.ait.lienzo.test.LienzoMockitoTestRunner) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Assertions(org.assertj.core.api.Assertions) Assert.fail(org.junit.Assert.fail) Pair(org.uberfire.commons.data.Pair) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridPinnedModeManager(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.GridPinnedModeManager) List(java.util.List) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) GridCellValue(org.uberfire.ext.wires.core.grids.client.model.GridCellValue) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Optional(java.util.Optional) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.mock(org.mockito.Mockito.mock) RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Test(org.junit.Test)

Aggregations

GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)39 Test (org.junit.Test)19 Before (org.junit.Before)11 GridCellValueTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)10 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)8 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)8 TextBoxSingletonDOMElementFactory (org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory)8 Optional (java.util.Optional)6 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)6 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)5 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)5 Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)4 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)4 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)4 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)4