Search in sources :

Example 41 with ExpressionCellValue

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

the class ExpressionContainerUIModelMapperTest method assertEditorType.

private void assertEditorType(final Class<?> clazz) {
    final GridCell<?> gridCell = uiModel.getCell(0, 0);
    assertThat(gridCell).isNotNull();
    assertThat(gridCell).isInstanceOf(ContextGridCell.class);
    final GridCellValue<?> gridCellValue = gridCell.getValue();
    assertThat(gridCellValue).isNotNull();
    assertThat(gridCellValue).isInstanceOf(ExpressionCellValue.class);
    final ExpressionCellValue ecv = (ExpressionCellValue) gridCellValue;
    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
    assertThat(editor.isPresent()).isTrue();
    assertThat(editor.get()).isInstanceOf(clazz);
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 42 with ExpressionCellValue

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

the class BaseExpressionGridGeneralTest method testSelectExpressionEditorFirstCell.

@Test
public void testSelectExpressionEditorFirstCell() {
    grid.getModel().appendRow(new BaseGridRow());
    appendColumns(GridColumn.class);
    final ExpressionCellValue cellValue = mock(ExpressionCellValue.class);
    final BaseExpressionGrid cellGrid = mock(BaseExpressionGrid.class);
    when(cellValue.getValue()).thenReturn(Optional.of(cellGrid));
    grid.getModel().setCellValue(0, 0, cellValue);
    grid.selectExpressionEditorFirstCell(0, 0);
    verify(gridLayer).select(cellGrid);
    verify(cellGrid).selectFirstCell();
}
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) Test(org.junit.Test)

Example 43 with ExpressionCellValue

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

the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithCellValueOfWrongType.

@Test
public void onContextMenu_WithGridWidget_WithCellValueOfWrongType() {
    when(nativeEvent.getClientX()).thenReturn((int) (COLUMN0_WIDTH / 2));
    when(nativeEvent.getClientY()).thenReturn((int) (ROW_HEIGHT + ROW_HEIGHT / 2));
    final BaseGrid gridWidget = mockGridWidget();
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
    gridWidget.getModel().setCellValue(1, 0, new ExpressionCellValue(Optional.empty()));
    handler.onContextMenu(event);
    verify(cellEditorControls, never()).show(any(HasCellEditorControls.Editor.class), anyInt(), anyInt());
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) Test(org.junit.Test)

Example 44 with ExpressionCellValue

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

the class ExpressionEditorGridRowTest method testRowHigherThanDefault.

@Test
@SuppressWarnings("unchecked")
public void testRowHigherThanDefault() {
    when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1);
    final GridRow row = spy(ExpressionEditorGridRow.class);
    final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>().put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))).build();
    when(row.getCells()).thenReturn(cells);
    assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT);
}
Also used : BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) Test(org.junit.Test)

Example 45 with ExpressionCellValue

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

the class ExpressionEditorGridRowTest method testRowLowerThanDefault.

@Test
@SuppressWarnings("unchecked")
public void testRowLowerThanDefault() {
    when(view.getHeight()).thenReturn(DEFAULT_HEIGHT - 1);
    final GridRow row = spy(ExpressionEditorGridRow.class);
    final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>().put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))).build();
    when(row.getCells()).thenReturn(cells);
    assertThat(row.getHeight()).isBetween(0D, DEFAULT_HEIGHT);
}
Also used : BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) 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