Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Eclipse View Refresh Problem
Eclipse View Refresh Problem [message #760016] Wed, 30 November 2011 23:19 Go to next message
Kaustubh Missing name is currently offline Kaustubh Missing nameFriend
Messages: 14
Registered: November 2011
Junior Member
I am kinda new to Eclipse RAP development. I have several SWT labels on my RAP view and the text on the label changes depending upon the data stored in CSV file. Whenever the CSV file changes, the label text is supposed to change. However, I am not able to see the text updating unless I resize my browser. Can anybody guide me how to solve this issue and get the RAP refresh done without resizing?

thanks
KAUS
Re: Eclipse View Refresh Problem [message #760025 is a reply to message #760016] Thu, 01 December 2011 00:16 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
Kaus,

if you are using background threads and Display#(a)syncExec() to update
the UI, then you will have to activate the UICallback [1] to push the
updates to the browser.
If this doesn't answer your question, then please provide more details.

Regards,
Rüdiger
[1] http://wiki.eclipse.org/RAP/UI_Callback

On 01.12.2011 00:19, Kaustubh wrote:
> I am kinda new to Eclipse RAP development. I have several SWT labels on
> my RAP view and the text on the label changes depending upon the data
> stored in CSV file. Whenever the CSV file changes, the label text is
> supposed to change. However, I am not able to see the text updating
> unless I resize my browser. Can anybody guide me how to solve this issue
> and get the RAP refresh done without resizing?
> thanks
> KAUS
--
Rüdiger Herrmann
http://codeaffine.com
Re: Eclipse View Refresh Problem [message #760051 is a reply to message #760025] Thu, 01 December 2011 05:58 Go to previous messageGo to next message
Kaustubh Missing name is currently offline Kaustubh Missing nameFriend
Messages: 14
Registered: November 2011
Junior Member
Thanks Rudiger. This is something what I am trying to do let me know if that is not sufficient.
----------------------------------------------------------------------
final Runnable runnable = new Runnable(){
public void run(){
UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
public void run(){
// update SWT Label, Canvas, Composite.
}
}
}
}
display.asyncExec(runnable);
----------------------------------------------------------------------
When I tried with display.syncExec() everything was frozen and it stopped responding and hence I changed it to asyncExec() and the display refreshed after resizing. Can you also tell me how to activate the UICallBack thread.
Re: Eclipse View Refresh Problem [message #760053 is a reply to message #760025] Thu, 01 December 2011 05:58 Go to previous messageGo to next message
Kaustubh is currently offline KaustubhFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks Rudiger. This is something what I am trying to do let me know if that is not sufficient.
----------------------------------------------------------------------
final Runnable runnable = new Runnable(){
public void run(){
UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
public void run(){
// update SWT Label, Canvas, Composite.
}
}
}
}
display.asyncExec(runnable);
----------------------------------------------------------------------
When I tried with display.syncExec() everything was frozen and it stopped responding and hence I changed it to asyncExec() and the display refreshed after resizing. Can you also tell me how to activate the UICallBack thread.
Re: Eclipse View Refresh Problem [message #760103 is a reply to message #760053] Thu, 01 December 2011 10:34 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 335
Registered: July 2009
Senior Member
please see the FAQ [1] and the JavaDoc on how to work with the UICallback.

If syncExec() freezes it is likely that you ran into a deadlock, either
caused by your code or by RAP code. If you can make sure that your code
doesn't cause the deadlock and it is reproducible with the latest
version of RAP, please file a bugzilla [2].

[1]
http://wiki.eclipse.org/RAP/FAQ#How_to_update_the_UI_from_a_background_thread
[2] http://eclipse.org/rap/support/#new-bugs

On 01.12.2011 06:58, Kaustubh wrote:
> Thanks Rudiger. This is something what I am trying to do let me know if
> that is not sufficient.
> ----------------------------------------------------------------------
> final Runnable runnable = new Runnable(){
> public void run(){
> UICallBack.runNonUIThreadWithFakeContext(display, new Runnable() {
> public void run(){
> // update SWT Label, Canvas, Composite.
> }
> }
> }
> }
> display.asyncExec(runnable);
> ----------------------------------------------------------------------
> When I tried with display.syncExec() everything was frozen and it
> stopped responding and hence I changed it to asyncExec() and the display
> refreshed after resizing. Can you also tell me how to activate the
> UICallBack thread.
--
Rüdiger Herrmann
http://codeaffine.com
Re: Eclipse View Refresh Problem [message #760483 is a reply to message #760103] Fri, 02 December 2011 14:31 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

By design, syncExec() will always block the current thread until the Runnable has been processed by the UI Thread. In RAP this can be very dangerous since the UI Thread only runs when the user initiates an action (except in the case of UICallback). Also, if the user has already closed their browser but the session has not yet timed out then the calling thread will block forever. Also there is an outstanding bug in RAP[1] that will not release the calling thread even when the display is disposed.

IMHO, syncExec() should never be used in RAP due to the asynchronous nature of RAP and the unexpected consequences that result. Users tend to think that it will let them update the UI from a background thread, but that is not the case. Updating from a background thread is covered in the FAQ that Rüdiger linked to.


Hope that helps users avoid confusion,

Cole

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=328347
Re: Eclipse View Refresh Problem [message #760488 is a reply to message #760103] Fri, 02 December 2011 14:31 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

By design, syncExec() will always block the current thread until the Runnable has been processed by the UI Thread. In RAP this can be very dangerous since the UI Thread only runs when the user initiates an action (except in the case of UICallback). Also, if the user has already closed their browser but the session has not yet timed out then the calling thread will block forever. Also there is an outstanding bug in RAP[1] that will not release the calling thread even when the display is disposed.

IMHO, syncExec() should never be used in RAP due to the asynchronous nature of RAP and the unexpected consequences that result. Users tend to think that it will let them update the UI from a background thread, but that is not the case. Updating from a background thread is covered in the FAQ that Rüdiger linked to.


Hope that helps users avoid confusion,

Cole

[1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=328347
Re: Eclipse View Refresh Problem [message #760564 is a reply to message #760483] Fri, 02 December 2011 23:30 Go to previous messageGo to next message
Kaustubh Missing name is currently offline Kaustubh Missing nameFriend
Messages: 14
Registered: November 2011
Junior Member
Thanks Cole and Rudiger. This was really helpful. I guess I should be able to solve this in a day or two. I should have posted my question long back as I am struggling for a month for this issue !

Could you please provide me an example of how to activate UICallback? I am not really understanding how to do it and what should be the callback id.

-Kaustubh
Re: Eclipse View Refresh Problem [message #760566 is a reply to message #760488] Fri, 02 December 2011 23:30 Go to previous messageGo to next message
Kaustubh is currently offline KaustubhFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks Cole and Rudiger. This was really helpful. I guess I should be able to solve this in a day or two. I should have posted my question long back as I am struggling for a month for this issue !

Could you please provide me an example of how to activate UICallback? I am not really understanding how to do it and what should be the callback id.

-Kaustubh
Re: Eclipse View Refresh Problem [message #760965 is a reply to message #760566] Mon, 05 December 2011 18:08 Go to previous messageGo to next message
Kaustubh Missing name is currently offline Kaustubh Missing nameFriend
Messages: 14
Registered: November 2011
Junior Member
Thanks a lot guys for your support. It worked ! I still need to test this on the server but I am sure it will work. I was trying to activate UICallBack in UI class whereas I read somewhere that it should be done in ApplicationWorkbenchAdvisor class in poststartup method to make sure it is activated right at the beginning.

Anyways, thanks and I will post new message if it fails on the server.

-Kaustubh
Re: Eclipse View Refresh Problem [message #760967 is a reply to message #760566] Mon, 05 December 2011 18:08 Go to previous message
Kaustubh is currently offline KaustubhFriend
Messages: 16
Registered: July 2009
Junior Member
Thanks a lot guys for your support. It worked ! I still need to test this on the server but I am sure it will work. I was trying to activate UICallBack in UI class whereas I read somewhere that it should be done in ApplicationWorkbenchAdvisor class in poststartup method to make sure it is activated right at the beginning.

Anyways, thanks and I will post new message if it fails on the server.

-Kaustubh
Previous Topic:Style setting mechanism
Next Topic:How to manage Ctrl+Space for autocomple text assist with RAP with ContentProposalAdapter
Goto Forum:
  


Current Time: Thu Apr 25 12:29:00 GMT 2024

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

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

Back to the top