com.sdm.quasar.client.swing.dialog.services.impl
Class SwingModalBlockHelperService
java.lang.Object
com.sdm.quasar.client.swing.dialog.services.impl.SwingModalBlockHelperService
- All Implemented Interfaces:
- ModalBlockHelperService, Service
- public class SwingModalBlockHelperService
- extends java.lang.Object
- implements ModalBlockHelperService
Default implementation for com.sdm.quasar.client.core.common.util.ModalBlockWorkaroundWorker
for Swing's modal dialogs.
This implementation's constructor stores this instance in a thread local variable in the EDT thread
so that static access to actually support an expected switch in the event queue works.
It is not possible to create more than one instance per EDT thread.
- Version:
- 1.0
- Author:
- Bernd Olleck, sd&m AG
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SwingModalBlockHelperService
public SwingModalBlockHelperService()
startJob
public void startJob(ModalBlockHelperService.JobQueue jobQueue)
- This processes the job queue until it is empty.
When a modal dialog should be displayed,
a call to
showDialogAndContinueActivation(Dialog)
must be called. That adds a Runnable to execute the job queue in the current EDT event queue
using SwingUtilities.invokeLater(java.lang.Runnable).
This has the following effect:
-
If none of the jobs create a modal dialog:
In this case none of the calls to
JobQueue#doNextJob() block and
the complete queue is executed in this context.
When the Runnable is executed in the EDT lateron it simply finds that
the queue is already finished and does nothing.
-
If one of the jobs creates a modal dialog:
In this case that call to
JobQueue#doNextJob() blocks and does not return.
However, after the dialog is displayed, a new event queue is created by swing and
that event queue executes the Runnable. The loop in the Runnable
continues with the next job and runs until JobQueue#isFinished().
When the modal dialog is closed, the call to JobQueue#doNextJob() that
blocked returns and the "main" loop in this implementation continues but
finds that the job queue is already finished and does nothing.
- Specified by:
startJob in interface ModalBlockHelperService
- Parameters:
jobQueue - the job queue to be processed- See Also:
ModalBlockWorkaroundWorker#startJob(JobQueue)
showDialogAndContinueActivation
public static void showDialogAndContinueActivation(java.awt.Dialog dialog)
- This method must be called when a modal dialog should be displayed.
The implementation will call
Dialog.show() on the given dialog
but also ensure that the activation life cycle will complete despite the blocking call.
This method must only be called in the EDT.
- Parameters:
dialog - the modal dialog to show