Populating huge table in SWT/JFace RCP application?

SWT can do that for you. When you use the SWT. VIRTUAL style flag, items are only created when scrolled into view.

Here's how to do it.

SWT can do that for you. When you use the SWT. VIRTUAL style flag, items are only created when scrolled into view.

Here's how to do it: Create the table with style SWT. VIRTUAL Set the row count using Table#setItemCount() Add a SWT. SetData Listener that fills the TableItems on demand.

Here's a code snippet: public static void main( String args ) { Display display = new Display(); Shell shell = new Shell( display ); shell. SetLayout( new FillLayout() ); final Table table = new Table( shell, SWT. VIRTUAL ); table.

SetItemCount( 10000 ); table. AddListener( SWT. SetData, new Listener() { public void handleEvent( Event event ) { TableItem item = (TableItem)event.

Item; item. SetText( "Item " + table. IndexOf( item ) ); } } ); shell.

SetSize( 300, 500 ); shell.open(); while(!shell.isDisposed() ) { if(!display.readAndDispatch() ) { display.sleep(); } } display.dispose(); }.

This is exactly the solution, now filling up 100k rows takes almost zero time, quite amazing feature, thanks a bunch! – Dima May 12 '10 at 19:58.

You want to do lazy-loading on the table display. Basically, you keep all these objects offscreen in memory, then create only a handful of actual GUI table rows. As the user scrolls you re-render these rows with the objects at that scroll location.

See this article (EDIT: oops I meant this article) for a JFace example.

Thanks for the hint, lazy drawing sounds like a good idea. Though I don't see how this snippet is different from mine, it runs over all items and draws it one by one... – Dima Nov 13 '09 at 11:37 Ooops! Wrong link, right site!

Here's the one for an SWT table with a million rows: java2s. Com/Code/Java/SWT-JFace-Eclipse/…. Just replace the "Add Items" button and re-implements its listener as a scroll listener that loads future items once you get near the end of the current set.

Good luck! – Benjamin Cox Nov 13 '09 at 16:50 Great, this makes sense now, thanks! – Dima Nov 24 '09 at 7:35.

1 - use the setText(String) instead of setText(int, String) one call instead of several. 2 - use myTable. SetRedraw(false) before and myTable.

SetRedraw(true) after the process to stop all redrawing opérations during loading data. It's simpler and can improve performance! Good luck.

On my side using this I load 2500 lines of 20 column in less than 300ms..... on a standard today PC.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions