DIRECTORY DB, DefaultNutUtilities, IO, InputFocus, Nut, NutOps, NutViewer, ViewerOps, Buttons; DefaultNutUtilitiesImpl: CEDAR PROGRAM IMPORTS DB, Nut, NutOps, NutViewer, InputFocus, ViewerOps EXPORTS DefaultNutUtilities = BEGIN OPEN DB, NutViewer; SpawnParent: PROC[v: Viewer] RETURNS [parent: Viewer] = { parent _ v; WHILE parent.parent # NIL DO parent _ parent.parent ENDLOOP }; ProcessSelection: PUBLIC Buttons.ButtonProc = -- A standard ButtonProc that assumes the button's REF ANY data is the FieldHandle above. -- Insures attribute of tuple is entity-valued and non-NIL, then calls Nut.Display on it. BEGIN OPEN DB; otherEntity: Entity; fd: DefaultNutUtilities.FieldHandle_ NARROW[clientData]; viewer: Viewer_ NARROW[parent]; IF fd.attribute=NIL THEN -- it was the relation itself { otherEntity _ RelationOf[fd.tuple]; IF NOT DB.Null[otherEntity] THEN [] _ Nut.Display[eName: DB.NameOf[otherEntity], domain: "RelationDomain", parent: SpawnParent[viewer], segment: DB.SegmentOf[otherEntity]] } ELSE IF NutOps.EntityValued[fd.attribute] THEN -- attribute refs another entity IF Null[fd.tuple] THEN Message[viewer, "That relationship has been deleted!"] ELSE IF Null[otherEntity_V2E[GetF[fd.tuple, fd.attribute]]] THEN Message[viewer, "That entity has been deleted!"] ELSE { otherEntity _ V2E[GetF[fd.tuple, fd.attribute]]; [] _ Nut.Display[eName: DB.NameOf[otherEntity], domain: DB.NameOf[DB.DomainOf[otherEntity]], parent: SpawnParent[viewer], segment: DB.SegmentOf[otherEntity]] } ELSE -- attribute is a string or number Message[viewer, "Not an entity-valued field"]; END; Reset: PUBLIC PROC[eName, domain: ROPE, seg: DB.Segment, viewer: Viewer] = BEGIN -- Resets contents of editor to its statebefore edits started. InputFocus.SetInputFocus[]; -- kill the caret viewer.child _ NIL; ViewerOps.PaintViewer[viewer, client]; [] _ Nut.Edit[eName: eName, domain: domain, segment: seg, parent: viewer] ; END; Edit: PUBLIC PROC[eName, domain: ROPE, seg: DB.Segment, parent: Viewer] = BEGIN -- Invoked when hit the "Edit" button on the default displayer. -- Should replace the displayer viewer with an editor viewer. InputFocus.SetInputFocus[]; IF NutOps.IsSystemEntity[eName] THEN BEGIN [] _ NutViewer.Message[NIL, eName, " is a system entity. You may not edit it."]; RETURN; END; [] _ Nut.Edit[ eName: eName, domain: domain, segment: seg, parent: parent]; END; END. . . ¼File: DefaultNutUtilitiesImpl.mesa CreatedBy: Butler on June 18, 1984 9:25:04 am PDT Last Edited By: Butler on June 27, 1984 3:52:35 pm PDT Widom on June 18, 1984 9:25:39 am PDT Ê+˜Jšœ"™"J™1™J™'J™&—J™J™šÏk ˜ Jšœ˜J˜Jšœ˜Jšœ ˜ J˜J˜J˜ J˜ Jšœ˜—J˜šœœ˜&š˜Jšœ/˜1—Jšœ˜—J˜Jš˜Jšœœ ˜J˜šÏn œœ œ˜9Jš œ œœœœ˜JJ˜—Jš4ÏbœœÏcZœ Zœœœœ@œ œ œœœ œçœœ#œ !œœœBœœ5œ<œäœ #œ5œ˜ü J˜š Ðbnœœœœœ˜Kš˜Jš >˜>Jšœ ˜-Jšœœ˜Jšœ&˜&JšœK˜KJšœ˜J˜——š Ÿœœœœœ˜Jš˜Jš ?˜?Jš =˜=Jšœ˜šœœ˜*Jšœœ7˜QJšœ˜Jšœ˜—JšœK˜KJšœ˜J˜——Jšœ˜—…— œ ƒ