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; FieldHandle: PUBLIC TYPE = REF FieldObject; FieldObject: PUBLIC TYPE = RECORD[ tuple: Relship, attribute: Attribute ]; 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: FieldHandle_ NARROW[clientData]; viewer: Viewer_ NARROW[parent]; IF fd.attribute=NIL THEN -- it was the relation itself { newV: Viewer; otherEntity _ RelationOf[fd.tuple]; newV _ NutViewer.SpawnViewer[e: otherEntity, seg: NutOps.SafeSegmentOf[otherEntity], parent: viewer.parent]; Nut.Display[e: otherEntity, newV: newV, seg: NutOps.SafeSegmentOf[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 { newV: Viewer; otherEntity _ V2E[GetF[fd.tuple, fd.attribute]]; newV _ NutViewer.SpawnViewer[e: otherEntity, seg: NutOps.SafeSegmentOf[otherEntity], parent: viewer.parent]; Nut.Display[e: otherEntity, newV: newV, seg: NutOps.SafeSegmentOf[otherEntity]] } ELSE -- attribute is a string or number Message[viewer, "Not an entity-valued field"]; END; Reset: PUBLIC PROC[eName: ROPE, d: DB.Domain, seg: DB.Segment, parent: Viewer] = BEGIN -- Resets contents of editor to its statebefore edits started. e: DB.Entity; e _ DB.FetchEntity[d, eName, seg ! DB.Error => { e _ NIL; CONTINUE } ]; InputFocus.SetInputFocus[]; -- kill the caret parent.child _ NIL; ViewerOps.PaintViewer[parent, $client]; Nut.Edit[e: e, eName: eName, d: d, seg: seg, newV: parent] ; END; Edit: PUBLIC PROC[eName: ROPE, d: DB.Domain, 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. e: Entity _ FetchEntity[d: d, name: eName]; newV: Viewer; InputFocus.SetInputFocus[]; IF NutOps.IsSystemEntity[e] THEN BEGIN [] _ NutViewer.Message[NIL, eName, " is a system entity. You may not edit it."]; RETURN; END; newV _ NutViewer.ReplaceViewer[ e: e, eName: eName, d: d, seg: seg, parent: parent]; Nut.Edit[ e: e, eName: eName, d: d, seg: seg, newV: newV]; END; GetTopLevel: PUBLIC PROCEDURE [v: Viewer] RETURNS [ancestor: Viewer] = { FOR ancestor _ v, ancestor.parent UNTIL ancestor.parent=NIL DO ENDLOOP; }; 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˜Jšœ œœœ ˜+Jšœ œœœ)˜JJ˜J˜Jš4ÏbœœÏcZœŸZœœœœ,œ œ œœœŸœ›œœ#œŸ!œœœBœœ5œ<œ¡œŸ#œ5œ˜Ù J˜š Ðbnœœœœœœ˜Qš˜JšŸ>˜>Jšœœ˜ Jš œœœœœ˜GJšœŸ˜-Jšœœ˜Jšœ'˜'Jšœ<˜