Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » swt table itemcount doubt
swt table itemcount doubt [message #876266] Thu, 24 May 2012 09:18 Go to next message
RaaZ Siripuram is currently offline RaaZ SiripuramFriend
Messages: 3
Registered: April 2012
Junior Member
Hi folks,

I have been stuck with one issue. Could anyone help me to get out of this.

I have created one AsyncronousTableViewer. First column of the table represents its row id (increments by 1) and it is primary key. In my data base I have millions of rows. Cache contains fixed number of rows (in my case 1000) and it has set to be as input to viewer.
As user scrolls down, cache will be updated (by giving query to database) with next 1000 rows and set this cache as input to viewer.

I want scroll bar thumb position should represent table data position in the database data.
More clearly, suppose, in database I have 10,000 records and in my table view has 5000 to 6000 rows (1000 rows), then thumb position should be at 50%. Same way if table got 8000 to 9000 rows(table always contains 1000 rows), then thumb position should be at 80%.

For this, for each event, I used verticalBar.setSelection(selection);
But, this raises many issues

please find here stackoverflow.com/questions/10315991/set-vertical-bar-thumb-position-programmatically


Later I realized that, it would be better to set total records in database as table item count.
So I set 10,000(above assumption) as item count.
Then table contains 0 - 9999 rows. Among them only 1000 rows(cache data) contain actual data to be displayed in the table view.

But when I set 5000 to 6000 rows as viewer input, these 1000 rows are placing in the table at 0-999 indexes. So again thumb position is at 0%.

How can I manage these thousand rows at 5000-5999 indexes of table rows.Then only thumb position will be at 50%(that is my expected position).

Hope you got my point. Smile
Could you please help me to get out of this issue.
Is my approach is correct or is there any other way?

Any suggestions would be appreciated...
Re: swt table itemcount doubt [message #876381 is a reply to message #876266] Thu, 24 May 2012 13:45 Go to previous messageGo to next message
Mario Marinato is currently offline Mario MarinatoFriend
Messages: 35
Registered: March 2011
Location: Brazil
Member
I think you might use the VIRTUAL flag when you create your table. When this flag is set, only the visible items are drawn and the viewer asks you for the n'th element when it is going to fill the line.

Mário Marinato
From Brazil
Re: swt table itemcount doubt [message #876985 is a reply to message #876381] Fri, 25 May 2012 16:23 Go to previous messageGo to next message
RaaZ Siripuram is currently offline RaaZ SiripuramFriend
Messages: 3
Registered: April 2012
Junior Member
Thanks Mario for your contribution.
Of course, I used VIRTUAL style.This is different case.
I have to manipulate billions of rows from database. Thats why I used cache.
Actual problem is with thumb position(first half of the above post).
Is there any other way to fix that issue.

From database(among millions of rows) view gets only 1000 rows.
But I need to set thumb position based on at what % of data (from database) view filled with.

>>> I want scroll bar thumb position should represent table data position in the database data.
>>>More clearly, suppose, in database I have 10,000 records and in my table view has 5000 to 6000 rows (1000 rows), then thumb position should be at 50%. Same way if table got 8000 to 9000 rows(table always contains 1000 rows), then thumb position should be at 80%.


Hope you get for what I am trying.... Rolling Eyes

Programatically I set thumb position at my desired place.But OS itself tries to replace thumb at actual position.
Re: swt table itemcount doubt [message #878690 is a reply to message #876985] Tue, 29 May 2012 18:30 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
The point of Tables with style SWT.VIRTUAL is to enable you to create a
Table with an arbitrary item count (millions are fine in theory, though
this does not make for a good UX). The question is, how many items
should your Table contain, regardless of the size of your database, or
your caching strategy? Just set this as its item count and it will ask
you for the items lazily as they're needed (needed == in the user's
viewport). Whether you answer these items with values taken directly
from the database or from some cached records that you've previously
retrieved is a detail of your implementation. Attempting to play with
the Table's scrollbar will not work; if you want to change the number of
items in the Table then just invoke setItemCount() again with the new value.

- basic SWT.VIRTUAL Table example:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet144.java

- SWT.VIRTUAL Table example that demonstrates populating 64 items at a
time, as if retrieved en masse from a database:
http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet201.java

Grant


On 5/25/2012 12:23 PM, RaaZ Siripuram wrote:
> Thanks Mario for your contribution.
> Of course, I used VIRTUAL style.This is different case.
> I have to manipulate billions of rows from database. Thats why I used
> cache.
> Actual problem is with thumb position(first half of the above post).
> Is there any other way to fix that issue.
>
> From database(among millions of rows) view gets only 1000 rows.
> But I need to set thumb position based on at what % of data (from
> database) view filled with.
>
>>>> I want scroll bar thumb position should represent table data
>>>> position in the database data.
>>>> More clearly, suppose, in database I have 10,000 records and in my
>>>> table view has 5000 to 6000 rows (1000 rows), then thumb position
>>>> should be at 50%. Same way if table got 8000 to 9000 rows(table
>>>> always contains 1000 rows), then thumb position should be at 80%.
>
> Hope you get for what I am trying.... :roll:
>
> Programatically I set thumb position at my desired place.But OS itself
> tries to replace thumb at actual position.
>
Re: swt table itemcount doubt [message #880257 is a reply to message #878690] Fri, 01 June 2012 18:00 Go to previous message
Mario Marinato is currently offline Mario MarinatoFriend
Messages: 35
Registered: March 2011
Location: Brazil
Member
Wish I had made myself as clear as Grant did. That was all I was thinking about.


Mário Marinato
From Brazil

[Updated on: Fri, 01 June 2012 18:36]

Report message to a moderator

Previous Topic:SWT Browser Widget, surpress CTRL-N with setUrl
Next Topic:How to print contents of a scrolledComposite?
Goto Forum:
  


Current Time: Fri Sep 25 10:55:20 GMT 2020

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

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

Back to the top