This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

SWT does not respond to button clicks  RSS feed

Jay Damon
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am attempting to adapt the code from a web application (I wrote) to an existing SWT application. In a nutshell, the code contains a long running process that runs in the background (using Concurrency classes) on the server. The web application dialog allows the user to cancel the process (at any time) or even close the dialog and re-open the dialog later to check on the status.

FYI, the job executes a number of tasks but the number of tasks and the time to execute each task is unknown until runtime.

I created (what I thought was) similar code in the SWT application using asyncExec. Basically, the code checks the job status and, if it is not complete, the thread sleeps for 1 second. The job continues to check (and sleep) until the job status is complete. Before it sleeps, the job updates the user dialog progress bar as well as an information line with the current status – this works just fine.

The problem is that the SWT application is non-responsive to button clicks while the background job is running. For example, if I run the job using asyncExec, I see output similar to the following:

Entered checkProgress
Exited checkProgress
Executing task 1 of 10 . . .
Executing task 2 of 10 . . .
Executing task 3 of 10 . . .
Executing task 4 of 10 . . .
Executing task 5 of 10 . . .
Executing task 6 of 10 . . .
Executing task 7 of 10 . . .
Executing task 8 of 10 . . .
Executing task 9 of 10 . . .
Executing task 10 of 10 . . .
Batch job complete
Cancel button pressed (via (JFace) Dialog.buttonPressed)
Cancel button pressed (via SelectionListener)
Close button pressed (via (JFace) Dialog.buttonPressed)
Close button pressed (via SelectionListener)

The SWT application enters and exits the method checkProgress immediately (as one would expect). The “Cancel” and “Close” buttons are clicked immediately after submitting the job but, as you will note above, SWT does NOT respond to those events until after the batch job completes.

FYI, I have also attempted running the batch job using syncExec and inline. SWT is always non-responsive while the batch job is running.

I thought perhaps the problem might be with JFace as the extends the Dialog class but, as you will note above, both the JFace Dialog.buttonPress(int) method AND the selection listener (added later) are called.

The existing SWT application is actually an old Java Web Start application that talks to a web server. I though perhaps that may be the problem. However, I duplicated the user interface in its own class with a simulated batch job. SWT is still non-responsive to button clicks.

Although I am a web application developer, I have a fair knowledge of SWT and JFace. However, I fail to understand why SWT is non-responsive. FYI, my development machine is running Windows 7 and 64-bit SWT (swt-win32-windows-x86_64.jar).

Any suggestions as to why SWT is non-response or how to correct the problem would be appreciated.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!