Bug 201135 - Virtual Tree Viewer creates all children of a visible item on exapndToLevel(1)
Summary: Virtual Tree Viewer creates all children of a visible item on exapndToLevel(1)
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Boris Bokowski CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: performance
Depends on:
Blocks: 203803
  Show dependency tree
 
Reported: 2007-08-24 16:10 EDT by Tod Creasey CLA
Modified: 2021-12-11 14:16 EST (History)
3 users (show)

See Also:


Attachments
Snapshot of the expand code (107.43 KB, text/html)
2007-09-05 15:54 EDT, Tod Creasey CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tod Creasey CLA 2007-08-24 16:10:26 EDT
When you call expandToLevel(1) on a tree item it will expands all of it's children in a virtual tree even with a  lazyContentProvidier

The code in question is in TreeViewer#createChildren()

	Object element = widget.getData();
			if (element == null && widget instanceof TreeItem) {
				// parent has not been materialized
				virtualMaterializeItem((TreeItem) widget);
				// try getting the element now that updateElement was called
				element = widget.getData();
			}
			if (element ==  null) {
				// give up because the parent is still not materialized
				return;
			}
			Item[] children = getChildren(widget);
			if (children.length == 1 && children[0].getData() == null) {
				// found a dummy node
				virtualLazyUpdateChildCount(widget, children.length);
				children = getChildren(widget);
			}
			// touch all children to make sure they are materialized
			for (int i = 0; i < children.length; i++) {
				if (children[i].getData() == null) {
					virtualLazyUpdateWidget(widget, i);
				}
			}
			return;

The line Item[] children = getChildren(widget); will create all of the children of the tree item even though most of them may not be visible.
Comment 1 Tod Creasey CLA 2007-09-05 15:54:07 EDT
Created attachment 77753 [details]
Snapshot of the expand code

This is the snapshot from YourKit. it looks like the real problem is the attempt tp preserve the selection when doing this
Comment 2 Tod Creasey CLA 2007-09-05 16:26:21 EDT
This optimization in the AbstractTreeViewer sped things up considerably

public void expandToLevel(Object elementOrTreePath, int level) {

		if (level == 1) {
			Widget widget = findItem(elementOrTreePath);
			if (widget != null && widget instanceof TreeItem) {
				((TreeItem) widget).setExpanded(true);
				return;
			}
		}
Comment 3 Tod Creasey CLA 2007-09-05 16:33:43 EDT
With the optimization it went from 32 seconds to being too fast for me to profile.
Comment 4 Tod Creasey CLA 2007-09-07 09:44:17 EDT
When this gets fixed I have a workaround in the new markers view that can be deleted.
Comment 5 Eclipse Webmaster CLA 2019-09-06 16:19:24 EDT
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.
Comment 6 Eclipse Genie CLA 2021-12-11 14:16:43 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. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. 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.

--
The automated Eclipse Genie.