-- /ivy/binding/calendar/calEnterImpl.mesa
-- to enter events into hickory, i.e finish up the job started in CalFormImplC.
-- Last edited by: Binding, August 17, 1984 8:19:45 am PDT
DIRECTORY
CalEnter,
CalStorage USING [ protData],
CalSupport USING [ DisplayMsg],
Hickory USING [ Event, EventList, EventTuple, GroupSet, EnterEvent, InsertToGroup, SameEventTuple, ChangeEvent, ListGroups, RemoveFromGroup],
Rope USING [ ROPE],
RopeSets USING [ RopeSetEl, Difference]
;
CalEnterImpl: CEDAR MONITOR
LOCKS CalStorage.protData
IMPORTS Hickory, RopeSets, CalStorage, CalSupport
EXPORTS CalEnter
SHARES CalSupport
= BEGIN
EnterEvents: PUBLIC INTERNAL PROCEDURE [ evt: REF Hickory.EventTuple, evl: Hickory.EventList, groups: Hickory.GroupSet] = BEGIN
to enter the events into calendar and hickory. Conflicts are not detected, since
detecting conflicting events in the case of repeated events is too expensive...
The list of events evl can potentially have the very first elem. with a non nil key,
because an event has been edited. see calFormImplB.TranslateSelection
eventGroups: Hickory.GroupSet; -- in what groups is an edited event?
FOR l: Hickory.EventList ← evl, l.rest UNTIL l = NIL DO
IF l.first.Key = NIL THEN BEGIN -- it's a new event for hickory
l.first ← Hickory.EnterEvent[ l.first, [ NIL, NIL]];
eventGroups ← [ NIL, NIL];
END
ELSE IF evt # NIL THEN BEGIN -- the first el. is the edited event...
eventGroups ← Hickory.ListGroups[ l.first.Key];
IF NOT Hickory.SameEventTuple[ evt^, l.first] THEN
Hickory.ChangeEvent[ evt^, l.first];
END
ELSE ERROR;
Hickory.InsertToGroup[ ev: l.first.Key, groups: RopeSets.Difference[ groups, eventGroups]];
Hickory.RemoveFromGroup[ ev: l.first.Key, groups: RopeSets.Difference[ eventGroups, groups]];
ENDLOOP;
CalSupport.DisplayMsg[ "Event(s) entered into Hickory", FALSE];
END; -- EnterEvents
END.