SModelToolImpl.mesa
last edited by Levin on December 16, 1983 2:30 pm
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],
Rope USING [Concat, ROPE],
ViewerClasses USING [Viewer],
ViewerOps USING [MoveViewer],
ViewerTools USING [GetContents];
SModelToolImpl: CEDAR PROGRAM
IMPORTS Containers, DFOperationsQueue, DFToolInternal, 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
tool.opsQueue.Enqueue[NEW[OpsQ.RequestRecord ← [
dfFile: Tool.EnsureDFName[list.first],
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.