public class EventManager
extends java.lang.Object
Keyboard.PROCEDURE_COMPLETE
event).
Documentation or testing showed no info which would suggest that keys/server events are processed in a certain way or chained in a certain way. When a server-event is posted, it will be chained in the event queue, but there is no guarantee where will be chained relative to other non-server events. 4GL enforces the server-event order only relative to other server-events and this only in case the events are not generated by truly asynchronous requests (like in the case of an appserver connected in Session-managed operating mode); for truly asynchronous requests (like in the case of an appserver connected in Session-free operating mode), the order of the server-events is undefined.
For this reason and for the fact that server-side events can be posted even when a WAIT-FOR
loop is not in effect, the server-events are kept in a global event queue
.
Modifier and Type | Class and Description |
---|---|
private static class |
EventManager.WorkArea
Stores global data relating to the state of the current context.
|
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
LOG
Logger.
|
private static ContextLocal<EventManager.WorkArea> |
work
Stores context-local state variables.
|
Modifier | Constructor and Description |
---|---|
private |
EventManager()
Hidden constructor, all usage of this class will be static.
|
Modifier and Type | Method and Description |
---|---|
static KeyInput |
eventFromKey(KeyCode key)
Convert a key code into a complete event (which includes the event's
source widget) by using the current widget in focus.
|
static Event |
getEvent()
Return next available event or
null if queue is empty. |
private static KeyInput |
getKeyEvent(int key,
Widget<?> src,
boolean isReal,
boolean isReleased)
Creates an instance of
keyEvent for specified key. |
static Event |
getOSEvent()
Get the next available OS event from the
EventManager.WorkArea.osEvents queue. |
static java.util.List<Event> |
getOSEvents()
Get the available OS events from the
EventManager.WorkArea.osEvents queue and clear the queue. |
static ServerEvent |
getServerEvent()
Get the next available server event from the
EventManager.WorkArea.serverEvents queue. |
static boolean |
hasOSEvents()
Check if there are pending mouse events in the
EventManager.WorkArea.osEvents queue. |
static boolean |
hasServerEvents()
Check if there are pending server events in the
EventManager.WorkArea.serverEvents queue. |
static boolean |
isEmptyEventStack()
Check if the event stack is empty.
|
static void |
popEventQueue()
Restore old event queue.
|
static void |
popOSEventQueue()
Restore old OS event queue.
|
static void |
postEvent(Event event)
Convenient shortcut for posting events.
|
static void |
postKey(int key)
Convenient shortcut for posting key events.
|
static boolean |
postMouseEvent(java.awt.event.MouseEvent event,
int windowId)
Saves the specified mouse event in the
EventManager.WorkArea.osEvents queue. |
static boolean |
postMouseEvent(java.awt.event.MouseEvent event,
int windowId,
int sourceId)
Saves the specified mouse event in the
EventManager.WorkArea.osEvents queue. |
static boolean |
postOSEvent(Event event)
Post an OS event (which needs to be processed by the 4GL drawing layer, but not
necessarily as a legacy 4GL event) to the event queue.
|
static void |
postServerEvent(ServerEvent event)
Saves the specified server event in the
EventManager.WorkArea.serverEvents queue, as server-side
events can be created if if a UI-blocking statement is not in effect. |
static void |
pushEventQueue()
Install new event queue.
|
static void |
pushOSEventQueue()
Install new OS event queue.
|
static void |
removeServerEvents(int[] eventIds)
Remove from the server event queue all the events in the given list, identified by their id.
|
private static boolean |
validateOSEvent(Event evt)
Validate an OS event: check that the event is not for a dead window.
|
private static final java.util.logging.Logger LOG
private static final ContextLocal<EventManager.WorkArea> work
private EventManager()
public static Event getEvent()
null
if queue is empty.public static boolean isEmptyEventStack()
public static void pushEventQueue()
public static void popEventQueue()
public static void pushOSEventQueue()
public static void popOSEventQueue()
public static boolean postMouseEvent(java.awt.event.MouseEvent event, int windowId)
EventManager.WorkArea.osEvents
queue.event
- The mouse event.windowId
- The window where the event was captured.true
if the event was posted.public static boolean postMouseEvent(java.awt.event.MouseEvent event, int windowId, int sourceId)
EventManager.WorkArea.osEvents
queue.event
- The mouse event.windowId
- The window where the event was captured.sourceId
- The explicit ID of the widget to which the mouse event needs to be posted.true
if the event was posted.public static boolean postOSEvent(Event event)
event
- The event to be posted.true
if the event was posted.public static boolean hasOSEvents()
EventManager.WorkArea.osEvents
queue.true
if there are pending mouse events, false
otherwise.public static Event getOSEvent()
EventManager.WorkArea.osEvents
queue.null
if the queue is empty.public static java.util.List<Event> getOSEvents()
EventManager.WorkArea.osEvents
queue and clear the queue.null
if there're no events.public static void postEvent(Event event)
event
- Event to post.public static void postServerEvent(ServerEvent event)
EventManager.WorkArea.serverEvents
queue, as server-side
events can be created if if a UI-blocking statement is not in effect.event
- The server event.public static void removeServerEvents(int[] eventIds)
eventIds
- The list of event IDs to be removed.public static ServerEvent getServerEvent()
EventManager.WorkArea.serverEvents
queue.null
if the queue is empty.public static boolean hasServerEvents()
EventManager.WorkArea.serverEvents
queue.true
if there are pending server events, false
otherwise.public static void postKey(int key)
key
- Key to post.public static KeyInput eventFromKey(KeyCode key)
key
- The key code of the event which was read from the terminal.null
in the case of any error.private static KeyInput getKeyEvent(int key, Widget<?> src, boolean isReal, boolean isReleased)
keyEvent
for specified key.key
- The key code.src
- The source widget for this event.isReal
- Flag which marks real keys pressed by user.private static boolean validateOSEvent(Event evt)
evt
- Event to check.true
if the event is valid.