-- WhiteboardToolImpl.mesa
-- last edit by
-- Maxwell, June 23, 1983 10:25 am
-- Willie-Sue, February 22, 1983 4:30 pm
-- Cattell, September 23, 1983 8:57 am
-- Donahue, August 2, 1983 4:35 pm
DIRECTORY
CommandTool USING[Run, DoCommand],
Commander USING[Handle, CommandObject],
DB USING
[Attribute, DeclareEntity, Domain, Entity, GetP, V2S],
IO USING[noInputStream],
MessageWindow USING[Append, Clear],
Nut USING [CreateProc],
PressPrinter USING[IsAPressFile],
Rope,
PrincOpsUtils USING[ IsBound],
ShowPress USING[CreateShowViewer],
SquirrelTool USING[squirrelOut],
TiogaMenuOps USING[ Open ],
ViewerClasses USING [Viewer],
ViewerOps USING [FindViewer, OpenIcon, PaintViewer, AddProp],
Whiteboard;
WhiteboardToolImpl: CEDAR PROGRAM
IMPORTS
CommandTool, DB, IO, MessageWindow, PressPrinter,
TiogaMenuOps, Rope, PrincOpsUtils, ShowPress, SquirrelTool, ViewerOps, Whiteboard
EXPORTS Whiteboard =
BEGIN
OPEN DB, Whiteboard;
ROPE: TYPE = Rope.ROPE;
Viewer: TYPE = ViewerClasses.Viewer;
-- *********************** creating entities **************************
CreateTextViewer: PUBLIC Nut.CreateProc =
BEGIN
IF PressPrinter.IsAPressFile[eName] THEN
TRUSTED{ IF NOT PrincOpsUtils.IsBound[link: ShowPress.CreateShowViewer] THEN
{ MessageWindow.Append["Running ShowPressPackage", TRUE];
IF CommandTool.Run["ShowPressPackage"].error
THEN
{ MessageWindow.Append["Can't load ShowPress", TRUE]; RETURN[NIL] }
ELSE MessageWindow.Append["Done.", TRUE] };
MessageWindow.Append[message: Rope.Cat["Reading ", eName], clearFirst: TRUE];
v ← ShowPress.CreateShowViewer[eName].parent;
v.icon ← document;
ViewerOps.AddProp[ v, $IconLabel, Whiteboard.ShortName[eName] ];
MessageWindow.Append[message: "Done.", clearFirst: TRUE];
RETURN[v] };
v ← ViewerOps.FindViewer[eName];
IF v = NIL OR v.destroyed THEN {
MessageWindow.Append[message: Rope.Cat["Reading ", eName], clearFirst: TRUE];
v ← TiogaMenuOps.Open[fileName: eName];
MessageWindow.Clear[] }
ELSE Open[v];
RETURN[v];
END;
CreateToolViewer: PUBLIC Nut.CreateProc =
BEGIN
tool: Entity;
instructions: ROPE;
v ← ViewerOps.FindViewer[eName];
IF v # NIL THEN { Open[v]; RETURN[NIL] };
tool ← DeclareEntity[d: Whiteboard.ToolViewer, name: eName, version: OldOnly];
IF tool = NIL THEN RETURN[NIL];
instructions ← V2S[GetP[tool, Whiteboard.instructions]];
IF Rope.Equal[instructions, ""] THEN RETURN;
{ cmdHandle: Commander.Handle = NEW[Commander.CommandObject ← []];
cmdHandle.err ← cmdHandle.out ← SquirrelTool.squirrelOut;
cmdHandle.in ← IO.noInputStream;
[] ← CommandTool.DoCommand[Rope.Concat[instructions, "\n"], cmdHandle] };
-- try to find a viewer that might have been created
v ← ViewerOps.FindViewer[eName];
Open[v];
RETURN[v]
END;
ExtractName: PUBLIC PROCEDURE[name: ROPE] RETURNS[ROPE] =
BEGIN
pos: INTEGER;
pos ← Rope.Find[name, ": "];
IF pos < 0 THEN pos ← 0 ELSE pos ← pos + 2;
RETURN[Rope.Substr[name, pos, Rope.Length[name]-pos-11]]; -- remove the " (Squirrel)" too
END;
Open: PROCEDURE[viewer: Viewer] =
BEGIN
IF viewer#NIL THEN
IF viewer.iconic THEN ViewerOps.OpenIcon[viewer]
ELSE ViewerOps.PaintViewer[viewer, all];
END;
END.
Change Log
Cattell August 11, 1982 12:23 pm: Removed StartTrap call, want to selectively start up whiteboards. Also make GetIconInfo recover gracefully if icon relation has been deleted or not initialized.
Cattell October 11, 1982 9:29 pm: GetIcon must catch MultipleMatch on GetEntityByName, because there may be more than one sub-type of the domain; in this case just use nut icon.