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 EventLists. 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.
| Modifier and Type | Field and Description |
|---|---|
private static CentralLogger |
LOG
logger
|
| Constructor and Description |
|---|
TriggerManager() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
collectRowDisplayEvents(EventList list,
org.roaringbitmap.RoaringBitmap triggers)
Collect trigger IDs for row display events in an event list.
|
static void |
deregister(ScopedDictionary<?,?> registry,
EventList el)
Deregisters a trigger for specified events and widgets.
|
private static java.lang.String |
dumpRegistry(ScopedDictionary<?,?> registry)
Renders the registry as text.
|
private static java.lang.String |
dumpScope(java.util.LinkedList<EventList> scope,
java.lang.String descriptor)
Renders the given scope as text.
|
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.
|
private static boolean |
scopeFinished(java.util.LinkedList<EventList> source,
java.util.LinkedList<EventList> target)
Process a notification that a scope is about to be exited.
|
static boolean |
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.
|
private static final CentralLogger LOG
public static void scopeStart(ScopedDictionary<?,?> registry)
registry - ScopedDictionary that keeps track of trigger
registrations for this session.public static boolean 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.true if there were any events in the current scope.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 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.private static java.lang.String dumpRegistry(ScopedDictionary<?,?> registry)
registry - ScopedDictionary that keeps track of trigger registrations for this session.private static java.lang.String dumpScope(java.util.LinkedList<EventList> scope, java.lang.String descriptor)
scope - The scope to dump.descriptor - The dump descriptor, human-readableprivate static boolean scopeFinished(java.util.LinkedList<EventList> source, java.util.LinkedList<EventList> target)
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, may be nulltrue if there were any events in the current scope.private static void collectRowDisplayEvents(EventList list, org.roaringbitmap.RoaringBitmap triggers)
list - The source event listtriggers - The output trigger ID bitmap