Search in sources :

Example 11 with BaseGrid

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

the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithCellSelectionStrategy_CellAlreadySelected.

@Test
public void onContextMenu_WithGridWidget_WithCellSelectionStrategy_CellAlreadySelected() {
    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.selectCell(1, 0, false, false);
    final MockCell cell = mock(MockCell.class);
    final CellSelectionStrategy selectionStrategy = mock(CellSelectionStrategy.class);
    gridWidget.getModel().setCell(1, 0, () -> cell);
    when(cell.getEditor()).thenReturn(Optional.of(editor));
    when(cell.getSelectionStrategy()).thenReturn(selectionStrategy);
    handler.onContextMenu(event);
    verify(selectionStrategy, never()).handleSelection(any(GridData.class), anyInt(), anyInt(), anyBoolean(), anyBoolean());
}
Also used : GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) CellSelectionStrategy(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy) BaseGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid) Test(org.junit.Test)

Example 12 with BaseGrid

use of org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid 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)

Aggregations

BaseGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)12 Test (org.junit.Test)9 DMNGridColumn (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)2 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)2 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)2 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)2 CellSelectionStrategy (org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy)2 Layer (com.ait.lienzo.client.core.shape.Layer)1 LinkedHashSet (java.util.LinkedHashSet)1 Optional (java.util.Optional)1 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)1 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)1 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)1 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)1 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)1 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)1 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)1 GridColumnRenderer (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer)1