Package com.luciad.lucy.gui.status
Class TLcyUserInteractionBlocker
java.lang.Object
com.luciad.lucy.gui.status.TLcyUserInteractionBlocker
- All Implemented Interfaces:
ILcdStatusListener
,EventListener
Implementation of
ILcdStatusListener
that blocks user interaction with a given frame
between receiving a START_BUSY
and an END_BUSY
status event, provided
the blocking hint of those events is set to true
. It displays a mouse cursor of choice,
typically a wait cursor, while the user interface is blocked.
As this listener blocks the user interface when a START_BUSY
event is received, it
is very important that an END_BUSY
event is received as well. Implementations firing
a START_BUSY
event (with blocking hint set to true
) should therefore be
carefully implemented to make sure an END_BUSY
is fired as well, even if for example
an exception has occurred. If required, the method stopBlocking()
can be used to make
sure the user interface is not blocked.- See Also:
-
Constructor Summary
ConstructorDescriptionTLcyUserInteractionBlocker
(JFrame aTargetFrame) Constructs a newTLcyUserInteractionBlocker
, without a delay and with aCursor.WAIT_CURSOR
.TLcyUserInteractionBlocker
(JFrame aTargetFrame, Cursor aCursor) Constructs a newTLcyUserInteractionBlocker
, without a delay, and with the given mouse cursor.TLcyUserInteractionBlocker
(JFrame aTargetFrame, Cursor aCursor, int aDelay) Constructs a newTLcyUserInteractionBlocker
, with the given delay and given mouse cursor. -
Method Summary
Modifier and TypeMethodDescriptionReturns the keys strokes that, when pressed, stop blocking the user interface.void
setStopBlockingKeyStrokes
(KeyStroke[] aStopBlockingKeyStrokes) Sets the key strokes that, when pressed, stop the user interface from blocking.void
statusChanged
(TLcdStatusEvent event) Handles the given status event by blocking the user interface if this condition holds:void
Stops blocking the user interface if it was being blocked.
-
Constructor Details
-
TLcyUserInteractionBlocker
Constructs a newTLcyUserInteractionBlocker
, without a delay and with aCursor.WAIT_CURSOR
. It is up to the user of this method to add it to a source ofTLcdStatusEvent
s, for exampleILcyLucyEnv
.- Parameters:
aTargetFrame
- The frame to block the user input from.- See Also:
-
TLcyUserInteractionBlocker
Constructs a newTLcyUserInteractionBlocker
, without a delay, and with the given mouse cursor. It is up to the user of this method to add it to a source ofTLcdStatusEvent
s.- Parameters:
aTargetFrame
- The frame to block the user input from.aCursor
- The mouse cursor to display while blocking the user interface.
-
TLcyUserInteractionBlocker
Constructs a newTLcyUserInteractionBlocker
, with the given delay and given mouse cursor. It is up to the user of this method to add it to a source ofTLcdStatusEvent
s.- Parameters:
aTargetFrame
- The frame to block the user input from.aCursor
- The mouse cursor to display while blocking the user interface.aDelay
- The delay, in milliseconds, before blocking the UI. When aSTART_BUSY
event is received, the user interface is only blocked after the given time delay. This can help avoid flickering caused by bursts of short tasks.
-
-
Method Details
-
getStopBlockingKeyStrokes
Returns the keys strokes that, when pressed, stop blocking the user interface.- Returns:
- the keys strokes that, when pressed, stop blocking the user interface.
- See Also:
-
setStopBlockingKeyStrokes
Sets the key strokes that, when pressed, stop the user interface from blocking. This is mainly useful to allow the user to continue using the application in the event someILcdStatusListener
, for some exceptional reason, only fired aSTART_BUSY
event and noSTOP_BUSY
event. Note that pressing any of the given key strokes has the same effect as a call tostopBlocking()
.- Parameters:
aStopBlockingKeyStrokes
- The key strokes that, when pressed, stop blocking the user interface. Typical values are control-c or escape.- See Also:
-
stopBlocking
public void stopBlocking()Stops blocking the user interface if it was being blocked. There is normally no need to call this method, but it can for example be useful to make sure the user interface does not remain blocked if some uncaught exception occurred.- See Also:
-
statusChanged
Handles the given status event by blocking the user interface if this condition holds:
Unblocks the user interface if this condition holds:event.getID() == TLcdStatusEvent.START_BUSY && event.isBlockingHint()
Nested busy events are supported as well, causing the user interface to unblock only after all nested tasks are ended.event.getID() == TLcdStatusEvent.END_BUSY && event.isBlockingHint()
- Specified by:
statusChanged
in interfaceILcdStatusListener
- Parameters:
event
- The status event describing the status change.
-