Bug 79180 [Viewers] TableViewer virtual manager may not handle programmatic scrolling
VirtualManager has a field currentVisibleIndex which holds the index of the last added item. This in itself is a major design bug since nobody guarantees in any way that items are created sequencially. A test case could easily be constructed in which after causing the creation of the the x first items the table is programatically scrolled to the middle or end jumping over any number of items. getCreatedItems() creates an array of size virtualManager.currentVisibleIndex. This array is ALWAYS smaller by 1 than the actual number of "visible" items. When creating item0 a 0 size array is returned, but 1 item is visible. When creating item1 a 1 size array is returned, but 2 items are visible ... Bug could easily be solved by creating an array of size currentVisibleIndex + 1. Also, shouldn't array copy be used here instead of the loop ? And ... why COPY the array ? ... will it be modified ? ... maybe 2 versions of the method should exist. Marcel
bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
* A concrete viewer based on a SWT <code>Table</code> control.
 * <p>
 * This class is not intended to be subclassed outside the viewer framework. It
 * is designed to be instantiated with a pre-existing SWT table control and
 * configured with a domain-specific content provider, table label provider,
 * element filter (optional), and element sorter (optional).
 * </p>
 * <p>
 * Label providers for table viewers must implement either the
 * <code>ITableLabelProvider</code> or the <code>ILabelProvider</code>
 * interface (see <code>TableViewer.setLabelProvider</code> for more details).
 * </p>
 * <p>
 * As of 3.1 the TableViewer now supports the SWT.VIRTUAL
 * flag. It is important to note that if SWT.VIRTUAL is in use
 * that the Widget based APIs will return null in both the
 * cases where either the element is not specified or not
 * created yet. 
 * </p>
 * <p>
 * Users of SWT.VIRTUAL should also avoid using getItems()
 * from the Table within the TreeViewer as this does not
 * necessarily generate a callback for the TreeViewer 
 * to populate the items. It also has the side effect of
 * creating all of the items thereby eliminating the
 * performance improvements of SWT.VIRTUAL.
 * </p>
 * @see SWT#VIRTUAL
 * @see #doFindItem(Object)
 * @see #internalRefresh(Object, boolean)