Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 69076 - [Viewers] Bugs in jface ListViewer "reveal" method
Summary: [Viewers] Bugs in jface ListViewer "reveal" method
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P4 normal (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-30 16:17 EDT by Larry Bergman CLA
Modified: 2005-12-13 10:54 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Bergman CLA 2004-06-30 16:17:21 EDT
The reveal method does not always properly scroll when the last item in the 
list is specified.  The reveal method seems to have several coding errors.  A 
portion of the code (from 3.0RC3) is listed below:

	[a] int visibleCount = Math.max ((rect.x + rect.height) / height, 1);
	[b] int bottomIndex = Math.min (topIndex + visibleCount + 1, count - 1);
	if ((topIndex <= index) && (index <= bottomIndex)) return;
	[c] int newTop = Math.min (Math.max (index - (visibleCount / 2), 0), 
count - 1);
	list.setTopIndex(newTop);

We note the following problems:
[a]: rect.x in this expression seems wrong.  In fact we think that rect.x + 
rect.height should be replaced simply with rect.height
[b]: We believe that topIndex + visibleCount + 1 is incorrect, and should be 
topIndex + visibleCount - 1.  This seems to be the source of the error.
[c]: The outer "min" expression is superfluous.  The max expression is 
proveably >= count-1.

Larry Bergman and Tessa Lau
Comment 1 Boris Bokowski CLA 2005-11-08 15:53:35 EST
This is a bug in the code we copied from SWT, which has since been fixed (see
bug 68950).

I have only fixed [a] and [b], I did not change [c]. 

Released for builds >20051108.
Comment 2 Boris Bokowski CLA 2005-11-11 11:52:06 EST
Reopening because we have a test failure on MacOS.

junit.framework.AssertionFailedError: topIndex should not change on setSelection
expected:<19> but was:<18>
at
org.eclipse.jface.tests.viewers.ListViewerTest.testRevealBug69076(ListViewerTest.java:66)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:330)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:204)
at org.eclipse.test.CoreTestApplication.runTests(CoreTestApplication.java:35)
at org.eclipse.test.CoreTestApplication.run(CoreTestApplication.java:31)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:165)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:338)
at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 3 Boris Bokowski CLA 2005-11-11 23:18:48 EST
I have changed the test so that it does not run on Mac OS until bug 116105 is fixed.
Comment 4 Boris Bokowski CLA 2005-12-09 15:46:52 EST
Opened bug 120167 to track the issue with the test so that I can close this one.
Comment 5 Boris Bokowski CLA 2005-12-09 15:52:27 EST
Trying again to mark this as fixed.
Comment 6 Boris Bokowski CLA 2005-12-13 10:54:05 EST
Verified on Windows XP using I20051213-0010. The test is part of the suite and passes.