Bug 4676 [Navigator] Tree scroll bar out of sync with top item (1GEJYGD)
The Tree scroll bar can get out of sync with the top item on Linux. To reproduce in Eclipse: 1. Open a standard SWT development workspace with the UIMain launcher loaded (org.eclipse.core.launcher should be the first project in the tree). 2. Expand the project to display the UIMain class and select it. 3. Exit Eclipse and restart. ->UIMain is selected and the top item. The scroll bar is also at the top/position 0. When you click the scroll bar the tree gets in sync with the scroll bar and shows the first tree item as the top item (the launcher project). NOTES: McQ (01/06/2001 9:02:42 AM) - Scrollbar needs to be forced to update its position. Is this a Tree problem or an ITPUI bug? KR (6/1/01 11:39:31 AM) It's the tree - only happens on Linux. KR (6/1/01 2:02:13 PM) Note that this is only reproducable when there are no editors open. It seems that the selected item is the top item and that the scroll bar is set as if the top item from the last Eclipse session was still the top item. McQ (01/06/2001 4:18:41 PM) - Re "It's the tree - only happens on Linux.": We have already had several cases where they assumed that by working with the scroll bar directly they could get widgets to position their contents, which works some places and not others (and thus is not supported). This could be a similar case. KR (6/4/01 11:42:26 AM) After debugging this for a while I noticed that a bunch of viewers call Tree.getVerticalBar() to restore the old ui state. This is one of the cases where this doesn't work. Tree.setSelection is called to select the previously selected item (at index 10). This automatically sets the top index and the scroll bar selection to 10. Someone (PackageExplorerPart.restoreState) then gets the vertical scroll bar and sets its selection to 9. For some reason the Tree doesn't always update the top index accordingly. KR (6/4/01 12:30:28 PM) It seems that the Tree sometimes gets a selection event for the programmatic scroll bar selection but most of the time doesn't. McQ (05/06/2001 11:04:29 AM) - No further action for June. McQ (26/06/2001 2:19:17 PM) - Time to take another look at this.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/packageview/PackageExplorerPart.java
}
				super.dragStart(event);
			}
		});
	}
	/**
	 * Handles double clicks in viewer.
	 * Opens editor if file double-clicked.
	 */
	private void handleDoubleClick(DoubleClickEvent event) {
		fActionSet.handleDoubleClick(event);
	}
	/**
	 * Handles selection changed in viewer.
	 * Updates global actions.
	 * Links to editor (if option enabled)
	 */
	private void handleSelectionChanged(SelectionChangedEvent event) {
		IStructuredSelection selection= (IStructuredSelection) event.getSelection();
		fActionSet.handleSelectionChanged(event);
		linkToEditor(selection);
	}
	public void selectReveal(ISelection selection) {
		ISelection javaSelection= convertSelection(selection);
	 	fViewer.setSelection(javaSelection, true);
	}
	private ISelection convertSelection(ISelection s) {
		List converted= new ArrayList();
		if (s instanceof StructuredSelection) {
			Object[] elements= ((StructuredSelection)s).toArray();