Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to make a TableViewer virtual
How to make a TableViewer virtual [message #461006] Wed, 14 September 2005 13:35 Go to next message
michael is currently offline michaelFriend
Messages: 44
Registered: July 2009
Member
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
Re: How to make a TableViewer virtual [message #461035 is a reply to message #461006] Thu, 15 September 2005 06:53 Go to previous messageGo to next message
Yves Harms is currently offline Yves HarmsFriend
Messages: 80
Registered: July 2009
Member
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
>
Re: How to make a TableViewer virtual [message #461037 is a reply to message #461035] Thu, 15 September 2005 06:54 Go to previous messageGo to next message
Yves Harms is currently offline Yves HarmsFriend
Messages: 80
Registered: July 2009
Member
Just one last thing:
Don't forget to pack() the TableColumns or you won't see anything.

Yves Harms wrote:
> 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
>>
Re: How to make a TableViewer virtual [message #461078 is a reply to message #461035] Thu, 15 September 2005 15:32 Go to previous messageGo to next message
michael is currently offline michaelFriend
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 #461103 is a reply to message #461078] Fri, 16 September 2005 08:52 Go to previous messageGo to next message
Yves Harms is currently offline Yves HarmsFriend
Messages: 80
Registered: July 2009
Member
Hi Michael,
as far as i know this concept is centered on the table, not the
scrollbar. The table so to speak only tells the scollbar how many space
it needs (this is a simplification of the real workflow).
Its all about how many items are inside the table. So working with plain
SWT you could always remove(dispose) or add items (new TableItem(..))
without worrying about the scollbar.

Yves


michael wrote:
> Hi michael
>
> 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?
>
Re: How to make a TableViewer virtual [message #461119 is a reply to message #461103] Fri, 16 September 2005 14:24 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
>
>
Re: How to make a TableViewer virtual [message #462325 is a reply to message #461123] Mon, 10 October 2005 14:38 Go to previous messageGo to next message
mr. burns is currently offline mr. burnsFriend
Messages: 402
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.

------=_NextPart_000_0027_01C5CDB9.0A81A6C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello Grant,

I try to get your example TableViewerVIRTUAL to work. I get no compile =
error, but if I run the project I get an error message saying:

Exception in thread "main" java.lang.NoClassDefFoundError: =
org/eclipse/core/runtime/ISafeRunnableat =
TableViewerVIRTUAL.main(TableViewerVIRTUAL.java:15)

I am working under Eclipse 3.1, and added a project dependency to SWT =
project (described under http://www.eclipse.org/swt/eclipse.php).
I also added the the org.eclipse.jface_3.1.0.jar to my project.

What did I wrong? Is there something missing?

Thanks for any help!


------=_NextPart_000_0027_01C5CDB9.0A81A6C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2668" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Hello Grant,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I try to get your example&nbsp; =
TableViewerVIRTUAL=20
to work. I get no compile error, but if I run the project I get an error =
message=20
saying:</FONT></DIV><FONT face=3DArial size=3D2>
<DIV><BR>Exception in thread "main" java.lang.NoClassDefFoundError:=20
org/eclipse/core/runtime/ISafeRunnable</FONT><FONT face=3DArial =
size=3D2>at=20
TableViewerVIRTUAL.main(TableViewerVIRTUAL.java:15)<BR></FONT ><FONT =
face=3DArial=20
size=3D2><BR></FONT><FONT face=3DArial size=3D2>I am working under =
Eclipse 3.1, and=20
added a project dependency to SWT project (described under <A=20
href=3D"http://www.eclipse.org/swt/eclipse.php">http://www.eclipse.org/sw=
t/eclipse.php</A>).<BR>I=20
also added the the org.eclipse.jface_3.1.0.jar to my =
project.<BR><BR>What did I=20
wrong? Is there something missing?<BR><BR>Thanks for any =
help!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2><BR>&nbsp;</DIV></FONT></BODY></HTML>

------=_NextPart_000_0027_01C5CDB9.0A81A6C0--
Re: How to make a TableViewer virtual [message #462358 is a reply to message #462325] Tue, 11 October 2005 13:39 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
JFace has other dependencies, you also need to add org.eclipse.core.runtime
and org.eclipse.osgi.

Grant


"Mr. Burns" <Mr._Burns@web.de> wrote in message
news:didud4$3g6$1@news.eclipse.org...
Hello Grant,

I try to get your example TableViewerVIRTUAL to work. I get no compile
error, but if I run the project I get an error message saying:

Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/core/runtime/ISafeRunnableat
TableViewerVIRTUAL.main(TableViewerVIRTUAL.java:15)

I am working under Eclipse 3.1, and added a project dependency to SWT
project (described under http://www.eclipse.org/swt/eclipse.php).
I also added the the org.eclipse.jface_3.1.0.jar to my project.

What did I wrong? Is there something missing?

Thanks for any help!
Previous Topic:How to remove TableColumns from Table
Next Topic:Waiting dialogs
Goto Forum:
  


Current Time: Fri Oct 30 08:54:13 GMT 2020

Powered by FUDForum. Page generated in 0.02382 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top