AdobeUIImpl.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Philip James, March 10, 1992 3:30 pm PST
DIRECTORY
AccessCH USING [NSNameFromRope],
AdobeCommon USING [AddSystemToKnownSystems, Box, EnumeratedTypes, FindSystem, FindThisQL, FormatType, Handle, InitialSetStatus, LocateSystemInKnownSystems, PostMessage, PostNumber, RemoveSystemFromKnownSystems, RowBufferRec, SetFSWOrderAndDefaultFromUserFile, StringArray],
AdobeCommonInternal USING [EntryBytesType, InstanceData, InstanceDataHandle, SystemNotFound],
AdobeIO USING [ReadProc, UnlockProc, WriteProc],
AdobeOps USING [ARNumber, ARSystemHandle, FieldList, QLHandle, QueryList, StrFIO, ToolType],
AdobeP75V2 USING [FieldItemObjectRec, FieldItemValue, FieldItemValueRec],
AdobeTool USING [ClearWindow, CurrentButtonProcData, DisableUserEdits, EmptyContents, EnableUserEdits, GetPossibilities, GetValidRelations, SetEnumValue, SetUpDefaults, SetUpWindow],
AdobeUI USING [Handle],
BasicTime USING [nullGMT],
Convert USING [CardFromRope, Error, RopeFromCard, TimeFromRope],
CrRPC USING [Error],
PFS USING [Error, PathFromRope, StreamOpen],
Rope USING [Concat, Equal, IsEmpty, Length, ROPE, Substr],
ViewerClasses USING [MouseButton],
ViewerTools USING [SelPos, SelPosRec],
XNSAdobeClientOps USING [AboutToStore, GetNextSubmitNumber, SubmitFailed, UpdateAcceleratorField];
AdobeUIImpl: CEDAR MONITOR
IMPORTS AccessCH, AdobeCommon, AdobeCommonInternal, AdobeIO, AdobeTool, Convert, CrRPC, PFS, Rope, XNSAdobeClientOps
EXPORTS AdobeUI ~ {
HandleField: PUBLIC PROCEDURE [h: AdobeUI.Handle, field: INTEGER, mouseButton: ViewerClasses.MouseButton, title: Rope.ROPE ¬ NIL, selections: LIST OF Rope.ROPE ¬ NIL] RETURNS [which: INT ¬ 0] = {
SELECT mouseButton FROM
red => {
h.setSelection[h.editors[field]];
};
yellow => SELECT title FROM
NIL => {
h.setContents[h.editors[field], ""];
h.setSelection[h.editors[field]];
};
ENDCASE => which ¬ h.popUpRequest[title, selections];
blue => {
h.setSelection[h.editors[field]];
};
ENDCASE => ERROR;
};
BusyTest: PROCEDURE [h: AdobeUI.Handle] RETURNS [isBusy: BOOLEAN ¬ FALSE] ~ {
IF h.isBusy THEN {
h.report[h, "Adobe tool is busy, try again later.\n"];
RETURN[TRUE];
};
};
CheckSystem: PROC [h: AdobeUI.Handle] RETURNS [continue: BOOL ¬ TRUE] ~ {
IF h.system = LAST[CARD] OR h.systemName = NIL THEN {
h.report[h, "Must specify system.\n"];
RETURN[FALSE];
};
};
AnotherTool: PUBLIC PROCEDURE [h: AdobeUI.Handle ¬ NIL] ~ {
h.makeAnotherTool[h];
};
ExamineRope: Rope.ROPE ~ "Examining AR #%g ... ";
DoExamine: PROC[h: AdobeUI.Handle, r: Rope.ROPE ¬ ExamineRope, lock: BOOL ¬ FALSE] ~ {
IF ~CheckSystem[h] THEN RETURN;
IF BusyTest[h] THEN RETURN;
SELECT h.currentARState FROM
CheckedOut => h.report[h, "Check in current AR first!\n"];
Normal => {
h.currentAR ¬ GetNumber[h];
SELECT h.currentAR FROM
0 => {
AdobeTool.EmptyContents[h];
};
LAST[CARDINAL] => {
h.currentAR ¬ h.oldCurrentAR
};
ENDCASE => {
h.isBusy ¬ TRUE;
h.report[h, r, [integer[h.currentAR]]];
AdobeIO.ReadProc[h.currentAR, h, NIL, lock];
h.oldCurrentAR ¬ h.currentAR;
AdobeTool.DisableUserEdits[h];
h.isBusy ¬ FALSE;
h.report[h, "done.\n"];
};
};
ENDCASE => {};
};
DoCheckIn: PROCEDURE [h: AdobeUI.Handle] ~ {
done: BOOL ¬ FALSE;
fIV: AdobeP75V2.FieldItemValue;
r: Rope.ROPE ¬ NIL;
IF ~CheckSystem[h] THEN RETURN;
IF BusyTest[h] THEN RETURN;
SELECT h.currentARState FROM
Normal => h.report[h, "No AR checked out.\n"];
CheckedOut => {
h.report[h, "Checking in AR#%g...", [integer[h.currentAR]]];
h.isBusy ¬ TRUE;
Check in AR
AdobeTool.DisableUserEdits[h];
IF AdobeIO.WriteProc[h] THEN {
AdobeIO.UnlockProc[h.currentAR, h];
h.setIcon[h, $normal];
h.currentARState ¬ Normal;
h.report[h, "Updating Accelerators . . . "];
FOR i: CARD IN [0..h.fieldViewer.buttons.length) DO
done ¬ FALSE;
r ¬ h.getContents[h.fieldViewer.buttons[i].controllerOf];
fIV ¬ NIL;
SELECT h.fieldViewer.buttons[i].type FROM
arId =>
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.arId ¬ [arId[Convert.CardFromRope[r]]]];
dateTime =>
IF r = NIL OR r.Length = 0 OR r.IsEmpty[] THEN
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.dateTime ¬ [dateTime[BasicTime.nullGMT]]]
ELSE
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.dateTime ¬ [dateTime[Convert.TimeFromRope[r]]]];
numeric =>
IF r = NIL OR r.Length = 0 OR r.IsEmpty[] THEN
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.numeric ¬ [numeric[0]]]
ELSE
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.numeric ¬ [numeric[Convert.CardFromRope[r]]]];
fixedLengthString =>
IF r = NIL OR r.Length = 0 OR r.IsEmpty[] THEN
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.fixedLengthString ¬ [fixedLengthString[NIL, h.fieldViewer.buttons[i].maxLength]]]
ELSE
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.fixedLengthString ¬ [fixedLengthString[r, h.fieldViewer.buttons[i].maxLength]]];
enumerated => {
evalNum: CARD ¬ 0;
r: Rope.ROPE ¬ Rope.Substr[h.getBoxName[h.fieldViewer.buttons[i].button], 0, h.getBoxName[h.fieldViewer.buttons[i].button].Length - 2];
cO: Rope.ROPE ¬ h.getContents[h.fieldViewer.buttons[i].controllerOf];
cO ¬ Rope.Substr[cO, 1, cO.Length - 2];
FOR j: CARD IN [0..h.systemHandle.fieldList.length) DO
IF Rope.Equal[h.systemHandle.fieldList[j].name, r] THEN {
WITH h.systemHandle.fieldList[j] SELECT FROM
it: REF AdobeP75V2.FieldItemObjectRec.enumerated => {
FOR k: CARD IN [0..it.possibilities.length) DO
FOR l: CARD IN [0..it.possibilities[k].enumRecs.length) DO
IF Rope.Equal[it.possibilities[k].enumRecs[l].tag, cO] THEN {
fIV ¬ NEW[AdobeP75V2.FieldItemValueRec.enumerated ¬ [enumerated[it.possibilities[k].enumRecs[l].item]]];
done ¬ TRUE;
};
IF done THEN EXIT;
ENDLOOP;
IF done THEN EXIT;
ENDLOOP;
};
ENDCASE => ERROR;
EXIT;
};
ENDLOOP;
IF ~done THEN
fIV ¬ NEW[AdobeP75V2.FieldItemValueRec.enumerated ¬ [enumerated[LAST[CARD16]]]];
};
string => {};
ENDCASE => ERROR;
IF fIV # NIL THEN
XNSAdobeClientOps.UpdateAcceleratorField[h.systemHandle.service, AccessCH.NSNameFromRope[h.systemName].local, h.systemHandle.version, h.currentAR, fIV, Rope.Substr[h.getBoxName[h.fieldViewer.buttons[i].button], 0, h.getBoxName[h.fieldViewer.buttons[i].button].Length-2]];
ENDLOOP;
h.report[h, "done.\n"];
} ELSE
AdobeTool.EnableUserEdits[h];
h.isBusy ¬ FALSE;
};
ENDCASE => {};
};
CheckOutRope: Rope.ROPE ~ "Checking out AR #%g ...";
CheckIn: PUBLIC PROC[h: AdobeUI.Handle] ~ {
ENABLE UNWIND => NULL;
DoCheckIn[h];
};
CheckInAndOut: PUBLIC PROC[h: AdobeUI.Handle] ~ {
ENABLE UNWIND => NULL;
DoCheckIn[h];
DoCheckOut[h];
};
CheckInAndExamine: PUBLIC PROC[h: AdobeUI.Handle] ~ {
ENABLE UNWIND => NULL;
DoCheckIn[h];
DoExamine[h];
};
Examine: PUBLIC PROC[h: AdobeUI.Handle] ~ {
ENABLE UNWIND => NULL;
DoExamine[h];
};
CheckOut: PUBLIC PROC[h: AdobeUI.Handle] ~ {
ENABLE UNWIND => NULL;
DoCheckOut[h];
};
DoCheckOut: PROC[h: AdobeUI.Handle] ~ {
IF ~CheckSystem[h] THEN RETURN;
IF BusyTest[h] THEN RETURN;
DoExamine[h, CheckOutRope, TRUE];
AdobeTool.EnableUserEdits[h];
h.currentARState ¬ CheckedOut;
h.setIcon[h, $editted];
h.paintBox[h.outer, $all];
};
AbortCheckOut: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
IF ~CheckSystem[h] THEN RETURN;
IF BusyTest[h] THEN RETURN;
SELECT h.currentARState FROM
Normal => h.report[h, "No AR checked out.\n"];
CheckedOut => {
Cancel CheckOut
h.isBusy ¬ TRUE;
h.report[h, "Aborting check out of AR#%g ... ", [integer[h.currentAR]]];
h.currentARState ¬ Normal;
AdobeTool.DisableUserEdits[h];
AdobeIO.UnlockProc[h.currentAR, h];
h.setIcon[h, $normal];
h.paintBox[h.outer, $all];
h.isBusy ¬ FALSE;
h.report[h, "done.\n"];
};
ENDCASE => {};
};
Next: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[h.instanceData];
number: CARDINAL ¬ 0;
WITH instanceData SELECT FROM
id: REF AdobeCommonInternal.InstanceData.edit =>
IF id.useQL THEN {
IF id.qlSetStatus = AdobeCommon.InitialSetStatus THEN id.qlSetStatus ¬ [0,0]
ELSE {
id.qlSetStatus.runOffset ¬ id.qlSetStatus.runOffset + 1;
IF id.qlSetStatus.runOffset = id.qlHandle.list.body[id.qlSetStatus.setIndex].runLength THEN {
id.qlSetStatus.runOffset ¬ 0;
id.qlSetStatus.setIndex ¬ id.qlSetStatus.setIndex + 1;
IF id.qlSetStatus.setIndex = id.qlHandle.list.len THEN {
id.qlSetStatus ¬ AdobeCommon.InitialSetStatus;
AdobeCommon.PostMessage[h, TRUE, "Query List Exhausted"];
h.setDisplayStyle[h.useQLButton, $BlackOnWhite];
id.useQL ¬ FALSE;
RETURN;
}
}
};
number ¬ id.qlHandle.list.body[id.qlSetStatus.setIndex].startValue + id.qlSetStatus.runOffset;
}
ELSE {
number ¬ GetNumber[h];
IF number # LAST[CARDINAL] THEN number ¬ number + 1;
};
ENDCASE;
IF number # LAST[CARDINAL] THEN
h.setContents[h.editors[1], Convert.RopeFromCard[number, 10, FALSE]];
};
Previous: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[h.instanceData];
number: CARDINAL ¬ 0;
WITH instanceData SELECT FROM
id: REF AdobeCommonInternal.InstanceData.edit =>
IF id.useQL THEN {
IF id.qlSetStatus = AdobeCommon.InitialSetStatus THEN id.qlSetStatus ¬ [id.qlHandle.list.body[id.qlHandle.list.len-1].runLength-1, id.qlHandle.list.len-1]
ELSE
IF id.qlSetStatus.runOffset # 0 THEN
id.qlSetStatus.runOffset ¬ id.qlSetStatus.runOffset - 1
ELSE
IF id.qlSetStatus.setIndex # 0 THEN {
id.qlSetStatus.setIndex ¬ id.qlSetStatus.setIndex - 1;
id.qlSetStatus.runOffset ¬ id.qlHandle.list.body[id.qlSetStatus.setIndex].runLength-1;
}
ELSE {
AdobeCommon.PostMessage[h, TRUE, "Query List Exhausted"];
h.setDisplayStyle[h.useQLButton, $BlackOnWhite];
id.useQL ¬ FALSE;
id.qlSetStatus ¬ AdobeCommon.InitialSetStatus;
RETURN;
};
number ¬ id.qlHandle.list.body[id.qlSetStatus.setIndex].startValue + id.qlSetStatus.runOffset;
}
ELSE {
number ¬ GetNumber[h];
IF number # LAST[CARDINAL] THEN number ¬ number - 1;
};
ENDCASE;
IF number # LAST[CARDINAL]THEN
h.setContents[h.editors[1], Convert.RopeFromCard[number, 10, FALSE]];
};
UseQL: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[h.instanceData];
ql: AdobeOps.QueryList ¬ NIL;
WITH instanceData SELECT FROM
id: REF AdobeCommonInternal.InstanceData.edit => {
IF id.useQL THEN {
id.useQL ¬ FALSE;
h.setDisplayStyle[h.useQLButton , $BlackOnWhite];
RETURN;
};
ql ¬ AdobeCommon.FindThisQL[h.getContents[h.editors[3]], h];
IF ql = NIL OR ql.list = NIL THEN
AdobeCommon.PostMessage[h, TRUE, "Empty QueryList!"]
ELSE {
h.setDisplayStyle[h.useQLButton , $WhiteOnBlack];
id.qlSetStatus ¬ AdobeCommon.InitialSetStatus;
id.useQL ¬ TRUE;
id.qlName ¬ ql.name;
id.qlHandle ¬ ql;
};
};
ENDCASE;
};
WhichQL: PUBLIC PROCEDURE [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] = {
ENABLE UNWIND => NULL;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[h.instanceData];
sel: ViewerTools.SelPos ¬ NIL;
WITH instanceData SELECT FROM
id: REF AdobeCommonInternal.InstanceData.edit =>
IF id.useQL THEN {
AdobeCommon.PostMessage[h, TRUE, "Currently using that QueryList."];
RETURN
};
ENDCASE;
SELECT mouseButton FROM
red => h.setSelection[h.editors[3]];
blue => {
h.setContents[h.editors[3], ""];
h.setSelection[h.editors[3]];
};
ENDCASE => {
l: LIST OF Rope.ROPE ¬ NIL;
which: INT ¬ 0;
FOR q: AdobeOps.QLHandle ¬ h.systemHandle.otherQLs, q.next UNTIL q = NIL DO
l ¬ CONS[q.qL.name, l];
ENDLOOP;
l ¬ CONS["SysQL", l];
which ¬ h.popUpRequest["Query List Name", l];
SELECT which FROM
<= 0 => RETURN;
1 => h.setContents[h.editors[3], "SysQL"];
ENDCASE =>
FOR lr: LIST OF Rope.ROPE ¬ l, lr.rest UNTIL lr = NIL DO
which ¬ which - 1;
IF which = 0 THEN
h.setContents[h.editors[3], lr.first];
ENDLOOP;
sel ¬ NEW[ViewerTools.SelPosRec ¬ [h.getContents[h.editors[3]].Length + 1, 0, FALSE, after]];
h.setSelection[h.editors[3], sel];
};
};
Clear: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
AdobeTool.EmptyContents[h];
AdobeTool.SetUpDefaults[h];
};
WhichQL2: PUBLIC PROCEDURE [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] = {
ENABLE UNWIND => NULL;
sel: ViewerTools.SelPos ¬ NIL;
SELECT mouseButton FROM
red => h.setSelection[h.editors[1]];
blue => {
h.setContents[h.editors[1], ""];
h.setSelection[h.editors[1]];
};
ENDCASE => {
l: LIST OF Rope.ROPE ¬ NIL;
which: INT ¬ 0;
FOR q: AdobeOps.QLHandle ¬ h.systemHandle.otherQLs, q.next UNTIL q = NIL DO
l ¬ CONS[q.qL.name, l];
ENDLOOP;
l ¬ CONS["SysQL", l];
which ¬ h.popUpRequest["Query List Name", l];
SELECT which FROM
<= 0 => RETURN;
1 => h.setContents[h.editors[1], "SysQL"];
ENDCASE =>
FOR lr: LIST OF Rope.ROPE ¬ l, lr.rest UNTIL lr = NIL DO
which ¬ which - 1;
IF which = 0 THEN
h.setContents[h.editors[1], lr.first];
ENDLOOP;
sel ¬ NEW[ViewerTools.SelPosRec ¬ [h.getContents[h.editors[1]].Length + 1, 0, FALSE, after]];
h.setSelection[h.editors[1], sel];
};
};
GetSubmitFileName: PROCEDURE [h: AdobeUI.Handle] RETURNS [fName: Rope.ROPE ¬ NIL] ~ {
fName ¬ h.getContents[h.editors[1]];
IF fName = NIL OR fName.Length = 0 OR fName.IsEmpty[] THEN {
fName ¬ NIL;
h.report[h, "Invalid file name!\n"];
};
};
Put: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
fName: Rope.ROPE ¬ GetSubmitFileName[h];
IF fName # NIL THEN
[] ¬ AdobeIO.WriteProc[h, PFS.StreamOpen[PFS.PathFromRope[fName], write]];
};
Get: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
fName: Rope.ROPE ¬ GetSubmitFileName[h];
{
ENABLE PFS.Error => {
h.report[h, "Invalid file name!\n"];
GOTO badFile;
};
IF fName # NIL THEN
AdobeIO.ReadProc[0, h, PFS.StreamOpen[PFS.PathFromRope[fName], read], FALSE];
EXITS
badFile => {};
};
};
Submit: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
num: CARD ¬ 0;
arField: CARD ¬ 0;
fIV: AdobeP75V2.FieldItemValue;
r: Rope.ROPE ¬ NIL;
done: BOOL ¬ FALSE;
{
ENABLE UNWIND => {
h.report[h, "submit failed.\n"];
XNSAdobeClientOps.SubmitFailed[h.systemHandle.service, AccessCH.NSNameFromRope[h.systemName].local, h.systemHandle.version, num];
AdobeTool.EnableUserEdits[h];
};
IF BusyTest[h] THEN RETURN;
h.report[h, "Submitting . . . "];
AdobeTool.DisableUserEdits[h];
{
DoProc: PROC [h:AdobeUI.Handle] ~ {
num ¬ XNSAdobeClientOps.GetNextSubmitNumber[h.systemHandle.service, AccessCH.NSNameFromRope[h.systemName].local];
FOR i: CARD IN [0..h.fieldViewer.buttons.length) DO
IF h.fieldViewer.buttons[i].type = arId THEN {
arField ¬ i;
EXIT;
};
ENDLOOP;
h.setContents[h.fieldViewer.buttons[arField].controllerOf, Convert.RopeFromCard[num, 10, FALSE]];
h.currentAR ¬ num;
};
XNSAdobeClientOps.AboutToStore[h.systemHandle.service, AccessCH.NSNameFromRope[h.systemName].local, h.systemHandle.version, num];
IF ~AdobeIO.WriteProc[h, NIL, DoProc] THEN {
h.report[h, "submit failed.\n"];
XNSAdobeClientOps.SubmitFailed[h.systemHandle.service, AccessCH.NSNameFromRope[h.systemName].local, h.systemHandle.version, num];
}
ELSE {
h.report[h, "Updating Accelerators . . . "];
FOR i: CARD IN [0..h.fieldViewer.buttons.length) DO
done ¬ FALSE;
r ¬ h.getContents[h.fieldViewer.buttons[i].controllerOf];
fIV ¬ NIL;
SELECT h.fieldViewer.buttons[i].type FROM
arId =>
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.arId ¬ [arId[Convert.CardFromRope[r]]]];
dateTime =>
IF r = NIL OR r.Length = 0 OR r.IsEmpty[] THEN
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.dateTime ¬ [dateTime[BasicTime.nullGMT]]]
ELSE
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.dateTime ¬ [dateTime[Convert.TimeFromRope[r]]]];
numeric =>
IF r = NIL OR r.Length = 0 OR r.IsEmpty[] THEN
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.numeric ¬ [numeric[0]]]
ELSE
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.numeric ¬ [numeric[Convert.CardFromRope[r]]]];
fixedLengthString =>
IF r = NIL OR r.Length = 0 OR r.IsEmpty[] THEN
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.fixedLengthString ¬ [fixedLengthString[NIL, h.fieldViewer.buttons[i].maxLength]]]
ELSE
fIV ¬ NEW [AdobeP75V2.FieldItemValueRec.fixedLengthString ¬ [fixedLengthString[r, h.fieldViewer.buttons[i].maxLength]]];
enumerated => {
evalNum: CARD ¬ 0;
r: Rope.ROPE ¬ Rope.Substr[h.getBoxName[h.fieldViewer.buttons[i].button], 0, h.getBoxName[h.fieldViewer.buttons[i].button].Length - 2];
cO: Rope.ROPE ¬ h.getContents[h.fieldViewer.buttons[i].controllerOf];
cO ¬ Rope.Substr[cO, 1, cO.Length - 2];
FOR j: CARD IN [0..h.systemHandle.fieldList.length) DO
IF Rope.Equal[h.systemHandle.fieldList[j].name, r] THEN {
WITH h.systemHandle.fieldList[j] SELECT FROM
it: REF AdobeP75V2.FieldItemObjectRec.enumerated => {
FOR k: CARD IN [0..it.possibilities.length) DO
FOR l: CARD IN [0..it.possibilities[k].enumRecs.length) DO
IF Rope.Equal[it.possibilities[k].enumRecs[l].tag, cO] THEN {
fIV ¬ NEW[AdobeP75V2.FieldItemValueRec.enumerated ¬ [enumerated[it.possibilities[k].enumRecs[l].item]]];
done ¬ TRUE;
};
IF done THEN EXIT;
ENDLOOP;
IF done THEN EXIT;
ENDLOOP;
};
ENDCASE => ERROR;
EXIT;
};
ENDLOOP;
IF ~done THEN
fIV ¬ NEW[AdobeP75V2.FieldItemValueRec.enumerated ¬ [enumerated[LAST[CARD16]]]];
};
string => {};
ENDCASE => ERROR;
IF fIV # NIL THEN
XNSAdobeClientOps.UpdateAcceleratorField[h.systemHandle.service, AccessCH.NSNameFromRope[h.systemName].local, h.systemHandle.version, num, fIV, Rope.Substr[h.getBoxName[h.fieldViewer.buttons[i].button], 0, h.getBoxName[h.fieldViewer.buttons[i].button].Length-2]];
ENDLOOP;
};
AdobeTool.EnableUserEdits[h];
h.report[h, "Done.\n"]
};
};
};
GetUserFile: PROCEDURE [h: AdobeUI.Handle] ~ {
currentToolRope, currentFieldRope, currentFieldData: Rope.ROPE ¬ NIL;
currentTool: AdobeOps.ToolType;
currentField: CARD;
c1, c2: CHAR;
AdobeCommon.SetFSWOrderAndDefaultFromUserFile[
systemName: h.systemName,
arSH: h.systemHandle,
server: h.systemHandle.host];
};
ChangeSystem: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
h2: AdobeUI.Handle ¬ h;
systemField: Rope.ROPE ¬ NIL;
tmpSys: AdobeOps.ARSystemHandle ¬ h.systemHandle;
IF h.isBusy THEN {
h.report[h, "Adobe is busy, cannot switch systems! \n"];
RETURN;
};
h.isBusy ¬ TRUE;
h.report[h, "Changing System ... "];
systemField ¬ h.systemName;
h.system ¬ AdobeCommon.LocateSystemInKnownSystems[systemField, h.knownSystems ! AdobeCommonInternal.SystemNotFound => {AdobeCommon.AddSystemToKnownSystems[systemField, h.knownSystems];
RETRY}];
IF h.system = LAST[CARD] THEN {h.oldsystem ¬ h.system; h.isBusy ¬ FALSE; RETURN};
h.systemHandle ¬ AdobeCommon.FindSystem[NIL, h, h.knownSystems.system[h.system], FALSE !
CrRPC.Error => { h2.systemHandle ¬ NIL; h2.report[h2, "Adobe Server is down.\n"]; CONTINUE};
AdobeCommonInternal.SystemNotFound => {
AdobeCommon.RemoveSystemFromKnownSystems[system, h.knownSystems];
h.systemHandle ¬ tmpSys;
h.system ¬ h.oldsystem;
h.isBusy ¬ FALSE;
GOTO badsys;
};
];
IF h.systemHandle = NIL THEN {
h.systemHandle ¬ tmpSys;
h.isBusy ¬ FALSE;
h.system¬ h.oldsystem;
RETURN
};
IF h.systemHandle = tmpSys THEN {
h.report[h, "System selected is same as current system, no change made.\n"];
h.isBusy ¬ FALSE;
RETURN
}
ELSE {
AdobeTool.ClearWindow[h];
AdobeTool.SetUpWindow[h];
GetUserFile[h];
h.report[h, "Done.\n"];
h.oldsystem ¬ h.system;
};
h.isBusy ¬ FALSE;
EXITS
badsys => RETURN;
};
formatFormsList: LIST OF Rope.ROPE ¬ LIST["plain", "columns", "template"];
RopeFromFormat: PROCEDURE [format: AdobeCommon.FormatType] RETURNS [rope: Rope.ROPE ¬ NIL] = {
SELECT format FROM
plain => {RETURN ["{plain}"] };
columns => {RETURN ["{columns}"] };
template => {RETURN ["{template}"] };
ENDCASE;
};
OutputFormat: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[h.instanceData];
WITH instanceData SELECT FROM
id: REF AdobeCommonInternal.InstanceData.report => {
ft: AdobeCommon.FormatType ¬ plain;
which:INT;
which ¬ h.popUpRequest["Output Format", formatFormsList];
SELECT which FROM
<= 0 => RETURN; --nothing selected
1 => ft ¬ plain;
2 => ft ¬ columns;
3 => ft ¬ template;
ENDCASE => {
h.report[h, "Don't really know what you did.\n"];
RETURN;
};
IF ft # id.format THEN {
theButton: Buttons.Button ← ViewerOps.FindViewer[RopeFromFormat[handle.oldOutputFormat]];
theButton: Buttons.Button ← handle.lastButton;
WHILE (theButton # NIL) AND (theButton.name # RopeFromFormat[id.format]) DO
theButton ← theButton.sibling;
ENDLOOP;
IF h.formatButton # NIL THEN {
h.reLabelBox[h.formatButton, RopeFromFormat[ft]];
Buttons.ReLabel[h.formatButton, RopeFromFormat[ft]];
id.format ¬ ft;
}
ELSE RETURN
};
}
ENDCASE;
};
SystemMenu: PUBLIC PROC [h: AdobeUI.Handle] = {
newSystemName, oldSys, newSys: Rope.ROPE ¬ NIL;
sysNum, oldSysNum: CARD;
{
ENABLE UNWIND => NULL;
which: INT ¬ 0;
oldSystemMenuEntry: REF ANY ¬ h.systemMenuItem;
sysList: LIST OF Rope.ROPE ¬ LIST["Current Selection"];
FOR i: CARD IN [0..h.knownSystems.next) DO
sysList ¬ CONS[h.knownSystems.system[h.knownSystems.next - i - 1], sysList];
ENDLOOP;
which ¬ h.popUpRequest["System", sysList];
oldSysNum ¬ h.oldsystem;
sysNum ¬ h.system;
SELECT which FROM
<= 0 => RETURN; --nothing selected
ENDCASE =>
sysNum ¬ which - 1;
IF sysNum = h.knownSystems.next THEN {
newSystemName: Rope.ROPE ¬ h.getSelectionContents[h.outer];
sysNum ¬ LAST[CARD];
sysNum ¬ AdobeCommon.LocateSystemInKnownSystems[newSystemName, h.knownSystems ! AdobeCommonInternal.SystemNotFound => {
AdobeCommon.AddSystemToKnownSystems[newSystemName, h.knownSystems];
RETRY}];
};
IF oldSysNum # LAST[CARDINAL] THEN
oldSys ¬ h.knownSystems.system[oldSysNum];
IF sysNum # LAST[CARDINAL] THEN
newSys ¬ h.knownSystems.system[sysNum];
oldSystemMenuEntry ← Menus.FindEntry[
menu: handle.menu,
entryName: oldSys];
IF oldSystemMenuEntry # NIL THEN {
newMenuEntry: AdobeCommon.Box ¬ h.newMenuEntry[newSys];
h.systemName ¬ newSys;
h.replaceMenuEntry[h, h.menu, oldSystemMenuEntry, newMenuEntry];
oldSysNum ¬ sysNum;
h.paintBox[h.outer, $menu];
}
ELSE {
h.report[h, "Didn't find old Menu Entry!\n"];
sysNum ¬ oldSysNum;
}
};
};
toolFormsList: LIST OF Rope.ROPE ¬ LIST["Edit", "Submit", "Report", "Query", "Sort", "QueryList"];
ListAction: PUBLIC PROCEDURE [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] ~ {[] ¬ HandleField[h, 4, mouseButton]};
ToolMenu: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
which:INT;
IF BusyTest[h] THEN RETURN;
IF h.currentARState = CheckedOut THEN {
h.report[h, "Do a CheckIn first.\n"];
RETURN;
};
IF h.systemHandle = NIL THEN {
h.report[h, "Select a system first.\n"];
RETURN;
};
which ¬ h.popUpRequest["Tools", toolFormsList];
SELECT which FROM
<= 0 => RETURN; --nothing selected
1 => {
h.tool ¬ edit;
};
2 => {
h.tool ¬ submit;
};
3 => {
h.tool ¬ report;
};
4 => {
h.tool ¬ query;
};
5 => {
h.tool ¬ sort;
};
6 => {
h.tool ¬ queryList;
};
ENDCASE => {
h.report[h, "Don't really know what you did.\n"];
RETURN;
};
IF (h.tool # h.oldtool) THEN {
oldToolMenuEntry: REF ANY ¬ h.findMenuEntry[h: h, entryName: Rope.Concat["{", Rope.Concat[RopeFromTool[h.oldtool], "}"]]];
oldToolMenuEntry: Menus.MenuEntry ← Menus.FindEntry[
menu: MenuFromAny[handle.menu],
entryName: Rope.Concat["{", Rope.Concat[RopeFromTool[handle.oldtool], "}"]]
];
IF oldToolMenuEntry # NIL THEN {
newToolMenuEntry: REF ANY ¬ h.newMenuEntry[
entryName: Rope.Concat["{", Rope.Concat[RopeFromTool[h.tool], "}"]]];
newToolMenuEntry: Menus.MenuEntry ← Menus.CreateEntry[
name: Rope.Concat["{", Rope.Concat[RopeFromTool[handle.tool], "}"]],
proc: DeadProc
];
h.replaceMenuEntry[
h: h,
menu: h.menu,
oldEntry: oldToolMenuEntry,
newEntry: newToolMenuEntry];
Menus.ReplaceMenuEntry[
menu: MenuFromAny[handle.menu],
oldEntry: oldToolMenuEntry,
newEntry: newToolMenuEntry];
AdobeTool.ClearWindow[h];
h.oldtool ¬ h.tool;
h.addButtons[h];
SELECT h.tool FROM
query => h.instanceData ¬ NEW[AdobeCommonInternal.InstanceData.query];
edit => h.instanceData ¬ NEW[AdobeCommonInternal.InstanceData.edit];
submit => h.instanceData ¬ NEW[AdobeCommonInternal.InstanceData.submit];
report => {
idh: AdobeCommonInternal.InstanceDataHandle;
h.instanceData ¬ NEW[AdobeCommonInternal.InstanceData.report];
idh ¬ NARROW[h.instanceData];
WITH idh SELECT FROM
id: REF AdobeCommonInternal.InstanceData.report => {
id.entryBytes ¬ NEW[AdobeCommonInternal.EntryBytesType ¬ [0]];
id.rowBuffer ¬ NEW[AdobeCommon.RowBufferRec ¬ [NIL, NIL]];
};
ENDCASE;
};
sort => h.instanceData ¬ NEW[AdobeCommonInternal.InstanceData.sort];
queryList => h.instanceData ¬ NEW[AdobeCommonInternal.InstanceData.queryList];
ENDCASE;
AdobeTool.SetUpWindow[h];
h.paintBox[h.outer, $menu];
h.setIcon[h, $normal];
h.paintBox[h.outer, $all];
}
ELSE h.tool ¬ h.oldtool;
};
};
QLOperandProc: PUBLIC PROCEDURE [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton, which: CARD, title: Rope.ROPE] = {
ENABLE UNWIND => NULL;
selections: LIST OF Rope.ROPE ¬ NIL;
choice: INT;
sel: ViewerTools.SelPos ¬ NIL;
FOR q: AdobeOps.QLHandle ¬ h.systemHandle.otherQLs, q.next UNTIL q = NIL DO
selections ¬ CONS[q.qL.name, selections];
ENDLOOP;
selections ¬ CONS["filename", selections];
selections ¬ CONS["List", selections];
selections ¬ CONS["SysQL", selections];
choice ¬ HandleField[h, which, mouseButton, title, selections];
IF choice > 0 THEN {
choice ¬ choice - 1;
WHILE choice > 0 DO
selections ¬ selections.rest;
choice ¬ choice - 1;
ENDLOOP;
h.setContents[h.editors[which], selections.first];
sel ¬ NEW[ViewerTools.SelPosRec ¬ [selections.first.Length + 1, 0, FALSE, after]];
h.setSelection[h.editors[which], sel];
};
};
CurrentButton: PUBLIC PROC [data: AdobeTool.CurrentButtonProcData, parent: AdobeCommon.Box] = {
ENABLE UNWIND => NULL;
which: INT ¬ 0;
handle: AdobeCommon.EnumeratedTypes ¬ data.e;
index: CARDINAL ¬ 0;
IF handle.dependentOn # NIL THEN {
handle.currentMenu ¬ handle.dependentOn.currentSelection;
};
IF handle.currentMenu >= handle.allSelections.length THEN {
sels: LIST OF Rope.ROPE ¬ CONS["Nil", NIL];
which ¬ data.h.popUpRequest[data.h.getBoxName[parent], sels];
}
ELSE {
which ¬ data.h.popUpRequest[data.h.getBoxName[parent], handle.allSelections[handle.currentMenu].ropes];
IF handle.boolVal = TRUE THEN RETURN;
SELECT which FROM
<= 0 => RETURN;
ENDCASE => AdobeTool.SetEnumValue[data.h, handle, which-1];
};
};
CheckField: PUBLIC PROC [enumData: AdobeCommon.EnumeratedTypes] = {
windowData: AdobeUI.Handle ¬ enumData.mainViewer;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[windowData.instanceData];
WITH instanceData SELECT FROM
toolData: REF AdobeCommonInternal.InstanceData.report => {
IF toolData.fieldsInReport[enumData.fieldNum] THEN {
the field is already on
windowData.setDisplayStyle[enumData.button, $BlackOnWhite];
toolData.fieldsInReport[enumData.fieldNum] ¬ FALSE;
RETURN;
}
ELSE {
the field is now turned on
toolData.fieldsInReport[enumData.fieldNum] ¬ TRUE;
windowData.setDisplayStyle[enumData.button, $WhiteOnBlack];
WITH windowData.systemHandle.fieldList[enumData.fieldNum] SELECT FROM
fli: AdobeOps.StrFIO => {
AdobeCommon.PostMessage[windowData, FALSE, "A report with "];
AdobeCommon.PostMessage[windowData, FALSE, fli.name];
AdobeCommon.PostMessage[windowData, TRUE, " wouldn't use accelerator files!"]};
ENDCASE};
};
ENDCASE};
GetValueFromEnum: PROC [bh: AdobeCommon.EnumeratedTypes] RETURNS [v: CARD ¬ LAST[CARD]]~ {
index: CARD ¬ 0;
valInField: Rope.ROPE ¬ bh.mainViewer.getContents[bh.controllerOf];
FOR sels: LIST OF Rope.ROPE ¬ bh.allSelections[bh.currentMenu].ropes, sels.rest UNTIL sels = NIL DO
IF Rope.Equal[valInField, sels.first, FALSE] THEN
RETURN[index]
ELSE index ¬ index + 1;
ENDLOOP;
RETURN[LAST[CARD]];
};
HintMenu: PUBLIC PROCEDURE [buttonData: AdobeCommon.EnumeratedTypes, mouseButton: ViewerClasses.MouseButton] =
{
ropeToPutIn: Rope.ROPE ¬ NIL;
count: INT ¬ 0;
data: AdobeCommon.Handle ¬ buttonData.mainViewer;
arSH: AdobeOps.ARSystemHandle ¬ data.systemHandle;
fL: AdobeOps.FieldList ¬ data.systemHandle.fieldList;
--flIndex: CARDINAL ¬ arSH.formSWOrderArray[data.tool][index];
enumValue, i: CARDINAL;
enumStrings, relStrings, hintSeqList: LIST OF Rope.ROPE ¬ NIL;
hintSeq: REF AdobeCommon.StringArray;
which: INT ¬ 0;
SELECT mouseButton FROM
red => {
data.setSelection[buttonData.controllerOf];
RETURN
};
blue => {
data.setContents[buttonData.controllerOf, ""];
data.setSelection[buttonData.controllerOf];
RETURN
};
ENDCASE;
SELECT buttonData.type FROM
arId => hintSeq ¬ AdobeTool.GetValidRelations[arId];
dateTime => hintSeq ¬ AdobeTool.GetValidRelations[dateTime];
numeric => hintSeq ¬ AdobeTool.GetValidRelations[numeric];
fixedLengthString => hintSeq ¬ AdobeTool.GetValidRelations[fixedLengthString];
enumerated => {
IF fItem.field # AdobeOps.nullDependsOnIndex THEN
IF buttonData.dependentOn # NIL THEN {
enumValue ¬ GetValueFromEnum[buttonData.dependentOn];
buttonData.currentMenu ¬ enumValue;
};
enumStrings ¬ AdobeTool.GetPossibilities[buttonData];
hintSeq ¬ AdobeTool.GetValidRelations[enumerated];
hintSeq ← NEW[AdobeCommon.StringArray[enumStrings.length + relStrings.length]];
FOR i IN [0..enumStrings.length) DO
hintSeq[i] ← enumStrings[i].string;
ENDLOOP;
FOR i IN [0..relStrings.length) DO
hintSeq[i + enumStrings.length] ← relStrings[i]; ENDLOOP
};
ENDCASE;
FOR i IN [0..hintSeq.length) DO
relStrings ¬ CONS[hintSeq[hintSeq.length-i-1], relStrings];
ENDLOOP;
FOR i: LIST OF Rope.ROPE ¬ enumStrings, i.rest UNTIL i = NIL DO
count ¬ count + 1;
ENDLOOP;
hintSeq ¬ NEW[AdobeCommon.StringArray[count]];
FOR i: LIST OF Rope.ROPE ¬ enumStrings, i.rest UNTIL i = NIL DO
count ¬ count - 1;
hintSeq[count] ¬ i.first;
ENDLOOP;
FOR i: CARD IN [0..hintSeq.length) DO
relStrings ¬ CONS[hintSeq[i], relStrings];
ENDLOOP;
which ¬ data.popUpRequest[data.getBoxName[buttonData.button], relStrings];
IF which > 0 THEN {
sel: ViewerTools.SelPos ¬ NIL;
count ¬ 1;
ropeToPutIn ¬ "Total confusion.";
FOR i: LIST OF Rope.ROPE ¬ relStrings, i.rest UNTIL i = NIL DO
IF count = which THEN
ropeToPutIn ¬ i.first;
count ¬ count + 1;
ENDLOOP;
data.setContents[
buttonData.controllerOf,
Rope.Concat[data.getContents[buttonData.controllerOf], ropeToPutIn]];
sel ¬ NEW[ViewerTools.SelPosRec ¬ [data.getContents[buttonData.controllerOf].Length + 1, 0, FALSE, after]];
data.setSelection[buttonData.controllerOf, sel];
};
hints ← DESCRIPTOR[hintSeq];
replace ← FALSE;
};
SubmitFieldButton: PUBLIC PROCEDURE [data: AdobeTool.CurrentButtonProcData, mouseButton: ViewerClasses.MouseButton] ~ {
buttonH: AdobeCommon.EnumeratedTypes ¬ data.e;
IF ~buttonH.boolVal THEN {
SELECT mouseButton FROM
red, yellow => data.h.setSelection[buttonH.controllerOf];
blue => {
data.h.setContents[buttonH.controllerOf, ""];
data.h.setSelection[buttonH.controllerOf];
};
ENDCASE;
};
};
ResetQL: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
ql: AdobeOps.QueryList ¬ NIL;
ql ¬ AdobeCommon.FindThisQL[h.getContents[h.editors[1]], h];
IF ql # NIL THEN ql.list ¬ NIL;
};
NumberEquals: PUBLIC PROC [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] = {
ENABLE UNWIND => NULL;
[] ¬ HandleField[h, 1, mouseButton];
};
EditFilename: PUBLIC PROC [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] = {
ENABLE UNWIND => NULL;
[] ¬ HandleField[h, 2, mouseButton];
};
ReportOutputFile: PUBLIC PROC [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] = {
ENABLE UNWIND => NULL;
[] ¬ HandleField[h, 1, mouseButton];
};
ReportTemplateFile: PUBLIC PROC [h: AdobeUI.Handle, mouseButton: ViewerClasses.MouseButton] = {
ENABLE UNWIND => NULL;
[] ¬ HandleField[h, 2, mouseButton];
};
ShowElements: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
ql: AdobeOps.QueryList ¬ NIL;
pastFirst: BOOL ¬ FALSE;
ql ¬ AdobeCommon.FindThisQL[h.getContents[h.editors[1]], h];
IF ql = NIL OR ql.list = NIL THEN {
AdobeCommon.PostMessage[h, TRUE, "Empty QueryList!"];
RETURN;
};
AdobeCommon.PostMessage[h, FALSE, "Query Elements for "];
AdobeCommon.PostMessage[h, FALSE, ql.name];
AdobeCommon.PostMessage[h, FALSE, ": "];
FOR i: CARD IN [0..ql.list.len) DO
FOR j: AdobeOps.ARNumber IN [ql.list.body[i].startValue..ql.list.body[i].startValue + ql.list.body[i].runLength) DO
IF pastFirst THEN
AdobeCommon.PostMessage[h, FALSE, ", "]
ELSE
pastFirst ¬ TRUE;
AdobeCommon.PostNumber[h, FALSE, j];
ENDLOOP;
ENDLOOP;
AdobeCommon.PostMessage[h, TRUE, "."];
};
Overwrite: PUBLIC PROCEDURE [h: AdobeUI.Handle] = {
ENABLE UNWIND => NULL;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[h.instanceData];
WITH instanceData SELECT FROM
id: REF AdobeCommonInternal.InstanceData.report =>
SELECT id.overwrite FROM
TRUE => {
id.overwrite ¬ FALSE;
h.setDisplayStyle[h.overwriteButton, $BlackOnWhite];
};
FALSE => {
id.overwrite ¬ TRUE;
h.setDisplayStyle[h.overwriteButton, $WhiteOnBlack];
};
ENDCASE => ERROR;
ENDCASE;
};
RopeFromTool: PUBLIC 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;
};
GetNumber: PUBLIC PROCEDURE [h: AdobeUI.Handle] RETURNS [CARDINAL ¬ LAST[CARDINAL]] = {
ENABLE UNWIND => NULL;
RETURN[
Convert.CardFromRope[
h.getContents[h.editors[1]] ! Convert.Error => GOTO IOError]
];
EXITS
IOError => {
h.report[h, "Please enter a positive number in the Number= field.\n"];
h.setSelection[h.editors[1]]
};
};
}.