public class TriggerManager
extends java.lang.Object
Registrations are kept in a scoped dictionary. Every top level block creates
a new scope for triggers in scopeStart
method. The registry
inside the scope is a LinkedList
of EventList
objects. The list is stored as the scope extra object, so the dictionary is
not in use.
The scope's registry works as a FIFO stack for EventList
s. The
most recent registration is added to the list head.
Deregistration may require full removal of one or more
EventList
objects
or editing their contents. Editing happens when only some events for a
widget have to be deregistered, but some others remain active.
Constructor and Description |
---|
TriggerManager() |
Modifier and Type | Method and Description |
---|---|
private static void |
cleanup(EventList list,
java.util.Set<java.lang.Integer> triggers)
Handle the cleanup associated with a given event list.
|
private static void |
clearRowDisplay(java.util.Set<java.lang.Integer> triggers)
Remove the given widgets from the client-side list of widgets which must
get notifications of row display events.
|
static void |
computeTriggerDifferences(ServerReturnValue srv,
EventList prevTriggers,
EventList currentTriggers)
Compute trigger differences from the specified list.
|
static void |
deregister(ScopedDictionary<?,?> registry,
EventList el)
Deregisters a trigger for specified events and widgets.
|
static EventList |
mergeTriggerRegistry(ScopedDictionary<?,?> registry)
Merges all trigger registry entries of all scopes and produces a
EventList instance that represents all sensitive widgets
with all event codes they are sensitive to. |
static void |
register(ScopedDictionary<?,?> registry,
EventList events,
int tid)
Registers a trigger within the current scope.
|
(package private) static void |
scopeFinished(java.util.LinkedList<EventList> source,
java.util.LinkedList<EventList> target,
boolean cleanup)
Process a notification that a scope is about to be exited.
|
static void |
scopeFinished(ScopedDictionary<?,?> registry)
Process a notification that a scope is about to be exited.
|
static void |
scopeStart(ScopedDictionary<?,?> registry)
Process a notification that a new block scope is about to be entered.
|
public static void scopeStart(ScopedDictionary<?,?> registry)
registry
- ScopedDictionary
that keeps track of trigger
registrations for this session.public static void scopeFinished(ScopedDictionary<?,?> registry)
All non-persistent triggers registered in the scope are deregistered.
All persistent triggers registered in this scope are moved to the previous scope.
registry
- ScopedDictionary
that keeps track of trigger
registrations for this session.public static void register(ScopedDictionary<?,?> registry, EventList events, int tid)
registry
- Tracks trigger registrations for this session.events
- Defines the events and widgets on which to execute this trigger.tid
- The trigger ID.public static void deregister(ScopedDictionary<?,?> registry, EventList el)
In Progress, requests to deregister (REVERT) the very first trigger definition for a pair of {event, widget} are silently ignored.
Triggers are deregistered only from the current scope. If there are definitions of this trigger in previous scopes (or if this is an ANYWHERE trigger), then all definitions are removed; otherwise, all are removed but one.
Trigger deregistration is complicated. Triggers are registered for a
list of set pairs like:
{(event1, event2) (widget1, widget2)} // item 1
{(event1, event2) (widget1, widget2, widget3)} // item 2
...
A deregistration request may come, for example, for event2 of widget1
and event1 of widget2 and event10 of widget1000. Deregistration should
be made for the first encountered match {event, widget} and the
remaining registrations should be kept. So, in that case:
{(event1) (widget1)} // item 1.1
{(event2) (widget2)} // item 1.2
{(event1, event2) (widget1, widget2, widget3)} // item 2
...
is the result.
registry
- ScopedDictionary
that keeps track of trigger
registrations for this session.el
- EventList
object, encoding events and widgets this
request has come forpublic static void computeTriggerDifferences(ServerReturnValue srv, EventList prevTriggers, EventList currentTriggers)
ServerReturnValue.newTriggers
and the dead triggers will be saved in
ServerReturnValue.deadTriggers
.srv
- The trigger's return data container, where the event lists will be saved.prevTriggers
- The trigger list before the trigger was invoked.currentTriggers
- The trigger list after the trigger was invoked.public static EventList mergeTriggerRegistry(ScopedDictionary<?,?> registry)
EventList
instance that represents all sensitive widgets
with all event codes they are sensitive to.registry
- ScopedDictionary
that keeps track of trigger
registrations for this session.EventList
of all registry entries.static void scopeFinished(java.util.LinkedList<EventList> source, java.util.LinkedList<EventList> target, boolean cleanup)
All non-persistent triggers registered in the scope are deregistered if current block is not an external procedure.
All persistent triggers registered in this scope are moved to the previous scope.
source
- The source event list.target
- The target where the persistent triggers will be merged.cleanup
- Flag indicating if the triggers are cleaned up using
cleanup(EventList, Set)
.private static void cleanup(EventList list, java.util.Set<java.lang.Integer> triggers)
list
- The event list to be deregistered.triggers
- The list of widgets no longer needing row display notifications.
This will be modified on output to add any widgets that need
to be removed from the notification list.private static void clearRowDisplay(java.util.Set<java.lang.Integer> triggers)
triggers
- The list of widgets no longer needing row display notifications.