<> <> <> DIRECTORY Containers USING [ChildXBound, ChildYBound], Convert USING [RopeFromInt], Graph USING [Entity, EntityGroup, EntityGroupList, EntityList, GraphHandle, GraphProc, NestedEntities, NestedEntitiesList, ROPE, Text, Texts, Viewer], GraphPrivate USING [CallWithLock, GraphPlaceProc, RemoveEntity, RemoveText, ShowEntity, ShowText, UserEditAllowed], GraphUtil USING [ControllerViewerExits, HandleNotNil], Rope USING [Concat], TiogaOps USING [Break, InsertRope, LastChild, Lock, Nest, Ref, SelectPoint, SetLooks, SubtractLooks, Unlock, UnNest, ViewerDoc], TiogaButtons USING [CreateButton, CreateButtonFromNode, CreateViewer, TiogaButton, TiogaButtonProc], ViewerTools USING [SetContents]; GraphTable: CEDAR PROGRAM IMPORTS Containers, Convert, GraphPrivate, GraphUtil, Rope, TiogaOps, TiogaButtons, ViewerTools EXPORTS GraphPrivate = { OPEN Graph, GraphPrivate; GraphButtonData: TYPE = REF GraphButtonDataRec; GraphButtonDataRec: TYPE = RECORD[ handle: GraphHandle _ NIL, ref: REF ANY _ NIL ]; MakeTable: PUBLIC GraphPlaceProc = { <> IF GraphUtil.HandleNotNil[handle] THEN { OPEN handle; <> controller.table _ TiogaButtons.CreateViewer[ info: [ wx: sx, wy: sy, ww: 1000, wh: 1000, menu: NIL, parent: controller.viewer, scrollable: TRUE, border: FALSE, caption: FALSE ]]; Containers.ChildXBound[controller.viewer, controller.table]; Containers.ChildYBound[controller.viewer, controller.table]; [] _ TiogaButtons.CreateButton[viewer: controller.table, rope: ""]; TextsTable[handle]; FOR egl: EntityGroupList _ entityGroupList, egl.rest UNTIL egl = NIL DO NETable[handle, egl.first.ys, NIL]; ENDLOOP; }; }; -- MakeTable TextsTable: PROC [handle: GraphHandle] = { b: TiogaButtons.TiogaButton _ TiogaButtons.CreateButton[ viewer: handle.controller.table, rope: "Texts", looks: "lb"]; b _ TiogaButtons.CreateButton[ viewer: handle.controller.table, rope: ""]; handle.controller.textsParent _ b.endLoc.node; TiogaOps.SelectPoint[handle.controller.table, b.endLoc]; TiogaOps.Break[]; TiogaOps.Nest[]; FOR ts: Texts _ handle.allTexts, ts.rest UNTIL ts = NIL DO t: Text _ ts.first; -- error if nil. TiogaOps.InsertRope[ IF t.text = NIL THEN Convert.RopeFromInt[t.id] ELSE t.text]; b _ TiogaButtons.CreateButtonFromNode[ node: TiogaOps.LastChild[handle.controller.textsParent], start: , end: , proc: TextButtonProc, clientData: NEW[GraphButtonDataRec _ [handle, t]] ]; TiogaOps.SelectPoint[handle.controller.table, b.endLoc]; TiogaOps.Break[]; ENDLOOP; TiogaOps.UnNest[]; }; -- TextsTable <<>> EntityListTable: PROC [handle: GraphHandle, entityList: EntityList, parent: TiogaOps.Ref] = { button: TiogaButtons.TiogaButton; IF entityList # NIL THEN TiogaOps.Break[]; FOR el: EntityList _ entityList, el.rest UNTIL el = NIL DO entity: Entity _ el.first; -- error if nil. TiogaOps.InsertRope[ IF entity.name = NIL THEN Convert.RopeFromInt[entity.id] ELSE entity.name.Concat[entity.comment]]; button _ TiogaButtons.CreateButtonFromNode[ node: TiogaOps.LastChild[parent], start: , end: , proc: EntityButtonProc, clientData: NEW[GraphButtonDataRec _ [handle, entity]] ]; TiogaOps.SelectPoint[handle.controller.table, button.endLoc]; TiogaOps.Break[]; ENDLOOP; }; -- EntityListTable NETable: PROC [handle: GraphHandle, ne: NestedEntities, parent: TiogaOps.Ref _ NIL] = { IF ne # NIL THEN { topLevel: BOOL _ parent = NIL; look: ROPE _ IF topLevel THEN "lb" ELSE "b"; IF topLevel THEN parent _ TiogaOps.ViewerDoc[handle.controller.table]; <> TiogaOps.Break[]; -- one blank line before each NestedEntities TiogaOps.SetLooks[look, caret]; TiogaOps.InsertRope[ne.name.Concat[ne.comment]]; TiogaOps.SubtractLooks[look, caret]; ne.node _ TiogaOps.LastChild[parent]; -- ne.node is the (currently) last child of parent. [] _ TiogaButtons.CreateButtonFromNode[ node: ne.node, start: , end: , proc: NestedEntitiesButtonProc, clientData: NEW[GraphButtonDataRec _ [handle, ne]] ]; TiogaOps.SelectPoint[handle.controller.table, [ne.node, -1]]; TiogaOps.Break[]; TiogaOps.Nest[]; <> EntityListTable[handle, ne.entityList, ne.node]; FOR nel: NestedEntitiesList _ ne.children, nel.rest UNTIL nel = NIL DO NETable[handle, nel.first, ne.node]; ENDLOOP; TiogaOps.UnNest[]; }; }; -- NETable EntityGroupButtonProc: TiogaButtons.TiogaButtonProc = { -- noop for now <> <> <> <> <> <