<> <> <> <> <> <<(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, 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[], 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...