}
/**
- * Delete the region the cursor is currently at. Avoids having to reset the
- * cursor just because we deleted a region.
- *
- * Calls to updateForDeletedRegion should be made from within a writeLock in
- * the HiddenColumns class - since changes to the hiddenColumns collection
- * require a writeLock the lock should already exist.
- *
- * @param hiddenCols
- * replacement list of hidden column regions
- * @param remove
- * number of columns which were deleted
- */
- protected void updateForDeletedRegion(List<int[]> hiddenCols, int remove)
- {
- hiddenColumns = hiddenCols;
- if (!hiddenCols.isEmpty())
- {
- if (cursorPos.getRegionIndex() >= hiddenCols.size())
- {
- cursorPos = new HiddenCursorPosition(hiddenCols.size(),
- cursorPos.getHiddenSoFar() - remove);
- }
- }
- }
-
- /**
* Get the cursor pointing to the hidden region that column is within (if
* column is hidden) or which is to the right of column (if column is
* visible). If no hidden columns are to the right, returns a cursor pointing
offset = cursor.findRegionForColumn(80, true).getHiddenSoFar();
assertEquals(46, offset);
}
-
- /**
- * Test the method which updates for a deleted region
- */
- @Test(groups = { "Functional" })
- public void testUpdateForDeletedRegion()
- {
- List<int[]> hlist = new ArrayList<>();
- HiddenColumnsCursor cursor = new HiddenColumnsCursor(hlist, 1, 5);
- cursor.updateForDeletedRegion(hlist, 0);
- assertNull(cursor.findRegionForColumn(30, false));
-
- hlist.add(new int[] { 3, 7 });
- hlist.add(new int[] { 15, 25 });
-
- cursor = new HiddenColumnsCursor(hlist, 1, 5);
-
- HiddenCursorPosition p = cursor.findRegionForColumn(30, false);
- assertEquals(16, p.getHiddenSoFar());
-
- List<int[]> hlist2 = new ArrayList<>();
- hlist2.add(new int[] { 3, 7 });
- cursor.updateForDeletedRegion(hlist2, 11);
- p = cursor.findRegionForColumn(30, false);
- assertEquals(5, p.getHiddenSoFar());
- }
-
}