ViewersSnapshotImpl.mesa; Written by S. McGregor
last edited by McGregor October 25, 1982 2:35 pm
Last Edited by: Maxwell, January 27, 1983 12:42 pm
Last Edited by: Pausch, July 18, 1983 4:46 pm
DIRECTORY
CedarSnapshot, -- using lots
InputFocus USING [EnableInput],
Menus USING [ClickProc],
MessageWindow USING [Append, Blink, Confirm],
SafeStorage USING [ReclaimCollectibleObjects],
ViewerClasses USING [Viewer],
ViewerOps USING [EnumerateViewers, EnumProc, FindViewer],
ViewersSnapshot,
WindowManager USING [UnWaitCursor, WaitCursor];
ViewersSnapshotImpl: CEDAR MONITOR
IMPORTS CedarSnapshot, InputFocus, MessageWindow, SafeStorage, ViewerOps, WindowManager
EXPORTS ViewersSnapshot
SHARES InputFocus =
BEGIN
working: BOOLFALSE;
Working: ENTRY PROC RETURNS [now: BOOL] = INLINE {now ← working; working ← TRUE};
Done: ENTRY PROC = INLINE {working ← FALSE};
Checkpoint: PUBLIC PROC RETURNS [outcome: CedarSnapshot.Outcome] =
BEGIN OPEN CedarSnapshot;
IF Working[] THEN RETURN [checkpointed];
WindowManager.WaitCursor[];
MessageWindow.Append["Trace and sweep of collectable storage...", TRUE];
[] ← SafeStorage.ReclaimCollectibleObjects[TRUE, TRUE]; -- t&s collection
MessageWindow.Append["Processing checkpoint file...", TRUE];
TRUSTED {outcome ← CedarSnapshot.Checkpoint[]};
MessageWindow.Append[SELECT outcome FROM
checkpointed => "Checkpoint created successfully.",
rolledBack => "State restored to previous checkpoint.",
insufficientDiskSpace => "Insufficient disk space to make checkpoint!",
transactionsInProgress => "Transaction in progress . . . checkpoint aborted.",
overwrittenBcd => "OVERWRITTEN BCDS! Strongly recommend you boot!",
potentiallyDangerousCodeLinks => "Warning: Checkpoint has potentially dangerous code links!",
ENDCASE => "Checkpoint or Rollback problem; see a system wizard!", TRUE];
IF outcome = overwrittenBcd THEN {
bootButton: ViewerClasses.Viewer;
MessageWindow.Blink[];
bootButton ← ViewerOps.FindViewer["Boot"];
IF bootButton # NIL THEN bootButton.class.notify[bootButton, LIST[$Mark, $Hit]];
MessageWindow.Blink[]};
InputFocus.EnableInput[];
WindowManager.UnWaitCursor[];
Done[];
END;
RollBack: PUBLIC PROC = BEGIN
TRUSTED {CedarSnapshot.RollBack[]}; -- no return unless rollback fails!
MessageWindow.Append["No previous Checkpoint to restore!"];
MessageWindow.Blink[];
END;
NothingWorthSaving: PROC RETURNS[BOOLEAN] =
BEGIN
dirty: BOOLEANFALSE;
CheckDirty: ViewerOps.EnumProc = {dirty ← v.newVersion OR v.newFile OR dirty};
ViewerOps.EnumerateViewers[CheckDirty];
IF dirty THEN {
MessageWindow.Blink[];
IF ~MessageWindow.Confirm[
"Confirm discard of edits ... "]
THEN {
MessageWindow.Append["action aborted."];
RETURN[FALSE]}};
RETURN[TRUE];
END;
MCheckpoint: PUBLIC Menus.ClickProc = {IF NothingWorthSaving[] THEN [] ← Checkpoint[]};
MRollBack: PUBLIC Menus.ClickProc = {IF NothingWorthSaving[] THEN RollBack[]};
END.