Avoid flooding the SWT UI Thread. alternative to jface.deferred [message #323799] |
Tue, 08 January 2008 23:13  |
Eclipse User |
|
|
|
Originally posted by: k.nospam.bugmenot.com
Ok, I solved my problem of blank lines in a virtual jface table viewer
with lazy content provider.
I tried to use jface.deferred but I read it will be deprecated and I
needed to change my model to implement it. So here I describe my workaround:
I have wrappers for the viewers like
wrp = TableWrapper.get(tableViewerInstance)
Then I use wrp like: wrp.refresh(element) or wrp.setInput(input);
Those methods don't call the viewer methods they just store information
in the wrp instance. For example for the refresh(element) I keep a set
of elements to be refreshed.
Besides having this viewer methods the wrappers are Runnable. The run()
method of the wrappers update the viewers. Now what I need is to execute
the run method in the UI thread but I can control the frequency of
updates for each viewer, I can also implement periodic updates I can
avoid locking using java 5.0 concurrency advantages.
Why not using Display.asyncExec? because it just doesn't work with many
items in the model the UI starts to be useless. The SWT queue with the
Runnable that you submit sith .asyncExec() starts to grow and everything
is slow.
Then I have a scheduler using the concurrency package to run those
wrappers run() methods. I implemented this wrappers and now my code
looks better instead of ugly Display.asyncExec(new Runnable bla bla)
I have wrapper.action();
I implemented a delayed update, I wait X milliseconds (200ms now) before
updating a viewer again. This solved all my UI problems. But it seems to
be something so basic that a solution like this should be implemented in
jface, what do you think? I cna try to explain better and clearly if it
seems interesting
thank you.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09898 seconds