Search in sources :

Example 61 with ExpressionCellValue

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

the class RelationColumnTest method assertMinimumWidth.

@SafeVarargs
private final void assertMinimumWidth(final double peerWidth, final double relationGridWidth, final double expectedMinimumWidth, final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>>... peers) {
    doReturn(peerWidth).when(peerExpressionEditor).getMinimumWidth();
    doReturn(relationGridWidth).when(gridWidget).getWidth();
    for (int i = 0; i < peers.length; i++) {
        parentUiModel.setCellValue(i + 1, 0, new ExpressionCellValue(peers[i]));
    }
    assertEquals(expectedMinimumWidth, column.getMinimumWidth(), 0.0);
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 62 with ExpressionCellValue

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

the class UndefinedExpressionUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(uiColumn);
    this.uiModel.appendRow(new BaseGridRow());
    this.mapper = new UndefinedExpressionUIModelMapper(() -> uiModel, () -> Optional.ofNullable(expression), listSelector, translationService, hasExpression);
    this.cellValueSupplier = () -> Optional.of(new ExpressionCellValue(Optional.of(editor)));
    when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(hasExpressionDMNModelInstrumentedBase);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 63 with ExpressionCellValue

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

the class DMNGridLayerTest method testSelectNestedGridWidget.

@Test
public void testSelectNestedGridWidget() {
    final GridWidget gridWidget = mock(GridWidget.class);
    final GridData gridData = new BaseGridData(false);
    gridData.appendRow(new BaseGridRow());
    gridData.appendColumn(mock(GridColumn.class));
    gridData.setCellValue(0, 0, new ExpressionCellValue(Optional.of(expressionGrid)));
    gridLayer.register(gridWidget);
    gridLayer.register(expressionGrid);
    assertThat(gridLayer.getSelectedGridWidget().isPresent()).isFalse();
    // Select nested grid
    when(gridWidget.getModel()).thenReturn(gridData);
    when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
    gridLayer.select(expressionGrid);
    assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
    assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(expressionGrid);
    verify(expressionGrid).select();
    verify(gridLayer).batch();
    // Select outer grid, deselecting nested grid
    reset(gridLayer, gridWidget, expressionGrid);
    when(gridWidget.getModel()).thenReturn(gridData);
    when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
    when(expressionGrid.isSelected()).thenReturn(true);
    gridLayer.select(gridWidget);
    assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
    assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(gridWidget);
    verify(gridWidget).select();
    verify(expressionGrid).deselect();
    verify(gridLayer).batch();
    // Reselect outer grid, there should be no change in selections and the GridLayer should not be redrawn
    reset(gridLayer, gridWidget, expressionGrid);
    when(gridWidget.getModel()).thenReturn(gridData);
    when(gridWidget.isSelected()).thenReturn(true);
    when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
    when(expressionGrid.isSelected()).thenReturn(false);
    gridLayer.select(gridWidget);
    verify(gridWidget, never()).select();
    verify(expressionGrid, never()).deselect();
    verify(gridLayer, never()).batch();
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Test(org.junit.Test)

Aggregations

ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)63 Test (org.junit.Test)28 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)22 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)21 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)17 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)14 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)12 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)11 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)10 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)9 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)9 Optional (java.util.Optional)8 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)8 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)8 Before (org.junit.Before)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)6 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)6