Bug 15054 - OwnerData or "virtual" Table support
Summary: OwnerData or "virtual" Table support
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Steve Northover CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on: 37998
Blocks:
  Show dependency tree
 
Reported: 2002-05-01 23:45 EDT by Konstantin Scheglov CLA
Modified: 2004-06-23 12:43 EDT (History)
9 users (show)

See Also:


Attachments
An improved version of TableVirtual (5.48 KB, text/plain)
2003-06-18 22:30 EDT, Michael Scharf CLA
no flags Details
A simple test application to show a virtual table with 1000,000 rows (3.60 KB, text/plain)
2003-06-18 22:31 EDT, Michael Scharf CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Scheglov CLA 2002-05-01 23:45:35 EDT
Filling of Table works too slow.
  I need to show to user big log. Yes, I know, that
he can not to look at 10000 log lines, but I have
filters and sorts for this. But in current implementation resort
requires refill of table. And even with small table with about 1000 items
it works too slow. In any case, if I have all
log records in memory (or in file with fast access
speed) I can show this logs record to user fast with
concept of "virtual" Table.
  In Windows it is possible to use so named "virtual"
ListView, with style LVS_OWNERDATA. My quick hack of
SWT Table shows, that with this style and with
implementation of LVN_GETDISPINFO Table works much
faster (speed practically does not depend on count of items).
I think, that TableViewer with its ContentProvider
and LabelProvider is almost all what needed to implement
LVN_GETDISPINFO.
  Can you add support of virtual ListView in
Eclipse SWT/JFace?
Comment 1 Mike Wilson CLA 2002-05-02 10:28:33 EDT
I would like to see this happen as well. Unfortunately, we will not have time 
to do this for R2.0. We would need to investigate both the potential ways this 
could be used by the UI team, as well as the underlying support on all the 
operating systems which use native tables (Carbon (?), GTK(?), etc.) before 
deciding on an API. Then we would actually have to implement this API 
everywhere (including in the emulated implementation for photon and 
linux/motif). Given how little free time there is, and the fact that the UI 
team probably would not be able to respond to the changes at this point, it 
will have to wait.

If you want to get involved with implementing this yourself, you should start 
a discussion on the platform-swt-dev mailing list with the results of 
investigating the support on the various platforms, plus your suggested API.
Comment 2 Konstantin Scheglov CLA 2002-05-16 01:24:27 EDT
Here is source code for Windows.

/**
 * @author Kosta
 */
package org.eclipse.swt.widgets;
import org.eclipse.jface.viewers.ITableLabelProvider;
//
import org.eclipse.swt.internal.win32.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
public class TableVirtual extends Table {
	private ITableLabelProvider m_LabelProvider;
	public TableVirtual(Composite parent, int style) {
		super(parent, checkStyle(style));
	}
	public void setLabelProvider(ITableLabelProvider labelProvider) {
		m_LabelProvider = labelProvider;
	}
	int widgetStyle() {
		int bits = super.widgetStyle();
		bits |= 0x1000;
		return bits;
	}
	void createItem(TableItem item, int index) {
	}
	public void createItems(int cnt) {
		items = new TableItem[cnt];
		for (int i = 0; i < cnt; i++) {
			LVITEM lvItem = new LVITEM();
			lvItem.iItem = i;
			lvItem.iImage = OS.I_IMAGENONE;
			lvItem.mask = OS.LVIF_IMAGE;
			//
			items[i] = new TableItem(this, SWT.NONE);
		}
		//
		OS.SendMessage(handle, 0x1000 + 47, cnt, 0);
	}
	LRESULT wmNotifyChild(int wParam, int lParam) {
		NMHDR hdr = new NMHDR();
		OS.MoveMemory(hdr, lParam, NMHDR.sizeof);
		switch (hdr.code) {
			case 0xFFFFFF4F :
				{
					NMLISTVIEW pnmlv = new NMLISTVIEW();
					OS.MoveMemory(pnmlv, lParam, 
NMLISTVIEW.sizeof);
					//
					int item = pnmlv.iSubItem;
					int subItem = pnmlv.uNewState;
					// for image support I need to change 
SWT native library
					/*if ((pnmlv.iItem & OS.LVIF_IMAGE) != 
0) {
						if ((m_LabelProvider != null) 
&& (subItem == 0)) {
							Image image = 
m_LabelProvider.getColumnImage(new Integer(item), subItem);
							pnmlv.lParam = 
imageIndex(image);
							OS.MoveMemory(lParam, 
pnmlv, NMLISTVIEW.sizeof);
						}
					}*/
					if ((pnmlv.iItem & OS.LVIF_TEXT) != 0) {
						String string;
						if (m_LabelProvider != null)
							string = 
m_LabelProvider.getColumnText(new Integer(item), subItem);
						else
							string = "";
						TCHAR buffer = new TCHAR
(getCodePage(), string, true);
						int byteCount = buffer.length() 
* TCHAR.sizeof;
						OS.MoveMemory(pnmlv.x, buffer, 
byteCount);
					}
				}
		} // switch
		return super.wmNotifyChild(wParam, lParam);
	}
	public void selectItem(int item) {
		int state = OS.SendMessage(handle, OS.LVM_GETITEMSTATE, item, 
OS.LVIS_SELECTED | OS.LVIS_FOCUSED);
		LVITEM lvItem = new LVITEM();
		lvItem.mask = OS.LVIF_STATE;
		lvItem.stateMask = OS.LVIS_SELECTED | OS.LVIS_FOCUSED;
		lvItem.state |= OS.LVIS_SELECTED | OS.LVIS_FOCUSED;
		OS.SendMessage(handle, OS.LVM_SETITEMSTATE, item, lvItem);
	}
}
Comment 3 Mike Wilson CLA 2002-05-16 11:10:25 EDT
We should consider this for R3.0.
Comment 4 Veronika Irvine CLA 2002-09-11 14:06:38 EDT
Moving from Later.
Comment 5 Michael Scharf CLA 2003-06-18 22:30:12 EDT
Created attachment 5236 [details]
An improved version of TableVirtual

- much smaller memory footprint (no TableItems allocated for each row)
- allows images for any column
Comment 6 Michael Scharf CLA 2003-06-18 22:31:24 EDT
Created attachment 5237 [details]
A simple test application to show a virtual table with 1000,000 rows
Comment 7 Ed Burnette CLA 2003-06-19 11:19:51 EDT
See also bug 36226 .
Comment 8 Eric Yokeley CLA 2004-02-10 17:03:49 EST
What's the status of this PR?  Are thre plans for including some sort of 
virtual table in Eclipse 3.0?
Comment 9 Steve Northover CLA 2004-02-11 10:38:33 EST
We are hoping to get this into 3.0 but might not make it.
Comment 10 Steve Northover CLA 2004-03-17 18:01:56 EST
Fixed > 20040317

Investigate SWT.VIRTUAL, SWT.SetData, Table.setItemCount() and Table.clear(). 
There is a chance we will be changing some of this behavior between now and 
3.0.  Good luck!
Comment 11 Steve Northover CLA 2004-03-17 18:02:16 EST
Really fixed.
Comment 12 Steve Northover CLA 2004-06-23 12:43:47 EDT
NOTE: DO NOT USE ANY OF THE CODE THAT IS ATTACHED TO THIS BUG REPORT.  The 
virtual table is supported as a style for the regular table.