ResetSchema:
PUBLIC
PROC[] = {
IF DB.GetSegmentInfo[$Whiteboard].trans # NIL THEN RETURN;
SetUpSegment[WBSegment];
IF NOT DB.Null[Note] THEN RETURN;
Note ← DB.DeclareDomain["Note", $Whiteboard];
Icon ← DB.DeclareDomain["WBIcon", $Whiteboard];
WBItem ← DB.DeclareDomain["WBItems", $Whiteboard];
DB.DeclareSubType[of: WBItem, is: Note];
DB.DeclareSubType[of: WBItem, is: Icon];
WBEntity ← DB.DeclareDomain["Whiteboard", $Whiteboard];
contents ← DB.DeclareProperty["contents", Note, DB.RopeType, $Whiteboard];
format ← DB.DeclareProperty["format", Note, DB.RopeType, $Whiteboard];
iconName ← DB.DeclareProperty["entity", Icon, DB.RopeType, $Whiteboard];
iconLabel ← DB.DeclareProperty["label", Icon, DB.RopeType, $Whiteboard];
iconType ← DB.DeclareProperty["type", Icon, DB.RopeType, $Whiteboard];
iconIcon ← DB.DeclareProperty["icon", Icon, DB.RopeType, $Whiteboard];
iconArgument ← DB.DeclareProperty["argument", Icon, DB.RopeType, $Whiteboard];
for whiteboards
versionProp ← DB.DeclareProperty["version", WBEntity, DB.IntType, $Whiteboard];
gridProp ← DB.DeclareProperty["gridSize", WBEntity, DB.IntType, $Whiteboard];
container ← DB.DeclareRelation["container", $Whiteboard];
containerIs ← DB.DeclareAttribute[container, "is", WBEntity];
containerOf ← DB.DeclareAttribute[container, "of", WBItem];
containerX ← DB.DeclareAttribute[container, "x", DB.IntType];
containerY ← DB.DeclareAttribute[container, "y", DB.IntType];
containerW ← DB.DeclareAttribute[container, "w", DB.IntType];
containerH ← DB.DeclareAttribute[container, "h", DB.IntType];
[] ← DB.DeclareIndex[container, LIST[containerIs]] };
SetUpSegment:
PROC [segmentFile:
ROPE] ~ {
segment: ATOM = $Whiteboard;
segmentNumber: NAT = 310B;
readOnly: BOOL ← FALSE;
DB.Initialize[nCachePages: 256];
try opening the segment for writing
DB.DeclareSegment[segmentFile, segment, segmentNumber, FALSE];
DB.OpenTransaction[$Whiteboard !
DB.Error =>
TRUSTED {
IF code = ProtectionViolation THEN { readOnly ← TRUE; CONTINUE } ELSE REJECT } ];
IF readOnly
THEN {
attempt to open for writing failed; open it for reading only
DB.CloseTransaction[DB.GetSegmentInfo[segment].trans];
DB.DeclareSegment[segmentFile, segment, segmentNumber, TRUE, FALSE];
DB.OpenTransaction[segment] };
};