Bug 292212 [Viewers] Performance issue in doing a TreeViewer.refresh() on a node in expanded state and containing thousands of children
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; MS-RTC LM 8; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022) Build Identifier: I20090611-1540 On expanding a node in the TreeViewer, the control comes to getChildren() call on the content provider. In cases where we need to make server calls to get the children and so as not to block the UI thread, we spawn a job and return a dummy object. Once the job completes, so as to update the node with the children, if we do a refresh on the treeviewer for the object being expanded, it takes considerable amount of time to render the children and this increases exponentially as the number of children increases. Additional documentation is provided in the .doc file attached this bug report and a sample application containing the code is attached as well. Reproducible: Always Steps to Reproduce: 1. Create a view part with a custom content and label providers 2. In the content-provider's getChildren() method, spawn off a job to load the children for the parent-object and return a dummy object (say "Loading...") so that the UI displays it at the time of expansion 3. In the job, construct the children (say 5000) and once done, fire a TreeViewer.refresh(..) on the parent-object in the ui-thread 4. You would notice that this takes a considerable amount of time to show the children.
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
/**
	 * Constant indicating that all levels of the tree should be expanded or
	 * collapsed.
	 *
	 * @see #expandToLevel(int)
	 * @see #collapseToLevel(Object, int)
	 */
	public static final int ALL_LEVELS = -1;
	/**
	 * List of registered tree listeners (element type:
	 * <code>TreeListener</code>).
	 */
	private ListenerList treeListeners = new ListenerList();
	/**
	 * The level to which the tree is automatically expanded each time the
	 * viewer's input is changed (that is, by <code>setInput</code>). A value
	 * of 0 means that auto-expand is off.
	 *
	 * @see #setAutoExpandLevel
	 */
	private int expandToLevel = 0;
	/**
	 * Safe runnable used to update an item.
	 */
	class UpdateItemSafeRunnable extends SafeRunnable {