CDBringoverCmd.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Pradeep Sindhu February 10, 1986 7:13:45 pm PST
Louis Monier February 7, 1986 7:45:03 pm PST
Bertrand Serlet February 11, 1986 0:36:01 am PST
DIRECTORY
CD, CDDirectory, CDIO, CDMenus, CDProperties, CDRemote, CDSequencer, PW, Rope, TerminalIO;
CDBringoverCmd: CEDAR PROGRAM
IMPORTS CDDirectory, CDIO, CDMenus, CDProperties, CDRemote, PW, Rope, TerminalIO
= BEGIN
ROPE: TYPE = Rope.ROPE;
libraryProp: ATOMPW.RegisterProp[$CDBringoverLibraryName, TRUE];
This property hangs on an object. Its value is the name of the library (.dale file).
Public functions
Bringover: PROC [comm: CDSequencer.Command] = {
libFileName: ROPE ← TerminalIO.RequestRope["Library Name: "];
lib: CD.Design ← CDIO.ReadDesign[libFileName];
designName: ROPE ← lib.name;
ForEachLibOb: CDDirectory.EachEntryAction = { -- ob from lib
found: BOOL;
targetOb: CD.Object;
[found, targetOb] ← CDDirectory.Fetch[comm.design, name];
IF ~found
THEN {
copyOfLibObject: CD.Object ← CDRemote.Get[comm.design, designName, name];
PW.AppendProps[copyOfLibObject, ob];
CDProperties.PutPropOnObject[copyOfLibObject, libraryProp, libFileName];
TerminalIO.WriteRopes["Adding ", name, "\n"];
}
ELSE {
prop: ROPENARROW [CDProperties.GetPropFromObject[targetOb, libraryProp]];
IF prop=NIL THEN RETURN; -- ob does not carry the prop
IF Rope.Equal[libFileName, prop, FALSE] OR TerminalIO.Confirm["Replace object?", Rope.Cat[name, " not from same library"]]
THEN {
copyOfLibObject: CD.Object ← CDRemote.Get[comm.design, designName, name];
PW.AppendProps[copyOfLibObject, ob];
CDProperties.PutPropOnObject[copyOfLibObject, libraryProp, libFileName];
CDDirectory.ReplaceObject[comm.design, targetOb, copyOfLibObject];
IF ~CDDirectory.Remove[comm.design, name, targetOb] THEN ERROR;
IF ~CDDirectory.Rename[comm.design, copyOfLibObject, name, FALSE] THEN ERROR;
TerminalIO.WriteRopes["Replacing ", name, "\n"];
};
};
};
IF lib=NIL THEN ERROR; -- can't find the file, turkey
[] ← CDDirectory.Enumerate[lib, ForEachLibOb];
TerminalIO.WriteRope["Done\n"];
};
Initialization
CDMenus.ImplementEntryCommand[menu: $IOMenu, entry: "Bringover", p: Bringover, key: $SelectGroup, queue: doQueueAndMark];
END.