BringOverToolImpl.mesa
last edited by Levin on December 16, 1983 2:30 pm
DIRECTORY
Buttons USING [ButtonProc, Create],
Containers USING [ChildXBound, Create],
DFOperations USING [
BringOverAction, BringOverFilter, BringOverFilterA, BringOverFilterB, BringOverFilterC, InteractionProc],
DFOperationsQueue USING [Enqueue, RequestRecord],
DFToolInternal USING [
AddOpToTable, Choice, CreateSelector, DFTool, EnsureDFName, MakeCenteredLabel, offScreenY, OpDefiner, Operation, OpsInteraction, OpSpecificProc, OptionSelector, Parameters, SelectOption, ViewerToRopeList],
Rope USING [Concat, ROPE],
ViewerClasses USING [Viewer],
ViewerOps USING [MoveViewer],
ViewerTools USING [GetContents, MakeNewTextViewer, SetContents, SetSelection];
BringOverToolImpl: CEDAR PROGRAM
IMPORTS
Buttons, Containers, DFOperationsQueue, DFToolInternal, Rope, ViewerOps, ViewerTools =
BEGIN
OPEN Ops: DFOperations, OpsQ: DFOperationsQueue, Tool: DFToolInternal;
ROPE: TYPE = Rope.ROPE;
---- ---- ---- ---- ---- ---- ---- ----
BringOver-specific Code
---- ---- ---- ---- ---- ---- ---- ----
BringOverData: TYPE = RECORD [
filter: Ops.BringOverFilter ← [],
filterASelector: REF Tool.OptionSelector ← NIL,
filterBSelector: REF Tool.OptionSelector ← NIL,
filterCSelector: REF Tool.OptionSelector ← NIL,
action: Ops.BringOverAction ← enter,
actionSelector: REF Tool.OptionSelector ← NIL,
usingList: ViewerClasses.Viewer ← NIL -- undigested TEXT for filter.list
];
selectedFilesLines: NAT = 2;
BringOverSpecific: Tool.OpSpecificProc = {
SELECT action FROM
$createOptions => {
op: Tool.Operation = NARROW[param];
tool: Tool.DFTool = op.tool;
parameters: Tool.Parameters = tool.parameters;
prev: ViewerClasses.Viewer;
x: INTEGER;
data: REF BringOverData = NEW[BringOverData ← []];
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.filterASelector, initialChoice, x] ← Tool.CreateSelector[
name: "Origin", proc: SelectBringOverFilterA, clientData: data,
choices: LIST[
["all", NEW[Ops.BringOverFilterA ← $all]],
["derived", NEW[Ops.BringOverFilterA ← $derived]],
["source", NEW[Ops.BringOverFilterA ← $source]]
],
op: op
];
data.filter.filterA ← NARROW[initialChoice.value, REF Ops.BringOverFilterA]^;
[data.filterBSelector, initialChoice, x] ← Tool.CreateSelector[
name: "Access", proc: SelectBringOverFilterB, clientData: data,
choices: LIST[
["all", NEW[Ops.BringOverFilterB ← $all]],
["private", NEW[Ops.BringOverFilterB ← $private]],
["public", NEW[Ops.BringOverFilterB ← $public]]
],
op: op,
x: x + parameters.entryHSpace
];
data.filter.filterB ← NARROW[initialChoice.value, REF Ops.BringOverFilterB]^;
[data.filterCSelector, initialChoice, x] ← Tool.CreateSelector[
name: "Reference", proc: SelectBringOverFilterC, clientData: data,
choices: LIST[
["all", NEW[Ops.BringOverFilterC ← $all]],
["imported", NEW[Ops.BringOverFilterC ← $imported]],
["defining", NEW[Ops.BringOverFilterC ← $defining]]
],
op: op,
x: x + parameters.entryHSpace
];
data.filter.filterC ← NARROW[initialChoice.value, REF Ops.BringOverFilterC]^;
op.height ← op.height + parameters.entryHeight + parameters.entryVSpace;
data.usingList ← ViewerTools.MakeNewTextViewer[info: [
wx: 0, -- we'll move it soon
wy: op.height,
ww: 9999, -- arbitrary; Containers.ChildXBound overrides
wh: selectedFilesLines*tool.parameters.entryHeight,
data: NIL,
parent: op.optionsContainer,
scrollable: TRUE,
border: FALSE
]];
prev ← Buttons.Create[
info: [name: "Selected files:",
wx: parameters.entryHSpace,
wy: op.height,
wh: tool.parameters.entryHeight,
parent: op.optionsContainer, 
border: FALSE
],
proc: SelectUsingList,
fork: FALSE,
clientData: data.usingList,
font: parameters.font
];
ViewerOps.MoveViewer[
viewer: data.usingList,
x: prev.wx + prev.ww + parameters.entryHSpace, y: data.usingList.wy,
w: data.usingList.ww, h: data.usingList.wh,
paint: FALSE
];
Containers.ChildXBound[op.optionsContainer, data.usingList];
op.height ← op.height + selectedFilesLines*tool.parameters.entryHeight + parameters.entryVSpace;
[data.actionSelector, initialChoice, x] ← Tool.CreateSelector[
name: "Action for each file", proc: SelectBringOverAction, clientData: data,
choices: LIST[
["enter in directory as attachment", NEW[Ops.BringOverAction ← $enter]],
["check remote server", NEW[Ops.BringOverAction ← $check]],
["check remote server, then enter in directory",
NEW[Ops.BringOverAction ← $checkAndEnter]],
["enter in directory as attachment and fetch", NEW[Ops.BringOverAction ← $fetch]]
],
op: op
];
data.action ← NARROW[initialChoice.value, REF Ops.BringOverAction]^;
op.height ← op.height + tool.parameters.entryHeight + 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 BringOverData = NARROW[op.options];
data.filter.list ← Tool.ViewerToRopeList[data.usingList];
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: bringOver[filter: data.filter, action: data.action]
]]];
ENDLOOP;
};
ENDCASE;
};
SelectBringOverFilterA: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure atomicity with $doOp logic.
data: REF BringOverData = NARROW[clientData];
data.filter.filterA ←
NARROW[Tool.SelectOption[data.filterASelector].value, REF Ops.BringOverFilterA]^;
};
SelectBringOverFilterB: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure atomicity with $doOp logic.
data: REF BringOverData = NARROW[clientData];
data.filter.filterB ←
NARROW[Tool.SelectOption[data.filterBSelector].value, REF Ops.BringOverFilterB]^;
};
SelectBringOverFilterC: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure atomicity with $doOp logic.
data: REF BringOverData = NARROW[clientData];
data.filter.filterC ←
NARROW[Tool.SelectOption[data.filterCSelector].value, REF Ops.BringOverFilterC]^;
};
SelectBringOverAction: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure atomicity with $doOp logic.
data: REF BringOverData = NARROW[clientData];
data.action ← NARROW[Tool.SelectOption[data.actionSelector].value, REF Ops.BringOverAction]^;
};
SelectUsingList: Buttons.ButtonProc = {
Note: runs synchronously with Viewers' notifier to ensure than manipulation of the using list is atomic.
usingList: ViewerClasses.Viewer = NARROW[clientData];
IF mouseButton = blue THEN ViewerTools.SetContents[usingList, NIL];
ViewerTools.SetSelection[usingList, NIL];
};
---- ---- ---- ---- ---- ---- ---- ----
Initialization
---- ---- ---- ---- ---- ---- ---- ----
Tool.AddOpToTable[
NEW[Tool.OpDefiner ← ["BringOver", $bringOver, $individual, BringOverSpecific]]];
END.