SModelToolImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
last edited by Levin on December 16, 1983 2:30 pm
Doug Wyatt, March 6, 1985 12:56:57 pm PST
Spreitzer, May 20, 1985 5:52:12 pm PDT
DIRECTORY
Buttons USING [ButtonProc],
Containers USING [ChildXBound, Create],
DFOperations USING [SModelAction],
DFOperationsQueue USING [Enqueue, RequestRecord],
DFToolInternal USING [AddOpToTable, Choice, CreateSelector, DFTool, EnsureDFName, MakeCenteredLabel, offScreenY, OpDefiner, Operation, OpsInteraction, OpSpecificProc, OptionSelector, SelectOption, ViewerToRopeList],
FileViewerOps USING [WaitUntilSaved],
Rope USING [Concat, ROPE],
ViewerClasses USING [Viewer],
ViewerOps USING [MoveViewer],
ViewerTools USING [GetContents];
SModelToolImpl: CEDAR PROGRAM
IMPORTS Containers, DFOperationsQueue, DFToolInternal, FileViewerOps, Rope, ViewerOps, ViewerTools
= BEGIN OPEN
Ops: DFOperations,
OpsQ: DFOperationsQueue,
Tool: DFToolInternal;
ROPE: TYPE = Rope.ROPE;
-- ---- ---- ---- ---- ---- ---- ----
SModel-specific Code
-- ---- ---- ---- ---- ---- ---- ----
SModelData: TYPE = RECORD [
action: Ops.SModelAction ← [],
checkOptionSelector: REF Tool.OptionSelector ← NIL,
storeOptionSelector: REF Tool.OptionSelector ← NIL
];
SModelSpecific: Tool.OpSpecificProc = {
SELECT action FROM
$createOptions => {
op: Tool.Operation = NARROW[param];
tool: Tool.DFTool = op.tool;
x: INTEGER;
data: REF SModelData = NEW[SModelData ← []];
initialChoice: Tool.Choice;
op.options ← data;
op.optionsContainer ← Containers.Create[info: [
wx: 0, wy: Tool.offScreenY,
ww: 9999, -- arbitrary; Containers.ChildXBound overrides
wh: 0,
parent: tool.inner,
border: FALSE,
scrollable: FALSE
]];
Containers.ChildXBound[tool.inner, op.optionsContainer];
Tool.MakeCenteredLabel[op, op.definer.opAlias.Concat[" Options"]];
[data.checkOptionSelector, initialChoice, x] ← Tool.CreateSelector[
name: "Check existence on server", proc: SelectSModelCheckOption, clientData: data,
choices: LIST[
["yes", NEW[BOOLTRUE]],
["no", NEW[BOOLFALSE]]
],
op: op
];
data.action.remoteCheck ← NARROW[initialChoice.value, REF BOOL]^;
[data.storeOptionSelector, initialChoice, x] ← Tool.CreateSelector[
name: "Store changed files", proc: SelectSModelStoreOption, clientData: data,
choices: LIST[
["yes", NEW[BOOLTRUE]],
["no", NEW[BOOLFALSE]]
],
op: op,
x: x + tool.parameters.entryHSpace
];
data.action.storeChanged ← NARROW[initialChoice.value, REF BOOL]^;
op.height ← op.height + tool.parameters.entryHeight + tool.parameters.entryVSpace;
ViewerOps.MoveViewer[
viewer: op.optionsContainer,
x: op.optionsContainer.wx, y: op.optionsContainer.wy,
w: op.optionsContainer.ww, h: op.height,
paint: FALSE
];
};
$doOp => {
op: Tool.Operation = NARROW[param];
tool: Tool.DFTool = op.tool;
wDir: ROPE = ViewerTools.GetContents[tool.wDir];
data: REF SModelData = NARROW[op.options];
FOR list: LIST OF ROPE ← Tool.ViewerToRopeList[tool.dfNames], list.rest UNTIL list = NIL DO
short, long: ROPE;
[short, long] ← Tool.EnsureDFName[list.first, wDir];
FileViewerOps.WaitUntilSaved[long, tool.feedback];
tool.opsQueue.Enqueue[NEW[OpsQ.RequestRecord ← [
dfFile: short,
wDir: wDir,
interact: Tool.OpsInteraction,
log: tool.log,
clientData: op,
opSpecific: sModel[action: data.action]
]]];
ENDLOOP;
};
ENDCASE;
};
SelectSModelCheckOption: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure atomicity with $doOp logic.
data: REF SModelData = NARROW[clientData];
data.action.remoteCheck ← NARROW[Tool.SelectOption[data.checkOptionSelector].value, REF BOOL]^;
};
SelectSModelStoreOption: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure atomicity with $doOp logic.
data: REF SModelData = NARROW[clientData];
data.action.storeChanged ← NARROW[Tool.SelectOption[data.storeOptionSelector].value, REF BOOL]^;
};
-- ---- ---- ---- ---- ---- ---- ----
Initialization
-- ---- ---- ---- ---- ---- ---- ----
Tool.AddOpToTable[
NEW[Tool.OpDefiner ← ["SModel", $sModel, $individual, SModelSpecific]]];
END.