@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; }
@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 GridRow row = model.getRow(rowIndex); if (!row.isMerged()) {
final GridRow row = model.getRow(rowIndex); if (!row.isMerged()) {
@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("Row[" + rowIndex + "] actual isMerged() differs to expected.", expectedRowMergeStates[rowIndex], row.isMerged()); assertEquals("Row[" + rowIndex + "] actual isCollapsed() differs to expected.", expectedRowCollapseStates[rowIndex],
@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("Row[" + rowIndex + "] actual isMerged() differs to expected.", expectedRowMergeStates[rowIndex], row.isMerged()); assertEquals("Row[" + rowIndex + "] actual isCollapsed() differs to expected.", expectedRowCollapseStates[rowIndex],