Search in sources :

Example 1 with CellSelectionStrategy

use of org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy in project kie-wb-common by kiegroup.

the class LiteralExpressionUIModelMapperTest method testFromDmn_CellSelectionStrategy.

@Test
public void testFromDmn_CellSelectionStrategy() {
    mapper.fromDMNModel(0, 0);
    final CellSelectionStrategy strategy = uiModel.getCell(0, 0).getSelectionStrategy();
    strategy.handleSelection(uiModel, 0, 0, true, false);
    verify(parentGridUiCellCellSelectionStrategy).handleSelection(eq(parentGridUiModel), eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX), eq(true), eq(false));
}
Also used : CellSelectionStrategy(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy) Test(org.junit.Test)

Example 2 with CellSelectionStrategy

use of org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy in project kie-wb-common by kiegroup.

the class UndefinedExpressionUIModelMapperTest method testFromDMNCellSelectionStrategy.

@Test
public void testFromDMNCellSelectionStrategy() {
    mapper.fromDMNModel(0, 0);
    final CellSelectionStrategy strategy = uiModel.getCell(0, 0).getSelectionStrategy();
    strategy.handleSelection(uiModel, 0, 0, true, false);
    verify(parentGridUiCellCellSelectionStrategy).handleSelection(eq(parentGridUiModel), eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX), eq(true), eq(false));
}
Also used : CellSelectionStrategy(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy) Test(org.junit.Test)

Example 3 with CellSelectionStrategy

use of org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandler method selectCell.

private void selectCell(final int uiRowIndex, final int uiColumnIndex, final GridWidget gridWidget, final boolean isShiftKeyDown, final boolean isControlKeyDown) {
    // Lookup CellSelectionManager for cell
    final GridData gridModel = gridWidget.getModel();
    CellSelectionStrategy selectionStrategy;
    final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex);
    if (cell == null) {
        selectionStrategy = RangeSelectionStrategy.INSTANCE;
    } else {
        selectionStrategy = cell.getSelectionStrategy();
    }
    if (selectionStrategy == null) {
        return;
    }
    gridLayer.select(gridWidget);
    // Handle selection
    if (selectionStrategy.handleSelection(gridModel, uiRowIndex, uiColumnIndex, isShiftKeyDown, isControlKeyDown)) {
        gridWidget.getLayer().batch();
    }
}
Also used : GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) CellSelectionStrategy(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy)

Example 4 with CellSelectionStrategy

use of org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy in project kie-wb-common by kiegroup.

the class DMNGridPanelContextMenuHandlerTest method onContextMenu_WithGridWidget_WithCellSelectionStrategy_CellNotSelected.

@Test
public void onContextMenu_WithGridWidget_WithCellSelectionStrategy_CellNotSelected() {
    when(nativeEvent.getClientX()).thenReturn((int) (COLUMN0_WIDTH / 2));
    when(nativeEvent.getClientY()).thenReturn((int) (HEADER_HEIGHT + ROW_HEIGHT + ROW_HEIGHT / 2));
    final BaseGrid gridWidget = mockGridWidget();
    when(gridLayer.getGridWidgets()).thenReturn(Collections.singleton(gridWidget));
    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(cellSelectionHandler).selectCellIfRequired(eq(1), eq(0), eq(gridWidget), eq(false), eq(false));
}
Also used : 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 5 with CellSelectionStrategy

use of org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy 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)

Aggregations

CellSelectionStrategy (org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionStrategy)5 Test (org.junit.Test)4 BaseGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)2 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)2 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)1