protected static boolean isCollapsedRowMultiValue(final GridData model, final GridColumn<?> column, final GridCell<?> cell, final int rowIndex) { GridRow row; int rowOffset = 1; final int columnIndex = column.getIndex(); //Iterate collapsed rows checking if the values differ while ((row = model.getRow(rowIndex - rowOffset)).isCollapsed()) { final GridCell<?> nc = row.getCells().get(columnIndex); if (!Objects.equals(nc, cell)) { return true; } rowOffset++; } //Check "lead" row as well - since this is not marked as collapsed final GridCell<?> nc = row.getCells().get(columnIndex); if (!Objects.equals(nc, cell)) { return true; } return false; }
protected static double getCellHeight(final int rowIndex, final GridData model, final GridCell<?> cell) { return IntStream.range(rowIndex, rowIndex + cell.getMergedCellCount()) .mapToDouble(index -> model.getRow(index).getHeight()) .sum(); }
@Override public Range deleteRow(final int rowIndex) { //Find row that is the "lead" in a merged collapsed block GridRow row; int minRowIndex = rowIndex; int maxRowIndex = rowIndex; while ((row = rows.get(minRowIndex)).isMerged() && row.isCollapsed() && minRowIndex > 0) { minRowIndex--; } //Find last row in a merged collapsed block do { maxRowIndex++; } while (maxRowIndex < rows.size() && rows.get(maxRowIndex).isCollapsed()); maxRowIndex--; final Range range = new Range(minRowIndex, maxRowIndex); for (int _rowIndex = minRowIndex; _rowIndex <= maxRowIndex; _rowIndex++) { rows.remove(minRowIndex); } indexManager.onDeleteRow(range); selectionsManager.onDeleteRow(range); return range; }
final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); final BaseGridCell cell = ((BaseGridCell) row.getCells().get(columnIndex)); if (maxRowIndex > expandMaxRowIndex) { final GridRow bottomSplitRow = rows.get(expandMaxRowIndex); if (bottomSplitRow.isCollapsed()) { final BaseGridCell bottomSplitRowCell = ((BaseGridCell) bottomSplitRow.getCells().get(columnIndex)); if (bottomSplitRowCell != null) { bottomSplitRowCell.setMergedCellCount(maxRowIndex - expandMaxRowIndex); bottomSplitRow.expand(); if (cell != null) { cell.setMergedCellCount(expandMaxRowIndex - minRowIndex);
@Override public GridCell<?> getCell(final int rowIndex, final int columnIndex) { if (rowIndex < 0 || rowIndex > rows.size() - 1) { return null; } final int _columnIndex = columns.get(columnIndex).getIndex(); return rows.get(rowIndex).getCells().get(_columnIndex); }
final GridRendererTheme theme = renderer.getTheme(); final double columnWidth = column.getWidth(); final double columnHeight = visibleRowOffsets.get(maxVisibleRowIndex - minVisibleRowIndex) - visibleRowOffsets.get(0) + model.getRow(maxVisibleRowIndex).getHeight(); final int columnIndex = model.getColumns().indexOf(column); if (!row.isMerged()) { } else if (!row.isCollapsed()) { if (row.isCollapsed()) { continue; row.getHeight()); mixedValueGroup.setX(0).setY(y).setListening(true); columnGroup.add(mixedValueGroup); if (nextRowCell != null) { final Group gt = renderGroupedCellToggle(columnWidth, row.getHeight(), nextRowCell.isCollapsed()); gt.setX(0).setY(y); while (_cell.getMergedCellCount() == 0) { _rowIndex--; _y = _y - model.getRow(_rowIndex).getHeight(); _cell = model.getCell(_rowIndex, columnIndex);
int uiRowIndex = 0; double offsetY = cy - renderer.getHeaderHeight(); while ((row = gridModel.getRow(uiRowIndex)).getHeight() < offsetY) { offsetY = offsetY - row.getHeight(); uiRowIndex++; while (uiRowIndex + 1 < gridModel.getRowCount() && (collapsedRow = gridModel.getRow(uiRowIndex + 1)).isCollapsed()) { rows.add(collapsedRow); uiRowIndex++;
final List<GridColumn<?>> columns = gridData.getColumns(); final GridRow currentRow = rows.get(rowIndex); final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); minRowIndex--; final GridRow previousRow = rows.get(minRowIndex); final GridCell<?> previousRowCell = previousRow.getCells().get(columnIndex); if (previousRowCell.getMergedCellCount() > 0) { break; final GridCell<?> nextRowCell = nextRow.getCells().get(columnIndex); if (nextRowCell == null) { break; rows.get(i).collapse();
final List<GridColumn<?>> columns = gridData.getColumns(); final GridRow currentRow = rows.get(rowIndex); final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); minRowIndex--; final GridRow previousRow = rows.get(minRowIndex); final GridCell<?> previousRowCell = previousRow.getCells().get(columnIndex); if (previousRowCell == null) { break; final GridCell<?> nextRowCell = nextRow.getCells().get(columnIndex); if (nextRowCell == null) { break; rows.get(i).expand();
@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(); }
@Override public void onFrame(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Set the rows' height to their starting height down to zero final double pct = assertPct(iAnimation.getPercent()); for (int i = 1; i < rowCount; i++) { final GridRow row = gridWidget.getModel().getRow(uiRowIndex + i); row.setHeight((1.0 - pct) * row.peekHeight()); } gridWidget.getLayer().batch(); }
@Test public void testInitialSetup_NoMerging() { final GridData data = new BaseGridData(); final GridColumn<String> gc1 = new MockMergableGridColumn<String>("col1", 100); final GridColumn<String> gc2 = new MockMergableGridColumn<String>("col2", 100); data.appendColumn(gc1); data.appendColumn(gc2); data.appendRow(new BaseGridRow()); data.appendRow(new BaseGridRow()); data.appendRow(new BaseGridRow()); for (int rowIndex = 0; rowIndex < data.getRowCount(); rowIndex++) { for (int columnIndex = 0; columnIndex < data.getColumnCount(); columnIndex++) { data.setCellValue(rowIndex, columnIndex, new BaseGridCellValue<String>("(" + columnIndex + ", " + rowIndex + ")")); } } for (int rowIndex = 0; rowIndex < data.getRowCount(); rowIndex++) { assertFalse(data.getRow(rowIndex).isMerged()); for (int columnIndex = 0; columnIndex < data.getColumnCount(); columnIndex++) { final GridCell<?> cell = data.getCell(rowIndex, columnIndex); assertFalse(cell.isMerged()); assertEquals(1, cell.getMergedCellCount()); } } }
@Override public void onStart(final IAnimation iAnimation, final IAnimationHandle iAnimationHandle) { //Store the rows' target heights for (int i = 0; i < rowCount; i++) { final GridRow row = gridWidget.getModel().getRow(uiRowIndex + i); heights.add(row.peekHeight()); } //Mark cells as expanded gridWidget.getModel().expandCell(uiRowIndex, uiColumnIndex); }
final GridRow row = rows.get(i); ((BaseGridRow) row).deleteCell(_columnIndex); row.expand();
@Override public GridCell<?> getCell(final int rowIndex, final int columnIndex) { if (rowIndex < 0 || rowIndex > rows.size() - 1) { return null; } final int _columnIndex = columns.get(columnIndex).getIndex(); return rows.get(rowIndex).getCells().get(_columnIndex); }
final GridRendererTheme theme = renderer.getTheme(); final double columnWidth = column.getWidth(); final double columnHeight = visibleRowOffsets.get(maxVisibleRowIndex - minVisibleRowIndex) - visibleRowOffsets.get(0) + model.getRow(maxVisibleRowIndex).getHeight(); final int columnIndex = model.getColumns().indexOf(column); if (!row.isMerged()) { } else if (!row.isCollapsed()) { if (row.isCollapsed()) { continue; row.getHeight()); mixedValueGroup.setX(0).setY(y).setListening(true); columnGroup.add(mixedValueGroup); if (nextRowCell != null) { final Group gt = renderGroupedCellToggle(columnWidth, row.getHeight(), nextRowCell.isCollapsed()); gt.setX(0).setY(y); while (_cell.getMergedCellCount() == 0) { _rowIndex--; _y = _y - model.getRow(_rowIndex).getHeight(); _cell = model.getCell(_rowIndex, columnIndex);
final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); final BaseGridCell cell = ((BaseGridCell) row.getCells().get(columnIndex)); if (maxRowIndex > expandMaxRowIndex) { final GridRow bottomSplitRow = rows.get(expandMaxRowIndex); if (bottomSplitRow.isCollapsed()) { final BaseGridCell bottomSplitRowCell = ((BaseGridCell) bottomSplitRow.getCells().get(columnIndex)); if (bottomSplitRowCell != null) { bottomSplitRowCell.setMergedCellCount(maxRowIndex - expandMaxRowIndex); bottomSplitRow.expand(); if (cell != null) { cell.setMergedCellCount(expandMaxRowIndex - minRowIndex);
int uiRowIndex = 0; double offsetY = cy - renderer.getHeaderHeight(); while ((row = gridModel.getRow(uiRowIndex)).getHeight() < offsetY) { offsetY = offsetY - row.getHeight(); uiRowIndex++; while (uiRowIndex + 1 < gridModel.getRowCount() && (collapsedRow = gridModel.getRow(uiRowIndex + 1)).isCollapsed()) { rows.add(collapsedRow); uiRowIndex++;
final List<GridColumn<?>> columns = gridData.getColumns(); final GridRow currentRow = rows.get(rowIndex); final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); minRowIndex--; final GridRow previousRow = rows.get(minRowIndex); final GridCell<?> previousRowCell = previousRow.getCells().get(columnIndex); if (previousRowCell.getMergedCellCount() > 0) { break; final GridCell<?> nextRowCell = nextRow.getCells().get(columnIndex); if (nextRowCell == null) { break; rows.get(i).collapse();
final List<GridColumn<?>> columns = gridData.getColumns(); final GridRow currentRow = rows.get(rowIndex); final GridCell<?> currentRowCell = currentRow.getCells().get(columnIndex); minRowIndex--; final GridRow previousRow = rows.get(minRowIndex); final GridCell<?> previousRowCell = previousRow.getCells().get(columnIndex); if (previousRowCell == null) { break; final GridCell<?> nextRowCell = nextRow.getCells().get(columnIndex); if (nextRowCell == null) { break; rows.get(i).expand();