Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333305

Summary: getTopIndex() may point to an invisible grid item
Product: z_Archived Reporter: Markus Bohr <markus.bohr>
Component: NebulaAssignee: Thomas Schindl <tom.schindl>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: cgross, m.stier
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Markus Bohr CLA 2010-12-29 10:07:13 EST
Build Identifier: eclipse: 3.5.1 nebula: 1.1.2

If dealing with a tree-structured grid (using subitems) having some of the subitems collapsed (invisible), usage of the filter may cause a fatal IllegalArgumentException.
Reason is that the grid item pointed to by Grid.getTopIndex() may point to an invisible grid element in case there are less lines to display than possible:

            int firstVisibleIndex = vScroll.getSelection(); // the result may point to an invisible item !!

            if (isTree) {
                Iterator itemsIter = items.iterator();
                int row = firstVisibleIndex + 1;

                while (row > 0 && itemsIter.hasNext()) {
                    GridItem item = (GridItem) itemsIter.next();

                    if (item.isVisible()) {
                        row--;
                        if (row == 0) {
                            firstVisibleIndex = items.indexOf(item);  // this line is never executed if there are less items to display than possible
                        }
                    }
                }
            }

            topIndex = firstVisibleIndex;

The solution could be to return the index of the next visible item before or after the invisible one, i.e. similar than this is performed in method Grid.getRowRange().

Reproducible: Sometimes

Steps to Reproduce:
1. 
Open a Nebula Grid widget that got a tree structure / subitems, and which got more items than able to show at the same time on the screen (so that a scollbar appears); recommended is "Setup / Functional Code Maintenance / Saving Reasons": 
2. 
scroll down to the very bottom. 
If there is no saving code that got a single subitem with the description "Test" and an arbitrary language, create one. 
3. 
expand this last saving code, so you see the single subitem, and scroll down again. 
4. 
type "Te" in a search condition for the description column
Comment 1 Markus Stier CLA 2012-06-12 04:13:03 EDT
Might be a duplicate to bug 375327. In 375327 there is a demo application to
reproduce the error.
Comment 2 Thomas Schindl CLA 2012-07-31 09:37:14 EDT
The problem is that the scrollbar is not fixed when items are removed adding an updateScrollbars() when items get removed fixes the problem.

*** This bug has been marked as a duplicate of bug 375327 ***