Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Are TableViewers incompatible with virtual tables (hard question :)?
Are TableViewers incompatible with virtual tables (hard question :)? [message #441706] Sat, 21 August 2004 21:35 Go to next message
Julen Parra is currently offline Julen ParraFriend
Messages: 12
Registered: July 2009
Junior Member
IŽm developer for an Eclipse database plugin (quantum at sourceforge.net).
I'm trying to use the new virtual tables for a database editor. Rob Warner
helped me nicely with my first problem, but now I have another I believe
rather more problematic.

I'm trying to use a TableViewer with the virtual table, and seems to be a
self-defeating proposition. If I define a TableViewer, I need a
IStructuredContentProvider for it, that should define a getElements()
function. This getElements() function should return all the rows data for
all the rows in the table. That quite defeats the purpose of a virtual
table, so a TableViewer should not be used with a virtual table.

So, first, is my analysis correct, or am I missing something ? Second, if
correct, and so cannot use a TableViewer, which would be the direction to
take ?. I want a TableViewer so I can use a CellModifier for my cells.
Basically I want cell editing in my virtual table. Should I develop a
virtual table viewer (gulp) ? Better to concentrate on offering the
editing capability directly to the (virtual) Table object ? If so, any
hints ?

Thanks in advance.
Already found a workaround [message #441712 is a reply to message #441706] Sun, 22 August 2004 21:32 Go to previous messageGo to next message
user is currently offline userFriend
Messages: 296
Registered: July 2009
Senior Member
Hi. I have found a workaround for my problem. That doesn't mean I'm not
curious about the whole thing, but I found that I could use the
TableViewer without making calls to the getElements() function. So I can
use the CellEditors and CellModifier. I don't know if the mix is going
to explode some time in the future, but for now it works OK.

So if anybody knows more about the whole thing, I'm eager to learn, but
the issue it's not blocking me any longer. Thanks for your time :)

Julen Parra wrote:
> IŽm developer for an Eclipse database plugin (quantum at sourceforge.net).
> I'm trying to use the new virtual tables for a database editor. Rob Warner
> helped me nicely with my first problem, but now I have another I believe
> rather more problematic.
>
> I'm trying to use a TableViewer with the virtual table, and seems to be a
> self-defeating proposition. If I define a TableViewer, I need a
> IStructuredContentProvider for it, that should define a getElements()
> function. This getElements() function should return all the rows data for
> all the rows in the table. That quite defeats the purpose of a virtual
> table, so a TableViewer should not be used with a virtual table.
>
> So, first, is my analysis correct, or am I missing something ? Second, if
> correct, and so cannot use a TableViewer, which would be the direction to
> take ?. I want a TableViewer so I can use a CellModifier for my cells.
> Basically I want cell editing in my virtual table. Should I develop a
> virtual table viewer (gulp) ? Better to concentrate on offering the
> editing capability directly to the (virtual) Table object ? If so, any
> hints ?
>
> Thanks in advance.
>
Re: Already found a workaround [message #441834 is a reply to message #441712] Thu, 26 August 2004 08:39 Go to previous messageGo to next message
CK Ng is currently offline CK NgFriend
Messages: 18
Registered: July 2009
Junior Member
May I know how you make use of the ContentProvider & LabelProvider in the
case of TableViewer and SWT.VIRTUAL??

Since it is Virtual, we need to handle the SetData event, my implementation
is as follow where DataModel will update the TableViewer:

tableViewer.getTable().addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem) event.item;
final int index = tableViewer.getTable().indexOf(item);
dataModel.updatePacket(index);
}
});

class TableContentProvider implements IStructuredContentProvider,
DataModelListener {
....
public void updateData(final Data data, final int index) {
display.syncExec(
new Runnable() {
public void run(){
if(tableViewer.getTable().isDisposed()) return;
tableViewer.getTable().getItem(index).setData(data);
// tableViewer.insert(data, index);
}
}
);
}
}

The line
tableViewer.getTable().getItem(index).setData(data);
no table item is displayed, I guess it didnt invoke the LabelProvider
somehow

If I use
tableViewer.insert(data, index);
it is giving me wrong index (it skips by returning [0, 2, 4,...]) in the
SetData Listener code
final int index = tableViewer.getTable().indexOf(item);
and evetually will cause ArrayOutOfBound exception

Any suggestion? Or I miss something.
Thanks

Regards,
CK Ng
--

<user@domain.invalid> wrote in message news:cgb38d$mkh$1@eclipse.org...
Hi. I have found a workaround for my problem. That doesn't mean I'm not
curious about the whole thing, but I found that I could use the
TableViewer without making calls to the getElements() function. So I can
use the CellEditors and CellModifier. I don't know if the mix is going
to explode some time in the future, but for now it works OK.

So if anybody knows more about the whole thing, I'm eager to learn, but
the issue it's not blocking me any longer. Thanks for your time :)

Julen Parra wrote:
> I
Re: Already found a workaround [message #442702 is a reply to message #441834] Sun, 12 September 2004 08:53 Go to previous message
Julen Parra is currently offline Julen ParraFriend
Messages: 12
Registered: July 2009
Junior Member
Sorry for the long time answering, I was out of touch with this newsgroup.
I suppose you have already found your solution, but anyway. I donŽt use
any table content provider. Basically the content is provided by the
SetData event, at least as I see things.

I don't know if I'm answering your question, but when I modify data, and
use the setData() function to modify the data of the TableItem, I have to
use the following line of code (I donŽt know if that's the proper way, but
works sort of, still not tested with all possibilities (deletes and so
on). This line is more or less like a refresh() of the visible items in
the table.

ti.getParent().notifyListeners(SWT.SetData, refresh);

That's about it. If you need more data, please tell me.




CK Ng wrote:

> May I know how you make use of the ContentProvider & LabelProvider in the
> case of TableViewer and SWT.VIRTUAL??

> Since it is Virtual, we need to handle the SetData event, my implementation
> is as follow where DataModel will update the TableViewer:

> tableViewer.getTable().addListener(SWT.SetData, new Listener() {
> public void handleEvent(Event event) {
> TableItem item = (TableItem) event.item;
> final int index = tableViewer.getTable().indexOf(item);
> dataModel.updatePacket(index);
> }
> });

> class TableContentProvider implements IStructuredContentProvider,
> DataModelListener {
> ....
> public void updateData(final Data data, final int index) {
> display.syncExec(
> new Runnable() {
> public void run(){
> if(tableViewer.getTable().isDisposed()) return;
> tableViewer.getTable().getItem(index).setData(data);
> // tableViewer.insert(data, index);
> }
> }
> );
> }
> }

> The line
> tableViewer.getTable().getItem(index).setData(data);
> no table item is displayed, I guess it didnt invoke the LabelProvider
> somehow

> If I use
> tableViewer.insert(data, index);
> it is giving me wrong index (it skips by returning [0, 2, 4,...]) in the
> SetData Listener code
> final int index = tableViewer.getTable().indexOf(item);
> and evetually will cause ArrayOutOfBound exception

> Any suggestion? Or I miss something.
> Thanks

> Regards,
> CK Ng
Previous Topic:Anyone to override the statusbar message, even my form didnt actively loaded?
Next Topic:Tree expandAll size
Goto Forum:
  


Current Time: Tue Apr 16 14:23:06 GMT 2024

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

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

Back to the top