How to automatically refresh a view without any action by the user [message #463643] |
Tue, 13 February 2007 22:14  |
Eclipse User |
|
|
|
I have been working on a RCP with a Table viewer based on the wizard in
the view extension.
This view shows information from an FTP log. The table shows objects in a
TreeMap class which is updated every few minutes. Table entries in which
the file is late or has a problem have an image to indicate the problem.
When the user "does something" to the view, such as sorting by column, the
IStructuredContentProvider class is called. The class sees that the
underlying TreeMap has been updated and the contents of the view are
refreshed.
The program which provides the TreeMap is running on the server. Every
few minutes it wakes up, deserialized the TreeMap, updates it, serializes
it and then sets a semiphore or trigger file.
The IStructuredContentProvider of the RCP program checks the semiphore or
trigger file, if present it deserialized the updated TreeMap and refreshes.
That is probably more than you care to know!
I'd like the view to be self refreshing, so table is update without having
to wait for the user to do something which causes the
IStructuredContentProvider to be called.
Does anyone have ideas how to do this? Methods to override?
In a general sense a thread could be started which wakes up and checks the
semiphore every few minutes and gives the RCP a kick to update the
display. But what to kick?
Thanks all
Bill Blalock
|
|
|
|
|
Re: How to automatically refresh a view without any action by the user [message #463691 is a reply to message #463682] |
Wed, 14 February 2007 11:03   |
Eclipse User |
|
|
|
Concerning the problem, which view should be refreshed, Paul Webster wrote:
"In IWorkbenchPage there are methods like isPartVisible(*) and
getViewStack(*).
Later,
PW "
HTH,
Stefan
Bill Blalock schrieb:
> Cem Dayanik wrote:
>
>> have you tried using TableViewer#refresh() method?
>
>> you need use Display#syncExec/asyncExec to update UI.
>
>
> Is this what you mean?
> Activator.getDefault().getWorkbench().getDisplay().syncExec(
> new Runnable() {
> public void run(){
> FtpClientView.plugin.viewer.refresh();
> }
> });
>
> where "plugin" is a public static variable of FtpClient and "viewer" is
> a public instance of the TableViewer?
>
> =====================================================
>
> If there are multiple views in the RCP how can the program which does
> this tell which view is on top and needs to be refreshed? Or refresh both?
>
> My program has two view, FtpClientView and FtpServerView. Ususally one
> is on top of the other.
>
> Thanks
> Bill Blalock
>
>
>> "Bill Blalock" <Bill.Blalock@certegy.com> wrote in message
>> news:710cca59b04848e0ab3426015db449d0$1@www.eclipse.org...
>>> I have been working on a RCP with a Table viewer based on the wizard
>>> in the view extension.
>>>
>>> This view shows information from an FTP log. The table shows objects
>>> in a TreeMap class which is updated every few minutes. Table entries
>>> in which the file is late or has a problem have an image to indicate
>>> the problem.
>>>
>>> When the user "does something" to the view, such as sorting by
>>> column, the IStructuredContentProvider class is called. The class
>>> sees that the underlying TreeMap has been updated and the contents of
>>> the view are refreshed.
>>>
>>> The program which provides the TreeMap is running on the server.
>>> Every few minutes it wakes up, deserialized the TreeMap, updates it,
>>> serializes it and then sets a semiphore or trigger file.
>>>
>>> The IStructuredContentProvider of the RCP program checks the
>>> semiphore or trigger file, if present it deserialized the updated
>>> TreeMap and refreshes.
>>>
>>> That is probably more than you care to know!
>>>
>>> I'd like the view to be self refreshing, so table is update without
>>> having to wait for the user to do something which causes the
>>> IStructuredContentProvider to be called.
>>>
>>> Does anyone have ideas how to do this? Methods to override?
>>> In a general sense a thread could be started which wakes up and
>>> checks the semiphore every few minutes and gives the RCP a kick to
>>> update the display. But what to kick?
>>>
>>> Thanks all
>>> Bill Blalock
>>>
>>>
>
>
|
|
|
|
|
|
Re: How to automatically refresh a view without any action by the user [message #463844 is a reply to message #463842] |
Fri, 16 February 2007 09:29  |
Eclipse User |
|
|
|
there 2 things to consider when calling refresh:
- if you recreate all model elements instance from the datasource you
need to use setComparer() to:
- ensure that TableViewer works efficiently
- ensure that Selections are preserved
- if you have structural changes like e.g. removed items in between
tableviewer code needs to reassociate all elements starting at
position you removed the item (the same is true if an item is added
somewhere in between)
if you want to be as efficient as possible I'd suggest to build the
model diff your own and use insert/add/remove/update methods from
TableViewer directly and maybe even turn of table updateing in between
by setting Table#setRedraw(false).
Tom
Paul Webster schrieb:
> Bill Blalock wrote:
>> Hi Paul:
>>
>> You wrote:
>>
>>> The common way is described in this thread ...
>>
>> Did you mean to link to a discussion thread in this newsgroup? I ask
>> because I'd like to read it.
>
> :-) I meant this thread.
>
> One common way to do this (that was already described in this thread) is
> to is to have your incoming data update your model and then use
> display.asyncExec(*) to call refresh on your JFace Viewer.
>
> Then your viewer would be refreshed with each incoming message.
>
> All I was adding was that if you prefer just to have your views updated
> every 10 seconds (say there can be a lot of incoming messages) instead
> of on every message you could schedule a UIJob which would basically
> check to see if the model had any messages and if so, call refresh on
> your viewer.
>
> Later,
> PW
|
|
|
Powered by
FUDForum. Page generated in 0.03981 seconds