private void updateRowMergedCells(final GridRow row) { for (GridCell<?> cell : row.getCells().values()) { if (cell.isMerged()) { ((BaseGridRow) row).setHasMergedCells(true); return; } } ((BaseGridRow) row).setHasMergedCells(false); } }
private void updateRowMergedCells(final GridRow row) { for (GridCell<?> cell : row.getCells().values()) { if (cell.isMerged()) { ((BaseGridRow) row).setHasMergedCells(true); return; } } ((BaseGridRow) row).setHasMergedCells(false); } }
@Override public void collapseCell(final int rowIndex, final int columnIndex) { //Data needs to be merged to collapse cells if (!isMerged) { return; } final int _columnIndex = columns.get(columnIndex).getIndex(); final GridRow row = rows.get(rowIndex); final GridCell<?> cell = row.getCells().get(_columnIndex); if (cell == null) { return; } if (!cell.isMerged()) { return; } indexManager.onCollapseCell(rowIndex, _columnIndex); }
@Override public void collapseCell(final int rowIndex, final int columnIndex) { //Data needs to be merged to collapse cells if (!isMerged) { return; } final int _columnIndex = columns.get(columnIndex).getIndex(); final GridRow row = rows.get(rowIndex); final GridCell<?> cell = row.getCells().get(_columnIndex); if (cell == null) { return; } if (!cell.isMerged()) { return; } indexManager.onCollapseCell(rowIndex, _columnIndex); }
@Test public void testInitialSetup() { constructGridData(2, 3); for (int rowIndex = 0; rowIndex < gridData.getRowCount(); rowIndex++) { for (int columnIndex = 0; columnIndex < gridData.getColumnCount(); columnIndex++) { gridData.setCellValue(rowIndex, columnIndex, new BaseGridCellValue<String>("(" + columnIndex + ", " + rowIndex + ")")); } } for (int rowIndex = 0; rowIndex < gridData.getRowCount(); rowIndex++) { final GridRow row = gridData.getRow(rowIndex); assertFalse(row.isMerged()); assertFalse(row.isCollapsed()); for (int columnIndex = 0; columnIndex < gridData.getColumnCount(); columnIndex++) { final GridCell<?> cell = gridData.getCell(rowIndex, columnIndex); assertFalse(cell.isMerged()); } } assertEquals(3, gridData.getRowCount()); }
@Test public void testInitialSetup() { constructGridData(2, 3); for (int rowIndex = 0; rowIndex < gridData.getRowCount(); rowIndex++) { for (int columnIndex = 0; columnIndex < gridData.getColumnCount(); columnIndex++) { gridData.setCellValue(rowIndex, columnIndex, new BaseGridCellValue<String>("(" + columnIndex + ", " + rowIndex + ")")); } } for (int rowIndex = 0; rowIndex < gridData.getRowCount(); rowIndex++) { final GridRow row = gridData.getRow(rowIndex); assertFalse(row.isMerged()); assertFalse(row.isCollapsed()); for (int columnIndex = 0; columnIndex < gridData.getColumnCount(); columnIndex++) { final GridCell<?> cell = gridData.getCell(rowIndex, columnIndex); assertFalse(cell.isMerged()); } } assertEquals(3, gridData.getRowCount()); }
@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()); } } }
assertEquals("Cell[" + columnIndex + ", " + rowIndex + "] actual isMerged() differs to expected.", expectedCellStates[rowIndex][columnIndex].isMerged, cell.isMerged()); assertEquals("Cell[" + columnIndex + ", " + rowIndex + "] actual getMergedCellCount() differs to expected.", expectedCellStates[rowIndex][columnIndex].mergedCellCount,
@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()); } } }
assertEquals("Cell[" + columnIndex + ", " + rowIndex + "] actual isMerged() differs to expected.", expectedCellStates[rowIndex][columnIndex].isMerged, cell.isMerged()); assertEquals("Cell[" + columnIndex + ", " + rowIndex + "] actual getMergedCellCount() differs to expected.", expectedCellStates[rowIndex][columnIndex].mergedCellCount,