Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341495 - tree.getHorizontalBar().setSelection(0) does not scroll tree content
Summary: tree.getHorizontalBar().setSelection(0) does not scroll tree content
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-31 10:44 EDT by Markus Keller CLA
Modified: 2019-11-08 04:38 EST (History)
2 users (show)

See Also:


Attachments
modified Snippet15 (2.91 KB, text/plain)
2011-03-31 12:08 EDT, Markus Keller CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-03-31 10:44:05 EDT
HEAD, broken on Windows 7 since at least 3.3

tree.getHorizontalBar().setSelection(0) on an SWT Tree doesn't scroll the content of the tree widget. It only sets the scroll bar thumb, leaving the content area out of sync.

This has been used at the end of org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationViewer.preservingSelection(Runnable) to fix bug 176638. That bug is still fixed on XP, but is broken on Windows 7.

Steps:
- new workspace
- paste this snippet:
package p;
public class ThisIsALongName_ThisIsALongName_ThisIsALongName {
	public static void main(String[] args) {
		int i= 2;
		System.out.println(i);
	}
}

- run the class
- open the launch configuration dialog
=> Filter tree in bad state

I also tried other fixes like this one, but that also doesn't scroll enough, because showItem() only reveals the text, not the whole tree item:

		TreeItem topItem = getTree().getTopItem();
		if (topItem != null) {
			getTree().showItem(topItem);
		}
Comment 1 Felipe Heidrich CLA 2011-03-31 11:07:13 EDT
(In reply to comment #0)
> HEAD, broken on Windows 7 since at least 3.3

and I'm afraid it will never be fixed, as it is invalid.

see https://bugs.eclipse.org/bugs/show_bug.cgi?id=339333#c3

Why you are not using setTopItem ?
What are you trying to do ?
Comment 2 Markus Keller CLA 2011-03-31 12:08:29 EDT
Created attachment 192299 [details]
modified Snippet15

> Why you are not using setTopItem ?
Because that doesn't scroll to the left completely

> What are you trying to do ?
After steps in comment 0, the tree on the left should horizontally be scrolled so that all top-level items and their expandos are visible.

I've extracted the problem into a modified Snippet15. Removing the tree.showItem(item) is not feasible in our infrastructure. But if you could fix that method so that it only scrolls horizontally if less than e.g. 20px of the item text would be visible, then that would be even better.
Comment 3 Lars Vogel CLA 2019-11-08 04:38:59 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant please remove the stalebug whiteboard tag.