Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » How to do a blocking, in-line refresh of shell in RAP(Force a refresh/update of a shell in RAP)
How to do a blocking, in-line refresh of shell in RAP [message #1001395] Wed, 16 January 2013 11:22 Go to next message
John Gymer is currently offline John Gymer
Messages: 185
Registered: November 2012
Location: UK
Senior Member
In a situation where I have a long-running piece of logic, but would like to refresh aspects of a Shell to indicate progress somehow, is there a simple way to do this in RAP (without separate threads) which will block until the refresh of the display is complete?

In SWT I can simply do this:

...
myShell.redraw();
myShell.update();
...


This works great, but in RAP it has no effect. Is there an easy way to achieve the same thing in RAP?

Thanks, John


---
Just because you can doesn't mean you should
Re: How to do a blocking, in-line refresh of shell in RAP [message #1001532 is a reply to message #1001395] Wed, 16 January 2013 17:04 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 99
Registered: February 2011
Member
You should never block the UI thread. The way to do this is with a separate thread.

Although it works in SWT, you shouldn't do it either. Your application will not be responding to UI events until your long running process finishes. This may cause the OS to think it has stopped responding (in Windows you may get a "Not Responding" message in the applications title bar) If the user maximises/resizes the window it won't be laid out correctly as the resize event isn't going to run until the event loop is run.
Re: How to do a blocking, in-line refresh of shell in RAP [message #1001777 is a reply to message #1001532] Thu, 17 January 2013 06:01 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 185
Registered: November 2012
Location: UK
Senior Member
Hi Chris,

Thanks for the reply.

Yes, I agree, that in principle the UI thread should never block, and designing any new application this should be adhered to.

My problem is that I'm writing a runtime intended to support a wide range of existing Windows/GUI applications (automatic transformation to RAP), which I do not wish to enforce my customers to recode this behaviour just to get it running the same under RAP. The most common example would be a progress indicator or some sort showing percentage complete, or similar.

Therefore, I'd like to be able to achieve an 'in-line' (in UI thread) 'refresh' of the display part-way through my logic. Yes, I understand the implications, that no user input event handling will be possible throughout the long-running process, but that's accepted in the design of these apps in the first place.

So, with that in mind... 'is' there a way to achieve a refresh within the UI thread?

(sorry, not meaning to be dog-brained about it - just trying to make transition for my customers as easy as possible).

Is RAP's new 'ServerPush' of any use here perhaps? (I haven't looked into this yet, so could be totally the wrong tree for my dog to bark up!)

Thanks, John


---
Just because you can doesn't mean you should

[Updated on: Thu, 17 January 2013 09:07]

Report message to a moderator

Re: How to do a blocking, in-line refresh of shell in RAP [message #1002632 is a reply to message #1001777] Fri, 18 January 2013 20:21 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 99
Registered: February 2011
Member
I'm not aware of a way to do what you want in rap. The request won't return to the browser until your code finishes. Shell.update won't work with rap
Re: How to do a blocking, in-line refresh of shell in RAP [message #1003486 is a reply to message #1002632] Mon, 21 January 2013 05:51 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 185
Registered: November 2012
Location: UK
Senior Member
Thanks Chris, that's what I figured. I'll have to figure out a different way to achieve it using background threads somehow.


---
Just because you can doesn't mean you should
Re: How to do a blocking, in-line refresh of shell in RAP [message #1003690 is a reply to message #1003486] Mon, 21 January 2013 15:03 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 99
Registered: February 2011
Member
If you're using the workbench or jface have a look at org.eclipse.jface.operation.ModalContext
Re: How to do a blocking, in-line refresh of shell in RAP [message #1004106 is a reply to message #1003690] Tue, 22 January 2013 10:29 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 185
Registered: November 2012
Location: UK
Senior Member
Hi Chris,

No, I'm not using jface or workbench.

However, I have recoded my event mechanism and pretty much got it working the way I need it to now.

My only outstanding issue is that I need to block any user interaction with the RAP windows/controls while my long running background thread is still going. I can do this successfully one of 2 ways so far, but they cause undesired effects...

Solution1) before kicking off the background thread I do a shell.setEnabled(false) on all the open shells, then shell.setEnabled(true) when the background thread finishes

Solution2) alternative is to create a new 'busy' shell (perhaps could contain a small animated graphic) which has SWT.APPLICATION_MODAL defined, then remove the shell when the background thread is done

Both techniques have the same issue in that all the other shells gain a 'disabled' look in RAP i.e. grey, pale colours etc. Functionally this works very well, but causes an unpleasant flashing when you are navigating around the application. I'd like the other shells' appearance to remain 'normal' during that period but still stop them from accepting any kind of user input... a bit like the 'hourglass' mouse cursor you get in Windows which indicates the application is busy, but the appearance of the windows remains the same.

Hope that makes some sense?

The above techniques work ok in SWT, since the shells don't get the 'greyed' appeared when disabled.

Ideally what I need would be to have a mechanism that stops/ignores all user input, until I tell it to accept it again... is that possible in RAP?

Thanks for your thoughts and time on this, by the way, it is most appreciated!

John


---
Just because you can doesn't mean you should
Re: How to do a blocking, in-line refresh of shell in RAP [message #1004197 is a reply to message #1004106] Tue, 22 January 2013 14:27 Go to previous messageGo to next message
Chris Fairhall is currently offline Chris Fairhall
Messages: 99
Registered: February 2011
Member
I think you can change the disabled look when showing a modal window in RAP using themes.

There is an option to change the "background glass" for modal windows.
Have a look at Shell-DisplayOverlay You can change the colour and opacity
Re: How to do a blocking, in-line refresh of shell in RAP [message #1004505 is a reply to message #1004197] Wed, 23 January 2013 06:11 Go to previous messageGo to next message
John Gymer is currently offline John Gymer
Messages: 185
Registered: November 2012
Location: UK
Senior Member
Superb Chris, thanks, this theming works perfectly for my modal 'progress' dialog, and I don't think I'd have found it on my own!
Very happy bunny here!
Cheers, John


---
Just because you can doesn't mean you should
Re: How to do a blocking, in-line refresh of shell in RAP [message #1005035 is a reply to message #1004505] Thu, 24 January 2013 06:07 Go to previous message
John Gymer is currently offline John Gymer
Messages: 185
Registered: November 2012
Location: UK
Senior Member
Just for completeness, here is the section of my CSS that sorts this out:

Shell-DisplayOverlay {
    background-image: none;
    background-color: #FFFFFF;
    opacity: 0.01;
}


Note that you cannot set opacity to 0 as this causes some internal problem in RAP (presumably a divide by 0!), but I can live with that.


---
Just because you can doesn't mean you should
Previous Topic:RWT Standalone Application fails with Firefox 3.6.13
Next Topic:Vertical alignment of Text widgets in RAP vs SWT
Goto Forum:
  


Current Time: Thu Jul 24 04:39:16 EDT 2014

Powered by FUDForum. Page generated in 0.03598 seconds