Community
Participate
Working Groups
On GTK you do not get a callback for free to set the item count for virtual tables. We need to set this explictly to make them work.
Created attachment 21358 [details] Test classes
Also the case on Windows. We should do this when we can in the refreshAll.
That test class had a bug - here is a better example import org.eclipse.jface.viewers.IStructuredContentProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; public class SimplePhantomRowsTest { static boolean showAll = true; /** * @param args */ public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display, SWT.CLOSE); shell.setLayout(new GridLayout(1, false)); Button button = new Button(shell, SWT.TOGGLE); button.setText("Toggle"); final TableViewer table = new TableViewer(shell, SWT.VIRTUAL); table.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); table.getTable().setLinesVisible(true); table.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { int size = 5; if (showAll) size = 15; String[] result = new String[size]; for (int i = 0; i < result.length; i++) { result[i] = "Element " + String.valueOf(i); } return result; } public void dispose() { // TODO Auto-generated method stub } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } }); table.setLabelProvider(new LabelProvider() { public String getText(Object element) { return (String) element; }; }); table.setInput(table); button.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { showAll = !showAll; table.refresh(); } }); shell.setSize(300, 400); shell.open(); while (!shell.isDisposed()) { display.readAndDispatch(); } } }
Created attachment 21368 [details] Patch
Comment on attachment 21368 [details] Patch These examples have bugs
*** Bug 100686 has been marked as a duplicate of this bug. ***
TableViewer.internalVirtualRefreshAll() has the following lines: //Don't cache if the root is null but cache if it is not lazy. if(root != null) virtualManager.cachedElements = ((IStructuredContentProvider) getContentProvider()).getElements(root); and I think the setItemCount() call should go into the if's body: //Don't cache if the root is null but cache if it is not lazy. if(root != null) { virtualManager.cachedElements = ((IStructuredContentProvider) getContentProvider()).getElements(root); table.setItemCount(cachedElements.length); } Apart from this bug, virtual TableViewer works beautiful!!!
Hitesh is now responsible for watching bugs in the [Viewers] component area.
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.