DIRECTORY Buttons USING [ButtonProc, Create], Containers USING [ChildXBound, Create], DFOperations USING [ BringOver, BringOverAction, BringOverFilter, BringOverFilterA, BringOverFilterB, BringOverFilterC, InteractionProc, SModel, SModelAction], DFToolInternal USING [ boldFont, Choice, DFTool, entryHeight, entryHSpace, entryVSpace, font, offScreenY, OpDefiner, Operation, OpsInteraction, OpSpecificProc, opTable, OptionSelector, OuterContainerWidth], IO USING [card, EndOfStream, GetTokenRope, IDProc, PutFR, PutRope, RIS, rope, STREAM], Labels USING [Create, Destroy, Label], MBQueue USING [CreateButton], Rope USING [Concat, Equal, Find, Length, ROPE], UserProfile USING [Token], VFonts USING [StringWidth], ViewerClasses USING [Viewer], ViewerOps USING [MoveViewer], ViewerTools USING [GetContents, MakeNewTextViewer, SetContents, SetSelection]; IndividualOpsImpl: CEDAR PROGRAM IMPORTS Buttons, Containers, DFOperations, DFToolInternal, IO, Labels, MBQueue, Rope, UserProfile, VFonts, ViewerOps, ViewerTools EXPORTS DFToolInternal = BEGIN OPEN Ops: DFOperations, Tool: DFToolInternal; ROPE: TYPE = Rope.ROPE; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 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; selector: REF Tool.OptionSelector; prev: ViewerClasses.Viewer; data: REF BringOverData = NEW[BringOverData _ []]; 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]; MakeCenteredLabel[op, op.definer.opAlias.Concat[" Options"]]; prev _ tool.q.CreateButton[ info: [name: "Origin:", wx: Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectBringOverFilterA, clientData: data, font: Tool.font ]; selector _ data.filterASelector _ NEW[Tool.OptionSelector _ [choices: LIST[ ["all", NEW[Ops.BringOverFilterA _ all]], ["derived", NEW[Ops.BringOverFilterA _ derived]], ["source", NEW[Ops.BringOverFilterA _ source]] ]]]; prev _ selector.displayer _ Labels.Create[ info: [name: selector.choices.first.name, wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, ww: LabelWidthForChoices[tool, selector.choices], parent: op.optionsContainer, border: FALSE ], font: Tool.font ]; prev _ tool.q.CreateButton[ info: [name: "Access:", wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectBringOverFilterB, clientData: data, font: Tool.font ]; selector _ data.filterBSelector _ NEW[Tool.OptionSelector _ [choices: LIST[ ["all", NEW[Ops.BringOverFilterB _ all]], ["private", NEW[Ops.BringOverFilterB _ private]], ["public", NEW[Ops.BringOverFilterB _ public]] ]]]; prev _ selector.displayer _ Labels.Create[ info: [name: selector.choices.first.name, wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, ww: LabelWidthForChoices[tool, selector.choices], parent: op.optionsContainer, border: FALSE ], font: Tool.font ]; prev _ tool.q.CreateButton[ info: [name: "Reference:", wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectBringOverFilterC, clientData: data, font: Tool.font ]; selector _ data.filterCSelector _ NEW[Tool.OptionSelector _ [choices: LIST[ ["all", NEW[Ops.BringOverFilterC _ all]], ["imported", NEW[Ops.BringOverFilterC _ imported]], ["defining", NEW[Ops.BringOverFilterC _ defining]] ]]]; prev _ selector.displayer _ Labels.Create[ info: [name: selector.choices.first.name, wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, ww: LabelWidthForChoices[tool, selector.choices], parent: op.optionsContainer, border: FALSE ], font: Tool.font ]; op.height _ op.height + Tool.entryHeight + Tool.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.entryHeight, data: NIL, parent: op.optionsContainer, scrollable: TRUE, border: FALSE ]]; prev _ Buttons.Create[ info: [name: "Selected files:", wx: Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectUsingList, fork: FALSE, clientData: data.usingList, font: Tool.font ]; ViewerOps.MoveViewer[ viewer: data.usingList, x: prev.wx + prev.ww + Tool.entryHSpace, y: data.usingList.wy, w: data.usingList.ww, h: data.usingList.wh ]; Containers.ChildXBound[op.optionsContainer, data.usingList]; op.height _ op.height + selectedFilesLines*Tool.entryHeight + Tool.entryVSpace; prev _ tool.q.CreateButton[ info: [name: "Action for each file:", wx: Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectBringOverAction, clientData: data, font: Tool.font ]; selector _ data.actionSelector _ NEW[Tool.OptionSelector _ [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 and fetch", NEW[Ops.BringOverAction _ fetch]] ]]]; prev _ selector.displayer _ Labels.Create[ info: [name: selector.choices.first.name, wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, ww: LabelWidthForChoices[tool, selector.choices], parent: op.optionsContainer, border: FALSE ], font: Tool.font ]; op.height _ op.height + Tool.entryHeight + Tool.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; Interact: Ops.InteractionProc = { IF ~tool.abortRequested THEN response _ Tool.OpsInteraction[tool, interaction]; IF tool.abortRequested THEN { abort _ TRUE; abortMessageForLog _ "(user generated)"; tool.abortRequested _ FALSE; }; }; data: REF BringOverData = NARROW[op.options]; dfNames: IO.STREAM = IO.RIS[ViewerTools.GetContents[tool.dfNames]]; filter: Ops.BringOverFilter _ data.filter; action: Ops.BringOverAction = data.action; usingList: IO.STREAM = IO.RIS[ViewerTools.GetContents[data.usingList]]; last: LIST OF ROPE _ NIL; filter.list _ NIL; DO name: ROPE = usingList.GetTokenRope[IO.IDProc ! IO.EndOfStream => EXIT].token; nameL: LIST OF ROPE; nameL _ CONS[name, NIL]; IF last = NIL THEN filter.list _ nameL ELSE last.rest _ nameL; last _ nameL; ENDLOOP; DO errors, warnings, filesActedUpon: INT; dfName: ROPE = DFToDo[dfNames]; IF dfName.Length = 0 THEN EXIT; [errors: errors, warnings: warnings, filesActedUpon: filesActedUpon] _ Ops.BringOver[ dfFile: dfName, filter: filter, action: action, interact: Interact, log: tool.log ]; tool.feedback.PutRope[MakeOutcomeRope[errors, warnings, filesActedUpon]]; ENDLOOP; }; ENDCASE; }; SelectBringOverFilterA: Buttons.ButtonProc = { data: REF BringOverData = NARROW[clientData]; data.filter.filterA _ NARROW[SelectOption[data.filterASelector].value, REF Ops.BringOverFilterA]^; }; SelectBringOverFilterB: Buttons.ButtonProc = { data: REF BringOverData = NARROW[clientData]; data.filter.filterB _ NARROW[SelectOption[data.filterBSelector].value, REF Ops.BringOverFilterB]^; }; SelectBringOverFilterC: Buttons.ButtonProc = { data: REF BringOverData = NARROW[clientData]; data.filter.filterC _ NARROW[SelectOption[data.filterCSelector].value, REF Ops.BringOverFilterC]^; }; SelectBringOverAction: Buttons.ButtonProc = { data: REF BringOverData = NARROW[clientData]; data.action _ NARROW[SelectOption[data.actionSelector].value, REF Ops.BringOverAction]^; }; SelectUsingList: Buttons.ButtonProc = { usingList: ViewerClasses.Viewer = NARROW[clientData]; IF mouseButton = blue THEN ViewerTools.SetContents[usingList, NIL] ELSE ViewerTools.SetSelection[usingList, NIL]; }; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- 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; selector: REF Tool.OptionSelector; prev: ViewerClasses.Viewer; data: REF SModelData = NEW[SModelData _ []]; 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]; MakeCenteredLabel[op, op.definer.opAlias.Concat[" Options"]]; selector _ data.checkOptionSelector _ NEW[Tool.OptionSelector _ [choices: LIST[ ["no", NEW[BOOL _ FALSE]], ["yes", NEW[BOOL _ TRUE]] ]]]; prev _ tool.q.CreateButton[ info: [name: "Check existence on server:", wx: Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectSModelCheckOption, clientData: data, font: Tool.font ]; prev _ selector.displayer _ Labels.Create[ info: [name: selector.choices.first.name, wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, ww: LabelWidthForChoices[tool, selector.choices], parent: op.optionsContainer, border: FALSE ], font: Tool.font ]; selector _ data.storeOptionSelector _ NEW[Tool.OptionSelector _ [choices: LIST[ ["yes", NEW[BOOL _ TRUE]], ["no", NEW[BOOL _ FALSE]] ]]]; prev _ tool.q.CreateButton[ info: [name: "Store changed files:", wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], proc: SelectSModelStoreOption, clientData: data, font: Tool.font ]; prev _ selector.displayer _ Labels.Create[ info: [name: selector.choices.first.name, wx: prev.wx + prev.ww + Tool.entryHSpace, wy: op.height, wh: Tool.entryHeight, ww: LabelWidthForChoices[tool, selector.choices], parent: op.optionsContainer, border: FALSE ], font: Tool.font ]; op.height _ op.height + Tool.entryHeight + Tool.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; Interact: Ops.InteractionProc = { IF ~op.tool.abortRequested THEN response _ Tool.OpsInteraction[op.tool, interaction]; IF op.tool.abortRequested THEN { abort _ TRUE; abortMessageForLog _ "(user generated)"; op.tool.abortRequested _ FALSE; }; }; data: REF SModelData = NARROW[op.options]; dfNames: IO.STREAM = IO.RIS[ViewerTools.GetContents[tool.dfNames]]; action: Ops.SModelAction = data.action; DO errors, warnings, filesActedUpon: INT; dfName: ROPE = DFToDo[dfNames]; IF dfName.Length[] = 0 THEN EXIT; [errors: errors, warnings: warnings, filesActedUpon: filesActedUpon] _ Ops.SModel[ dfFile: dfName, action: action, interact: Interact, log: tool.log ]; tool.feedback.PutRope[MakeOutcomeRope[errors, warnings, filesActedUpon]]; ENDLOOP; }; ENDCASE; }; SelectSModelCheckOption: Buttons.ButtonProc = { data: REF SModelData = NARROW[clientData]; data.action.remoteCheck _ NARROW[SelectOption[data.checkOptionSelector].value, REF BOOL]^; }; SelectSModelStoreOption: Buttons.ButtonProc = { data: REF SModelData = NARROW[clientData]; data.action.storeChanged _ NARROW[SelectOption[data.storeOptionSelector].value, REF BOOL]^; }; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- AddOpToTable: PUBLIC PROC [definer: REF Tool.OpDefiner] = { definer.opAlias _ UserProfile.Token[Rope.Concat["DFTool.NameFor", definer.opName], definer.opName]; Tool.opTable.ops[Tool.opTable.nOps] _ definer; Tool.opTable.nOps _ Tool.opTable.nOps.SUCC; }; DFToDo: PUBLIC PROC [s: IO.STREAM] RETURNS [r: ROPE _ NIL] = { dfExt: ROPE = ".df"; r _ s.GetTokenRope[IO.IDProc ! IO.EndOfStream => CONTINUE].token; IF r.Length >= dfExt.Length[] AND r.Find[dfExt, r.Length[] - dfExt.Length[], FALSE] = -1 THEN r _ r.Concat[dfExt]; }; LabelWidthForChoices: PUBLIC PROC [tool: Tool.DFTool, list: LIST OF Tool.Choice] RETURNS [max: INT _ 0] = { maxRope: ROPE _ NIL; temp: Labels.Label; IF list = NIL THEN RETURN; FOR l: LIST OF Tool.Choice _ list, l.rest UNTIL l = NIL DO w: INT = VFonts.StringWidth[l.first.name]; IF w > max THEN {maxRope _ l.first.name; max _ w}; ENDLOOP; temp _ Labels.Create[ info: [name: maxRope, wx: 0, wy: 0, parent: tool.outer, border: FALSE], paint: FALSE ]; max _ temp.cw; Labels.Destroy[temp]; }; MakeCenteredLabel: PUBLIC PROC [op: Tool.Operation, name: ROPE] = { [] _ Labels.Create[ info: [name: name, wx: (Tool.OuterContainerWidth[op.tool] - VFonts.StringWidth[name])/2, wy: op.height, wh: Tool.entryHeight, parent: op.optionsContainer, border: FALSE ], font: Tool.boldFont ]; op.height _ op.height + Tool.entryHeight + Tool.entryVSpace; }; MakeOutcomeRope: PUBLIC PROC [errors, warnings, filesActedUpon: INT] RETURNS [ROPE] = { RETURN[ IO.PutFR["%d files retrieved%g\N", IO.card[filesActedUpon], IO.rope[ IF errors + warnings ~= 0 THEN IO.PutFR[" (with %d errors, %d warnings)", IO.card[errors], IO.card[warnings]] ELSE NIL ] ] ] }; SelectOption: PUBLIC PROC [selector: REF Tool.OptionSelector] RETURNS [choice: Tool.Choice] = { NextChoice: PROC [this: ROPE, list: LIST OF Tool.Choice] RETURNS [next: Tool.Choice _ [NIL, NIL]] = { IF list = NIL THEN RETURN; FOR l: LIST OF Tool.Choice _ list, l.rest UNTIL l = NIL DO IF this.Equal[l.first.name, FALSE] THEN RETURN[IF l.rest = NIL THEN list.first ELSE l.rest.first] ENDLOOP; RETURN[list.first] }; choice _ NextChoice[ViewerTools.GetContents[selector.displayer], selector.choices]; ViewerTools.SetContents[selector.displayer, choice.name]; }; ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- AddOpToTable[NEW[Tool.OpDefiner _ ["BringOver", $individual, BringOverSpecific]]]; AddOpToTable[NEW[Tool.OpDefiner _ ["SModel", $individual, SModelSpecific]]]; END. VIndividualOpsImpl.mesa last edited by Levin on October 7, 1983 1:58 pm BringOver-specific Code Copy out option information to prevent user edits while operation is in progress Note: runs synchronously with Viewers' notifier to ensure than manipulation of `selector.displayer' is atomic. Note: runs synchronously with Viewers' notifier to ensure than manipulation of `selector.displayer' is atomic. Note: runs synchronously with Viewers' notifier to ensure than manipulation of `selector.displayer' is atomic. Note: runs synchronously with Viewers' notifier to ensure than manipulation of `selector.displayer' is atomic. Note: runs synchronously with Viewers' notifier to ensure than manipulation of the using list is atomic. SModel-specific Code Copy out option information to prevent user edits while operation is in progress Note: runs synchronously with Viewers' notifier to ensure than manipulation of `selector.displayer' is atomic. Note: runs synchronously with Viewers' notifier to ensure than manipulation of `selector.displayer' is atomic. Utilities (exported for other OpImpls) Initialization Ê3˜Jšœ™Jšœ/™/J˜šÏk ˜ Jšœœ˜#Jšœ œ˜'šœ œ˜JšœŠ˜Š—šœœ˜Jšœ·˜·—Jšœœ;œœ˜VJšœœ˜&Jšœœ˜Jšœœœ˜/Jšœ œ ˜Jšœœ˜Jšœœ ˜Jšœ œ˜Jšœ œ=˜N—J˜šœœ˜ š˜Jšœ3œD˜y—Jšœ˜—J˜Jš˜J˜Jšœ)˜-J˜Jšœœœ˜J™JšÏcœžœžœžœžœžœžœž˜'J™Jšžœžœžœžœžœžœžœž˜'J˜šœœœ˜J˜!Jšœœœ˜/Jšœœœ˜/Jšœœœ˜/J˜$Jšœœœ˜.Jšœ"œž"˜IJ˜—J˜Jšœœ˜J˜šœ*˜*šœ˜˜Jšœœ˜#J˜Jšœ œ˜"J˜Jšœœœ˜2Jšœ˜šœ/˜/Jšœ˜Jšœ ž.˜9Jšœ˜Jšœ˜Jšœœ˜Jšœ ˜Jšœ˜—Jšœ8˜8Jšœ=˜=˜˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜ J˜—J˜Jšœ˜J˜J˜—šœ"œ!œ˜KJšœœ˜)Jšœ œ"˜1Jšœ œ ˜.Jšœ˜—˜*˜)J˜)Jšœ˜J˜J˜1Jšœ˜Jšœ˜ Jšœ˜—Jšœ˜Jšœ˜—˜˜Jšœ)˜)Jšœ˜Jšœ˜Jšœ˜Jšœ˜ J˜—J˜Jšœ˜J˜J˜—šœ"œ!œ˜KJšœœ˜)Jšœ œ"˜1Jšœ œ ˜.Jšœ˜—˜*˜)J˜)Jšœ˜J˜J˜1Jšœ˜Jšœ˜ Jšœ˜—Jšœ˜Jšœ˜—˜˜Jšœ)˜)Jšœ˜Jšœ˜Jšœ˜Jšœ˜ J˜—J˜Jšœ˜J˜J˜—šœ"œ!œ˜KJšœœ˜)Jšœ œ#˜3Jšœ œ"˜2Jšœ˜—˜*˜)J˜)Jšœ˜J˜J˜1Jšœ˜Jšœ˜ Jšœ˜—Jšœ˜Jšœ˜—J˜<˜6Jšœž˜Jšœ˜Jšœ ž.˜9J˜(Jšœœ˜ Jšœ˜Jšœ œ˜Jšœ˜ Jšœ˜—˜˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜Jšœ˜ J˜—J˜Jšœœ˜ Jšœ˜J˜J˜—šœ˜Jšœ˜Jšœ>˜>Jšœ*˜*J˜—Jšœ<˜Jšœœ ˜Jšœœ œœ˜Ašœœ,œ˜]J˜—J˜—J˜š Ÿœœœœœ ˜PJšœœ ˜Jšœ œœ˜Jšœ˜Jšœœœœ˜š œœœœœ˜:Jšœœ$˜*Jšœ œ#˜2Jšœ˜—šœ˜Jšœ@œ˜GJšœ˜ J˜—J˜J˜J˜J˜—šŸœœœœ˜Cšœ˜šœ˜J˜EJšœ˜J˜Jšœ˜Jšœ˜ Jšœ˜—Jšœ˜Jšœ˜—Jšœ<˜