void selectExpressionEditorFirstCell() { final GridCellValue<?> value = model.getCell(0, 0).getValue(); final Optional<BaseExpressionGrid> grid = ((ExpressionCellValue) value).getValue(); grid.ifPresent(beg -> { //It's not possible to set-up GridLayer for ExpressionContainerGrid in Unit Tests so defensively handle nulls Optional.ofNullable(getLayer()).ifPresent(layer -> ((DMNGridLayer) layer).select(beg)); beg.selectFirstCell(); }); }
public void onInsertColumn(final int index) { final List<GridData.SelectedCell> selectedCells = gridData.getSelectedCells(); final List<Integer> rowsWithASelection = selectedCells.stream() .filter(sc -> { final int ri = sc.getRowIndex(); final int ci = sc.getColumnIndex(); final int _ci = ColumnIndexUtilities.findUiColumnIndex(gridData.getColumns(), ci); final GridCell<?> cell = gridData.getCell(ri, _ci); return cell != null && cell.getSelectionStrategy() instanceof RowSelectionStrategy; }) .map(GridData.SelectedCell::getRowIndex) .collect(Collectors.toList()); rowsWithASelection.forEach(rowIndex -> onSelectCell(rowIndex, index)); }
public void onInsertColumn(final int index) { final List<GridData.SelectedCell> selectedCells = gridData.getSelectedCells(); final List<Integer> rowsWithASelection = selectedCells.stream() .filter(sc -> { final int ri = sc.getRowIndex(); final int ci = sc.getColumnIndex(); final int _ci = ColumnIndexUtilities.findUiColumnIndex(gridData.getColumns(), ci); final GridCell<?> cell = gridData.getCell(ri, _ci); return cell != null && cell.getSelectionStrategy() instanceof RowSelectionStrategy; }) .map(GridData.SelectedCell::getRowIndex) .collect(Collectors.toList()); rowsWithASelection.forEach(rowIndex -> onSelectCell(rowIndex, index)); }
private double getMergedCellHeight(final int uiRowIndex, final int uiColumnIndex) { double height = 0; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); for (int i = uiRowIndex; i < uiRowIndex + cell.getMergedCellCount(); i++) { height = height + gridModel.getRow(i).getHeight(); } return height; }
private double getMergedCellHeight(final int uiRowIndex, final int uiColumnIndex) { double height = 0; final GridCell<?> cell = gridModel.getCell(uiRowIndex, uiColumnIndex); for (int i = uiRowIndex; i < uiRowIndex + cell.getMergedCellCount(); i++) { height = height + gridModel.getRow(i).getHeight(); } return height; }
@Test public void testIsCollapsedCellMixedValue() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isFalse(); }
public static Optional<GridCellValue<?>> extractGridCellValue(final GridCellTuple cellTuple) { final GridCell<?> cell = cellTuple.getGridWidget().getModel().getCell(cellTuple.getRowIndex(), cellTuple.getColumnIndex()); return Optional.ofNullable(cell == null ? null : cell.getValue()); } }
public void selectExpressionEditorFirstCell(final int uiRowIndex, final int uiColumnIndex) { final GridCellValue<?> value = model.getCell(uiRowIndex, uiColumnIndex).getValue(); final Optional<BaseExpressionGrid> grid = ((ExpressionCellValue) value).getValue(); grid.ifPresent(beg -> { ((DMNGridLayer) getLayer()).select(beg); beg.selectFirstCell(); }); }
@Test public void testIsCollapsedCellMixedValueOneDifferentValue_2() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("two", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueOneDifferentValue_3() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("two", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueThreeDifferentValues() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("two", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("three", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueOneDifferentValue_1() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("two", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueThreeDifferentValues() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("two", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("three", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueOneDifferentValue_1() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("two", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueOneDifferentValue_2() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("two", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValueOneDifferentValue_3() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("two", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isTrue(); }
@Test public void testIsCollapsedCellMixedValue() throws Exception { final GridCell<String> cellOne = gridCellWithMockedMergedCellCount("one", 3); final GridCell<String> cellTwo = gridCellWithMockedMergedCellCount("one", 0); final GridCell<String> cellThree = gridCellWithMockedMergedCellCount("one", 0); doReturn(3).when(gridData).getRowCount(); doReturn(cellOne).when(gridData).getCell(0, 0); doReturn(cellTwo).when(gridData).getCell(1, 0); doReturn(cellThree).when(gridData).getCell(2, 0); doReturn(true).when(gridRow).isCollapsed(); Assertions.assertThat(ColumnRenderingStrategyMerged.isCollapsedCellMixedValue(gridData, 2, 0)).isFalse(); }
@Test @SuppressWarnings("unchecked") public void testEditBodyCellWithASelectedCell() { when(uiModel.getSelectedCells()).thenReturn(Collections.singletonList(new GridData.SelectedCell(0, 1))); when(uiModel.getCell(eq(0), eq(1))).thenReturn(gridCell); when(gridCell.getSupportedEditAction()).thenReturn(GridCellEditAction.DOUBLE_CLICK); assertThat(handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event)).isFalse(); verify(gridWidget, never()).startEditingCell(anyInt(), anyInt()); verify(gridWidget).startEditingCell(eq(relativeLocation)); }
@Test @SuppressWarnings("unchecked") public void testEditBodyCellWithANullSelectedCell() { when(uiModel.getSelectedCells()).thenReturn(Collections.singletonList(new GridData.SelectedCell(0, 1))); when(uiModel.getCell(eq(0), eq(1))).thenReturn(null); assertThat(handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event)).isFalse(); verify(gridWidget, never()).startEditingCell(anyInt(), anyInt()); verify(gridWidget).startEditingCell(eq(relativeLocation)); }
@Test @SuppressWarnings("unchecked") public void testEditBodyCellWithASelectedCell() { when(uiModel.getSelectedCells()).thenReturn(Collections.singletonList(new GridData.SelectedCell(0, 1))); when(uiModel.getCell(eq(0), eq(1))).thenReturn(gridCell); when(gridCell.getSupportedEditAction()).thenReturn(GridCellEditAction.DOUBLE_CLICK); assertThat(handler.onNodeMouseEvent(gridWidget, relativeLocation, Optional.empty(), Optional.empty(), Optional.of(0), Optional.of(1), event)).isFalse(); verify(gridWidget, never()).startEditingCell(anyInt(), anyInt()); verify(gridWidget).startEditingCell(eq(relativeLocation)); }