<> <> <> <> <> <<(Changed to catch WBError)>> <> 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, 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["\nWHITEBOARD "]]; file.Put[rope[DB.EntityInfo[el.first].name]]; DumpWBItems[file, el.first]; file.Put[rope["\nEND\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; 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]; 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]; WriteRope[file, name]; file.Put[rope[" "]]; WriteRope[file, label]; file.Put[rope[" "]]; WriteRope[file, IF type = NIL THEN "" ELSE Atom.GetPName[type]]; file.Put[rope[" "]]; WriteRope[file, iconName]; file.Put[rope[" "]]; WriteRope[file, argument]; 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...