Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How to make my SWT application responsive during loading a lot of data
How to make my SWT application responsive during loading a lot of data [message #987271] Sun, 25 November 2012 13:45 Go to next message
Ondřej Kála is currently offline Ondřej KálaFriend
Messages: 7
Registered: November 2012
Junior Member
Hi,
I need my application to load some data and then proceed to next window. During loading time, I want to show some loading animation (GIF image?) and give the user option to minimize or move the application window. How do I do that correctly? I tried starting and joining threads, using Display.asyncExec or Display.syncExec but nothing worked. Thanks for help.

[Updated on: Sun, 25 November 2012 14:57]

Report message to a moderator

Re: How to make my SWT application responsive during loading a lot of data [message #987277 is a reply to message #987271] Sun, 25 November 2012 15:56 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 386
Registered: December 2010
Location: Germany
Senior Member
You can use the Thread class:
Runnable myRunnable = new Runnable() {
	public void run() {
		... use Display.a/syncExec inside this Thread to change the UI ...
	}
}
new Thread(myRunnable).start()

Re: How to make my SWT application responsive during loading a lot of data [message #987278 is a reply to message #987277] Sun, 25 November 2012 16:06 Go to previous messageGo to next message
Ondřej Kála is currently offline Ondřej KálaFriend
Messages: 7
Registered: November 2012
Junior Member
Christoph Keimel wrote on Sun, 25 November 2012 10:56
You can use the Thread class:
Runnable myRunnable = new Runnable() {
	public void run() {
		... use Display.a/syncExec inside this Thread to change the UI ...
	}
}
new Thread(myRunnable).start()



I dont want to change the UI until loading is over, I want it to not freeze during it.

Currently I create a thread that does the loading, is that wrong?
Re: How to make my SWT application responsive during loading a lot of data [message #987280 is a reply to message #987278] Sun, 25 November 2012 16:41 Go to previous messageGo to next message
Christoph Keimel is currently offline Christoph KeimelFriend
Messages: 386
Registered: December 2010
Location: Germany
Senior Member
Why does the following pattern not work for you?

Runnable myRunnable = new Runnable() {
	public void run() {
		... do the loading ...
		... use Display.a/syncExec to change the UI ...
	}
}
new Thread(myRunnable).start()
Re: How to make my SWT application responsive during loading a lot of data [message #987282 is a reply to message #987280] Sun, 25 November 2012 17:17 Go to previous messageGo to next message
Ondřej Kála is currently offline Ondřej KálaFriend
Messages: 7
Registered: November 2012
Junior Member
Christoph Keimel wrote on Sun, 25 November 2012 11:41
Why does the following pattern not work for you?

Runnable myRunnable = new Runnable() {
	public void run() {
		... do the loading ...
		... use Display.a/syncExec to change the UI ...
	}
}
new Thread(myRunnable).start()


What do you mean by "change the UI"? Showing the animation? I can do that, my main problem is that I want the UI window to react to mouse actions (move/resize/minimize) instead of being frozen.
Re: How to make my SWT application responsive during loading a lot of data [message #987288 is a reply to message #987282] Sun, 25 November 2012 18:07 Go to previous messageGo to next message
Ondřej Kála is currently offline Ondřej KálaFriend
Messages: 7
Registered: November 2012
Junior Member
Sorry, I forgot to remove the join of thread, it works now, thanks.
Re: How to make my SWT application responsive during loading a lot of data [message #987302 is a reply to message #987271] Sun, 25 November 2012 21:13 Go to previous message
Ondřej Kála is currently offline Ondřej KálaFriend
Messages: 7
Registered: November 2012
Junior Member
And for the displaying of GIF, I used this code:

http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet141.java

but I need it to show on top of everything, how do I do that?
Previous Topic:Multiple viewport on the same canvas
Next Topic:What is gtk_main_do_event doing?
Goto Forum:
  


Current Time: Tue Dec 23 01:32:41 GMT 2014

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

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