DIRECTORY Atom, Commander USING [CommandProc, Register], Convert USING [RopeFromRope], DB, FS USING [StreamOpen], IO, Rope, ViewerTools, WhiteboardDB USING[Dump, WBError], WhiteboardDBPrivate; WhiteboardDump: CEDAR PROGRAM IMPORTS Atom, Commander, Convert, DB, FS, IO, Rope, WhiteboardDBPrivate, WhiteboardDB = BEGIN OPEN IO, Rope, WhiteboardDBPrivate; DoDump: Commander.CommandProc = BEGIN ENABLE WhiteboardDB.WBError => { SELECT reason FROM $ServerDown => {msg _ "Dump Failed -- server unavailable; retry later"; CONTINUE}; $TransactionAbort => {msg _ "Dump Failed -- transaction aborted; retry later"; CONTINUE}; ENDCASE => REJECT }; h: IO.STREAM = IO.RIS[cmd.commandLine]; [] _ h.SkipWhitespace[]; IF h.EndOf THEN [] _ WhiteboardDB.Dump["Whiteboard.dump"] ELSE [] _ WhiteboardDB.Dump[h.GetLineRope[]]; -- make sure to go through the monitor END; DumpToFile: PUBLIC PROC[fileName: ROPE] = BEGIN file: STREAM; IF fileName = NIL THEN fileName _ "Whiteboard.dump"; file _ OpenFile[fileName]; DumpWBs[file]; file.Close[]; END; DumpWBs: PROC[file: STREAM] = BEGIN FOR el: LIST OF Whiteboard _ Enumerate[NIL], el.rest UNTIL el = NIL DO file.Put[rope["(WHITEBOARD "]]; file.Put[rope[DB.NameOf[el.first]]]; DumpWBItems[file, el.first]; file.Put[rope[")\n\n"]]; ENDLOOP; END; DumpWBItems: PROC[file: STREAM, wb: WhiteboardDBPrivate.Whiteboard] = BEGIN children: ChildSet = Children[wb]; FOR child: WBItem _ NextChild[children], NextChild[children] UNTIL child = NIL DO IF TypeOf[child] = note THEN { file.Put[rope[" "]]; DumpNote[file, child] } ELSE { file.Put[rope[" "]]; DumpIcon[file, child] }; ENDLOOP; file.Put[rope[")"]]; END; DumpNote: PROC[file: STREAM, note: WBNote] = BEGIN x, y, w, h: INT; text: ViewerTools.TiogaContents = GetContents[note]; file.Put[rope["\n (NOTE "]]; [x, y] _ Position[note]; [w, h] _ Size[note]; WriteCoords[file, x, y, w, h]; WriteRope[file, text.contents]; file.Put[rope[" "]]; WriteRope[file, text.formatting]; file.Put[rope[" )"]]; END; DumpIcon: PROC[file: STREAM, icon: WBIcon] = BEGIN x, y: INTEGER _ 0; name, label, iconName, argument: ROPE; type: ATOM; file.Put[rope["\n (ICON "]]; [x, y] _ Position[icon]; file.Put[int[x]]; file.Put[rope[" "]]; file.Put[int[y]]; file.Put[rope[" "]]; [label, iconName] _ GetDisplayProps[icon]; argument _ GetToolArgument[icon]; [name, type] _ GetIconProps[icon]; IF Rope.Equal[name, ""] THEN file.Put[rope["-"]] ELSE file.Put[rope[name]]; file.Put[rope["|"]]; IF Rope.Equal[label, ""] THEN file.Put[rope["-"]] ELSE file.Put[rope[label]]; file.Put[rope["|"]]; IF type = NIL THEN file.Put[rope["-"]] ELSE file.Put[rope[Atom.GetPName[type]]]; file.Put[rope["|"]]; IF Rope.Equal[iconName, ""] THEN file.Put[rope["-"]] ELSE file.Put[rope[iconName]]; file.Put[rope["|"]]; IF Rope.Equal[argument, ""] THEN file.Put[rope["-"]] ELSE file.Put[rope[argument]]; file.Put[rope[")"]]; END; WriteRope: PROC[file: STREAM, r: ROPE] = BEGIN file.Put[rope[" "]]; file.Put[rope[Convert.RopeFromRope[r]]]; END; WriteCoords: PROC[file: STREAM, x, y, w, h: INTEGER] = BEGIN file.Put[int[x]]; file.Put[rope[" "]]; file.Put[int[y]]; file.Put[rope[" "]]; file.Put[int[w]]; file.Put[rope[" "]]; file.Put[int[h]]; END; OpenFile: PROC[fileName: ROPE] RETURNS [file: STREAM] = BEGIN IF fileName = NIL THEN RETURN; file _ FS.StreamOpen[fileName: fileName, accessOptions: $create] END; Commander.Register[key: "WBDump", proc: DoDump, doc: "\nDumps current whiteboard segment to named file\n (File defaults to Whiteboard.dump)"] END... vFile: WhiteboardDump.mesa Copyright (C) 1984 by Xerox Corporation. All rights reserved. For dumping of whiteboard databases. (Companion to WhiteboardLoadImpl.mesa.) Last edited by: Jennifer Widom, August 24, 1984 10:36:43 pm PDT Last edited by: Donahue, May 28, 1985 5:10:12 pm PDT (Changed to catch WBError) Last Edited by: Winkler, December 18, 1984 11:05:46 am PST Êb˜Jšœ™Jšœ=™=JšœL™LJšœ?™?J™4J™J™:J˜šÏk ˜ J˜Jšœ œ˜(J˜Jšœ˜Jšœœ˜Jšœ˜J˜J˜ Jšœ œ˜"Jšœ˜J˜—šœœ˜š˜Jšœœœœ+˜OJ˜——Jšœœœ˜)J˜šœ˜š˜šœ˜ Jšœ˜JšœHœ˜RJšœOœ˜YJšœœ˜—Jš œœœœœ˜'J˜šœ œ*˜9Jšœ*Ïc&˜T—Jšœ˜J˜——šÏn œ œ œ˜)š˜Jšœœ˜ Jšœ œœ˜4J˜J˜J˜ Jšœ˜—J˜—šŸœœœ˜š˜š œœœœ œœ˜FJ˜Jšœœ˜$J˜J˜Jšœ˜—šœ˜J˜———šŸ œœœ'˜Eš˜Jšœ"˜"šœ:œ œ˜Qšœœ˜J˜/—Jšœ0˜4Jšœ˜—J˜šœ˜J˜———šŸœœœ˜,š˜Jšœ˜J˜4J˜J˜J˜J˜Jšœ˜J˜Jšœ!˜!J˜Jšœ˜J˜——šŸœœœ˜,š˜Jšœœ˜Jšœ!œ˜&Jšœœ˜ J˜J˜J˜J˜J˜J˜Jšœ*˜*J˜!J˜"Jšœœœ˜KJ˜Jšœœœ˜MJ˜Jšœ œœ%˜PJ˜Jšœœœ˜SJ˜Jšœœœ˜SJ˜Jšœ˜J˜——šŸ œœœœ˜(š˜J˜J˜(Jšœ˜J˜——šŸ œœœœ˜6š˜J˜J˜J˜J˜J˜J˜J˜Jšœ˜J˜——š Ÿœœ œœœ˜7š˜Jšœ œœœ˜Jšœœ7˜@Jšœ˜J˜——˜/J˜]J˜—Jšœ˜J˜—…— ¤|