<<>> <> <> <> DIRECTORY AdobeCommon USING [AdobeTimeRope, AdobeViewerDataRec, ButtonsSeq, ButtonSeqObject, DependentsSequence, DependentsSequenceRec, EnumeratedTypes, EnumeratedTypesRec, GetFullLoginName, Handle, SelectionsSequence], AdobeCommonInternal, AdobeOps USING [ARSystemHandle, ArFIO, DateFIO, NumFIO, FixFIO, EnumFIO, StrFIO, ToolType], AdobeTool, BasicTime USING [GMT, Now], Imager, IO USING [PutF, Value], Rope USING [Cat, Concat, Equal, ROPE]; AdobeToolImpl: CEDAR MONITOR IMPORTS AdobeCommon, AdobeTool, BasicTime, IO, Rope EXPORTS AdobeTool = { BumpNumOfDeps: PUBLIC PROC [add: AdobeCommon.EnumeratedTypes, addTo: AdobeCommon.EnumeratedTypes] = { IF addTo.dependentsSequence = NIL THEN { addTo.dependentsSequence ¬ NEW[AdobeCommon.DependentsSequenceRec[5]]; }; FOR index: CARDINAL ¬ 0, index + 1 UNTIL (index = addTo.dependentsSequence.length) DO IF addTo.dependentsSequence[index] = NIL THEN { addTo.dependentsSequence[index] ¬ add; RETURN; }; ENDLOOP; <> { newDepSeq: AdobeCommon.DependentsSequence ¬ NEW[AdobeCommon.DependentsSequenceRec[addTo.dependentsSequence.length + 5]]; FOR index:CARDINAL IN [0..addTo.dependentsSequence.length) DO newDepSeq[index] ¬ addTo.dependentsSequence[index]; ENDLOOP; newDepSeq[addTo.dependentsSequence.length + 1] ¬ add; addTo.dependentsSequence ¬ newDepSeq; }; }; RopeFromTool: PROCEDURE [tool: AdobeOps.ToolType] RETURNS [rope: Rope.ROPE ¬ NIL] = { SELECT tool FROM edit => {RETURN ["Edit"] }; submit => {RETURN ["Submit"] }; report => {RETURN ["Report"] }; query => {RETURN ["Query"] }; sort => {RETURN ["Sort"] }; queryList => {RETURN ["QueryList"] }; ENDCASE; }; CountRopes: PUBLIC PROC [l: LIST OF Rope.ROPE] RETURNS [count: CARD ¬ 0] ~ { FOR i: LIST OF Rope.ROPE ¬ l, i.rest UNTIL i = NIL DO count ¬ count + 1; ENDLOOP; RETURN[count]; }; SetUpEditTool: PROC [handle: AdobeCommon.Handle] = { x, y, w, h: CARD; procData: AdobeTool.CurrentButtonProcData; thisViewer: REF ANY ¬ handle.fieldViewer.outer; thisSH: AdobeOps.ARSystemHandle ¬ handle.systemHandle; thisField: AdobeCommon.EnumeratedTypes ¬ NIL; lineIndex: INTEGER ¬ 0; fieldHeight: CARDINAL ¬ --VFonts.FontHeight[] + 2 --17; IF handle.fieldViewer.buttons # NIL THEN EmptyFieldViewer[handle]; handle.currentAR ¬ 0; handle.setContents[handle.editors[1], "0"]; handle.fieldViewer.buttons ¬ NEW[AdobeCommon.ButtonSeqObject[thisSH.fieldList.length]]; FOR field: CARDINAL IN [0..thisSH.fieldList.length) DO handle.fieldViewer.buttons[field] ¬ NEW[AdobeCommon.EnumeratedTypesRec]; thisField ¬ handle.fieldViewer.buttons[field]; thisField.mainViewer ¬ handle; thisField.boolVal ¬ TRUE; FOR tt: AdobeOps.ToolType IN AdobeOps.ToolType DO thisField.defaults[tt] ¬ thisSH.fieldList[field].defaultInfo[tt].default; ENDLOOP; procData ¬ NEW[AdobeTool.CurrentButtonProcDataRec]; procData.h ¬ handle; procData.e ¬ handle.fieldViewer.buttons[field]; WITH thisSH.fieldList[field] SELECT FROM it: AdobeOps.EnumFIO => { numSubMenus, saveKey, currentEnum: CARD ¬ 0; thisField.type ¬ enumerated; thisField.dependentsSequence ¬ NEW[AdobeCommon.DependentsSequenceRec[5]]; IF it.field # LAST[CARD16] THEN { currentSubMenu: CARD ¬ 0; thisField.dependentOn ¬ handle.fieldViewer.buttons[it.field]; numSubMenus ¬ CountRopes[thisField.dependentOn.allSelections[0].ropes]; BumpNumOfDeps[handle.fieldViewer.buttons[field], handle.fieldViewer.buttons[it.field]]; thisField.currentMenu ¬ numSubMenus - 1; thisField.allSelections ¬ NEW[AdobeCommon.SelectionsSequence[numSubMenus]]; WITH thisSH.fieldList[it.field] SELECT FROM dep: AdobeOps.EnumFIO => { --tmp-- itkd, depit, foo: CARD; did: BOOL ¬ FALSE; -- tmp -- max: CARD ¬ dep.possibilities[0].enumRecs.length; FOR index: CARD IN [0..dep.possibilities[0].enumRecs.length) DO did ¬ FALSE; FOR itIndex: CARD IN [0..it.possibilities.length) DO -- tmp -- itkd ¬ it.possibilities[itIndex].keyedDependency; -- tmp -- depit ¬ dep.possibilities[0].enumRecs[index].item; IF it.possibilities[itIndex].keyedDependency = dep.possibilities[0].enumRecs[index].item THEN { thisField.allSelections[currentSubMenu].num ¬ index; -- tmp -- foo ¬ it.possibilities[itIndex].enumRecs.length; FOR i: CARD IN [0..it.possibilities[itIndex].enumRecs.length) DO thisField.allSelections[currentSubMenu].ropes ¬ CONS[it.possibilities[itIndex].enumRecs[it.possibilities[itIndex].enumRecs.length - i - 1].tag, thisField.allSelections[currentSubMenu].ropes]; ENDLOOP; currentSubMenu ¬ currentSubMenu + 1; did ¬ TRUE; EXIT }; ENDLOOP; IF ~did THEN { thisField.allSelections[currentSubMenu] ¬ [index, LIST["Nil"]]; currentSubMenu ¬ currentSubMenu + 1; }; ENDLOOP; }; ENDCASE => ERROR; <> <= it.possibilities.length THEN>> <> <> <> <<>> <> <> <> <> <> <<}>> <> <> <<};>> <> } ELSE { thisField.dependentOn ¬ NIL; thisField.currentMenu ¬ 0; thisField.allSelections ¬ NEW[AdobeCommon.SelectionsSequence[1]]; thisField.allSelections[0].num ¬ it.possibilities[0].enumRecs[0].item; FOR index: CARD IN [0..it.possibilities[0].enumRecs.length) DO thisField.allSelections[0].ropes ¬ CONS[ it.possibilities[0].enumRecs[it.possibilities[0].enumRecs.length - index - 1].tag, thisField.allSelections[0].ropes]; ENDLOOP; thisField.currentSelection ¬ it.possibilities[0].enumRecs.length - 1; }; thisField.button ¬ handle.makeButton[thisViewer, 0, lineIndex * fieldHeight, Rope.Concat[it.name, ": "], procData, FALSE, $CurrentButtonProc, procData]; [x, y, w, h] ¬ handle.getBoxGeometry[thisField.button]; thisField.controllerOf ¬ handle.newFieldBox[ parent: thisViewer, x: w+5, y: lineIndex * fieldHeight, w: 400, h: h, border: FALSE, scrollable: FALSE ]; handle.setContents[thisField.controllerOf, "{}"]; thisField.boolVal ¬ TRUE; handle.inhibitEdits[thisField.controllerOf]; }; it: AdobeOps.ArFIO => { handle.fieldViewer.buttons[field].type ¬ arId; handle.fieldViewer.buttons[field].button ¬ handle.makeButton[thisViewer, 0, lineIndex * fieldHeight, Rope.Concat[it.name, ": "], procData, FALSE, $SubmitFieldButtonProc, procData]; [x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button]; handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[ parent: thisViewer, x: w+5, y: lineIndex * fieldHeight, w: 400, h: h, border: FALSE, scrollable: FALSE ]; handle.inhibitEdits[handle.fieldViewer.buttons[field].controllerOf]; }; it: AdobeOps.DateFIO => { handle.fieldViewer.buttons[field].type ¬ dateTime; handle.fieldViewer.buttons[field].button ¬ handle.makeButton[thisViewer, 0, lineIndex * fieldHeight, Rope.Concat[it.name, ": "], procData, FALSE, $SubmitFieldButtonProc, procData]; [x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button]; handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[ parent: thisViewer, x: w+5, y: lineIndex * fieldHeight, w: 400, h: h, border: FALSE, scrollable: FALSE ]; handle.inhibitEdits[handle.fieldViewer.buttons[field].controllerOf]; }; it: AdobeOps.NumFIO => { handle.fieldViewer.buttons[field].type ¬ numeric; handle.fieldViewer.buttons[field].button ¬ handle.makeButton[thisViewer, 0, lineIndex * fieldHeight, Rope.Concat[it.name, ": "], procData, FALSE, $SubmitFieldButtonProc, procData]; [x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button]; handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[ parent: thisViewer, x: w+5, y: lineIndex * fieldHeight, w: 400, h: h, border: FALSE, scrollable: FALSE ]; handle.inhibitEdits[handle.fieldViewer.buttons[field].controllerOf]; }; it: AdobeOps.FixFIO => { handle.fieldViewer.buttons[field].type ¬ fixedLengthString; handle.fieldViewer.buttons[field].button ¬ handle.makeButton[thisViewer, 0, lineIndex * fieldHeight, Rope.Concat[it.name, ": "], procData, FALSE, $SubmitFieldButtonProc, procData]; [x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button]; handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[ parent: thisViewer, x: w+5, y: lineIndex * fieldHeight, w: handle.getBoxGeometry[handle.outer].w - w - 5, h: h, border: FALSE, scrollable: TRUE ]; <> <> <> <> <> <> <> <> <> <<]>> <<];>> handle.xBoundBox[handle.fieldViewer.outer, handle.fieldViewer.buttons[field].controllerOf]; handle.fieldViewer.buttons[field].maxLength ¬ it.maxLength; handle.inhibitEdits[handle.fieldViewer.buttons[field].controllerOf]; }; it: AdobeOps.StrFIO => { thisField.type ¬ string; thisField.button ¬ handle.makeButton[thisViewer, 0, lineIndex * fieldHeight, Rope.Concat[it.name, ": "], procData, FALSE, $SubmitFieldButtonProc, procData]; [x, y, w, h] ¬ handle.getBoxGeometry[thisField.button]; thisField.adjButton ¬ handle.makeButton[thisViewer, x + w - --VFonts.StringWidth[""]-- 35 -5, (lineIndex+1) * fieldHeight, "", handle.fieldViewer.buttons[field], TRUE, $AdjustStringHeight, handle.fieldViewer.buttons[field]]; thisField.controllerOf ¬ handle.newFieldBox[ parent: thisViewer, x: w+5, y: lineIndex * fieldHeight, w: handle.getBoxGeometry[handle.outer].w - w - 5, h: (h * handle.unboundFieldHeight) - 2, border: FALSE, scrollable: TRUE ]; handle.xBoundBox[handle.fieldViewer.outer, thisField.controllerOf]; <> thisField.currentHeight ¬ handle.unboundFieldHeight; <> <> <> <> <<].out;>> lineIndex ¬ lineIndex + thisField.currentHeight - 1; handle.inhibitEdits[thisField.controllerOf]; }; ENDCASE; lineIndex ¬ lineIndex + 1; ENDLOOP; }; Report: PROCEDURE [handle: AdobeCommon.Handle, format: Rope.ROPE, v1, v2, v3: IO.Value ¬ [null[]] ] = { handle.messageViewer.reportStream.PutF[format, v1, v2, v3]; }; SetEnumValue: PUBLIC PROC [handle: AdobeCommon.Handle, enum: AdobeCommon.EnumeratedTypes, val: CARD, evenIfAlready: BOOL ¬ FALSE] ~ { tmpList: LIST OF Rope.ROPE ¬ enum.allSelections[enum.currentMenu].ropes; FOR index: CARD IN [0..val) DO tmpList ¬ tmpList.rest; ENDLOOP; SetEnumField[handle, enum, tmpList.first, evenIfAlready]; }; SetEnumField: PUBLIC PROC [handle: AdobeCommon.Handle, enum: AdobeCommon.EnumeratedTypes, sel: Rope.ROPE ¬ NIL, evenIfAlready: BOOL ¬ FALSE] ~ { ropeToPutIn: Rope.ROPE ¬ sel; index: CARD ¬ 0; IF enum.dependentOn # NIL THEN enum.currentMenu ¬ enum.dependentOn.currentSelection; IF sel = NIL OR Rope.Equal[sel, "Nil", FALSE] THEN index ¬ CountRopes[enum.allSelections[enum.currentMenu].ropes] - 1 ELSE { tmpList: LIST OF Rope.ROPE ¬ NIL; FOR tmpList ¬ enum.allSelections[enum.currentMenu].ropes, tmpList.rest UNTIL tmpList = NIL OR Rope.Equal[tmpList.first, sel, FALSE] DO index ¬ index + 1; ENDLOOP; IF tmpList = NIL THEN RETURN; ropeToPutIn ¬ tmpList.first; }; IF ~evenIfAlready THEN IF enum.currentSelection = index THEN RETURN; IF Rope.Equal[ropeToPutIn, "Nil", FALSE] THEN ropeToPutIn ¬ ""; ropeToPutIn ¬ Rope.Concat["{", ropeToPutIn.Concat["}"]]; handle.setContents[enum.controllerOf, ropeToPutIn]; enum.currentSelection ¬ index; IF enum.dependentsSequence # NIL THEN FOR index: CARDINAL IN [0..enum.dependentsSequence.length) DO IF enum.dependentsSequence[index] # NIL THEN SetEnumField[handle, enum.dependentsSequence[index], "Nil"]; ENDLOOP; }; EnableUserEdits: PUBLIC PROC [handle: AdobeCommon.Handle] = { IF handle.fieldViewer.buttons # NIL THEN FOR loop: CARDINAL IN [0..handle.fieldViewer.buttons.length) DO IF handle.fieldViewer.buttons[loop].defaults[handle.tool] = NIL THEN SELECT handle.fieldViewer.buttons[loop].type FROM arId => NULL; enumerated => handle.fieldViewer.buttons[loop].boolVal ¬ FALSE; ENDCASE => { handle.fieldViewer.buttons[loop].boolVal ¬ FALSE; handle.enableEdits[handle.fieldViewer.buttons[loop].controllerOf]; }; ENDLOOP; }; DisableUserEdits: PUBLIC PROC [handle: AdobeCommon.Handle] = { IF handle.fieldViewer.buttons # NIL THEN FOR loop: CARDINAL IN [0..handle.fieldViewer.buttons.length) DO handle.inhibitEdits[handle.fieldViewer.buttons[loop].controllerOf]; handle.fieldViewer.buttons[loop].boolVal ¬ TRUE; ENDLOOP; }; EmptyFieldViewer: PUBLIC PROC [handle: AdobeCommon.Handle] = { IF handle.fieldViewer.buttons # NIL THEN { FOR loop: CARDINAL IN [0..handle.fieldViewer.buttons.length) DO handle.destroyBox[handle, handle.fieldViewer.buttons[loop].controllerOf, FALSE]; handle.destroyBox[handle, handle.fieldViewer.buttons[loop].adjButton, FALSE]; handle.destroyBox[handle, handle.fieldViewer.buttons[loop].button, FALSE]; ENDLOOP; handle.fieldViewer.buttons ¬ NIL; handle.paintBox[handle.fieldViewer.outer, $all]; }; }; ClearWindow: PUBLIC PROC [handle: AdobeCommon.Handle] ~ { EmptyFieldViewer[handle]; }; SetUpWindow: PUBLIC PROC [handle: AdobeCommon.Handle] ~ { nameBase: Rope.ROPE ¬ NIL; SELECT handle.tool FROM edit => SetUpEditTool[handle]; submit => AdobeTool.SetUpSubmitTool[handle]; query => AdobeTool.SetUpQueryTool[handle]; report => AdobeTool.SetUpReportTool[handle]; queryList => AdobeTool.SetUpQueryListTool[handle]; ENDCASE ; nameBase ¬ Rope.Concat["Adobe ", RopeFromTool[handle.tool]]; handle.setMainName[handle.outer, nameBase]; IF handle.systemHandle # NIL THEN handle.setMainName[handle.outer, nameBase.Cat[" using ", handle.systemHandle.name]]; handle.paintBox[handle.outer, $caption]; }; SetUpDefaults: PUBLIC PROCEDURE [handle: AdobeCommon.Handle] ~ { r, s: Rope.ROPE ¬ NIL; FOR i :CARD IN [0..handle.fieldViewer.buttons.length) DO r ¬ handle.fieldViewer.buttons[i].defaults[handle.tool]; IF r # NIL THEN { SELECT TRUE FROM Rope.Equal[r, "CurrentTOD", FALSE] => handle.setContents[handle.fieldViewer.buttons[i].controllerOf, AdobeCommon.AdobeTimeRope[BasicTime.Now[]]]; Rope.Equal[r, "LoginName", FALSE] => handle.setContents[handle.fieldViewer.buttons[i].controllerOf, AdobeCommon.GetFullLoginName[handle]]; ENDCASE => handle.setContents[handle.fieldViewer.buttons[i].controllerOf, r]; handle.fieldViewer.buttons[i].boolVal ¬ TRUE; }; ENDLOOP; }; EmptyContents: PUBLIC PROCEDURE[handle: AdobeCommon.Handle] ~ { FOR index: CARD ¬ 0, index + 1 UNTIL index = handle.fieldViewer.buttons.length DO handle.setContents[handle.fieldViewer.buttons[index].controllerOf, ""--, TRUE--]; ENDLOOP; }; }.