Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to make a TableViewer virtual
| | |
Re: How to make a TableViewer virtual [message #461078 is a reply to message #461035] |
Thu, 15 September 2005 15:32 |
michael Messages: 44 Registered: July 2009 |
Member |
|
|
Hi Yves,
First of all thanks for your help.
Do I guess right, that a "virtual" Table/TableViewer is only lazy loading
but not virtual the way Swing JTable and KTable are?
That means, with these kind of tables its possible to only load the first
n records, but the vertical scrollbar "knows" how much records there are
in the model. So you can scroll down and then the next batch of records
gets displayed.
IMHO, the problem with the SWT/JFace table seems that the table's
scrollbar also only knows of the number of records specified by
setItemCount(int) and so are actually displayed.
I know I could handle the scrollbar's events and re-fill the whole table
by doing a clear() and setItemCount() again, but the vertical scrollbar is
not in sync with the number of records in the model.
Am I right or am I missing anything?
Regards,
Michael
Am Thu, 15 Sep 2005 08:53:05 +0200 schrieb Yves Harms
<user@domain.invalid>:
> Table t = new Table(parent, SWT.VIRTUAL);
> //create columns
> for(int i=0;i<5;i++) new TableColumn(t,SWT.NONE).setText("#"+i);
>
> TableViewer v = new TableViewer(table);
>
> v.setContentProvider(new ILazyContentProvider(){
> //implement your Content Provider here
> })
>
> v.setLabelProvider(new ITableLabelProvider(){
> //implement your label Provider here
> });
>
> //for lazy tables setItemCount instead of v.setInput(yourinput)
> v.setItemCount(yourItemCount);
>
>
> You should put the ContentProvider and LabelProvider in seperate
> classfiles, I used anonymous classes to show which interfaces must be
> implemented.
>
> Howto enable Cellediting: This works the same ways as with non-lazy
> TableViewers.
>
> Regards,
> Yves
>
>
>
> michael wrote:
>> Hi,
>> [Eclipse 3.1.0, JDK 1.4.2]
>> I'm looking for a documentation describing how-to make a TableViewer
>> virtual.
>> Does anyone know of such one or can anybody give me a hint how/where
>> to start?
>> Regards,
>> Michael
>>
>
--
Erstellt mit M2, Operas revolutionärem E-Mail-Modul:
http://www.opera.com/m2/
|
|
| |
Re: How to make a TableViewer virtual [message #461119 is a reply to message #461103] |
Fri, 16 September 2005 14:24 |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
I think what he is getting at is, say there are actually 1000 items in
the input to the table, but he doesn't want to get all 1000 items at
once. But the scrollbar should actually look like there really are 1000
items in the table even though there aren't 1000 TableItem's yet.
I don't know if the virtual table works this way.
--
Thanks,
Rich Kulp
|
|
|
Re: How to make a TableViewer virtual [message #461123 is a reply to message #461119] |
Fri, 16 September 2005 15:47 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
That is how it works. For a very minimal jface-level example of this see
the snippet below, or for an swt-level example of this see
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet144.java?rev=HEAD& amp;content-type=text/vnd.viewcvs-markup .
public class TableViewerVIRTUAL {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,300,300);
Table table = new Table(shell, SWT.VIRTUAL);
table.setBounds(10,10,200,200);
final TableViewer viewer = new TableViewer(table);
viewer.setItemCount(10000); // <------
viewer.setLabelProvider(new ITableLabelProvider() {
public void removeListener(ILabelProviderListener listener) {}
public boolean isLabelProperty(Object element, String property)
{
return false;
}
public void dispose() {}
public void addListener(ILabelProviderListener listener) {}
public String getColumnText(Object element, int columnIndex) {
return "virtual item: " +
String.valueOf(((Integer)element).intValue());
}
public Image getColumnImage(Object element, int columnIndex) {
return null;
}
});
viewer.setContentProvider(new ILazyContentProvider() { // <------
public void inputChanged(Viewer viewer, Object oldInput, Object
newInput) {}
public void dispose() {}
public void updateElement(int index) {
System.out.println("setting: " + index);
viewer.replace(new Integer(index), index);
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
Grant
"Rich Kulp" <richkulp@us.NO_SPAM.ibm.com> wrote in message
news:dgekjc$l0u$3@news.eclipse.org...
> I think what he is getting at is, say there are actually 1000 items in
> the input to the table, but he doesn't want to get all 1000 items at
> once. But the scrollbar should actually look like there really are 1000
> items in the table even though there aren't 1000 TableItem's yet.
>
> I don't know if the virtual table works this way.
>
>
> --
> Thanks,
> Rich Kulp
|
|
|
Re: How to make a TableViewer virtual [message #461136 is a reply to message #461119] |
Fri, 16 September 2005 19:45 |
Eclipse User |
|
|
|
Originally posted by: micasim.gmx.de
Hi Rich,
indeed, that's what I meant.
Thanks for clarification,
Michael
On Fri, 16 Sep 2005 16:24:44 +0200, Rich Kulp
<richkulp@us.NO_SPAM.ibm.com> wrote:
> I think what he is getting at is, say there are actually 1000 items in
> the input to the table, but he doesn't want to get all 1000 items at
> once. But the scrollbar should actually look like there really are 1000
> items in the table even though there aren't 1000 TableItem's yet.
>
> I don't know if the virtual table works this way.
>
>
|
|
| | |
Goto Forum:
Current Time: Fri Apr 26 19:22:13 GMT 2024
Powered by FUDForum. Page generated in 0.04030 seconds
|