(FILECREATED "17-Oct-86 15:08:15" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH123.;2 17005 changes to: (FNS NC.SeverAllLinks NC.DeleteNoteCards NC.SmartDeleteLinks NC.QuitWithoutSaving NC.FileBoxCollectChildren) (VARS RHTPATCH123COMS) previous date: "16-Oct-86 18:46:50" {QV}<NOTECARDS>1.3K>NEXT>RHTPATCH123.;1) (* Copyright (c) 1986 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT RHTPATCH123COMS) (RPAQQ RHTPATCH123COMS ((* * Fix to bug #193: Quit w/o saving on card that's never been saved to notefile should do a delete.) (* * Change to NCCARDS) (FNS NC.QuitWithoutSaving) (* * Change to NCDATABASE) (FNS NC.GetNoteCard) (* * Change to NCLINKS) (FNS NC.SmartDeleteLinks) (* * Change to NCFILEBOXCARD) (FNS NC.FileBoxCollectChildren))) (* * Fix to bug #193: Quit w/o saving on card that's never been saved to notefile should do a delete.) (* * Change to NCCARDS) (DEFINEQ (NC.QuitWithoutSaving (LAMBDA (CardIdentifier) (* rht: "17-Oct-86 12:56") (* Quit from a note card without saving its contents on the database. But must make sure that any updates that would have been done to this card even if it had been on the database are carried out on the old image currently on the database) (* * rht 2/1/85: Now only writes out links if it has to. Also resets dirty flags and calls normal quit procedure. I think we've still got possible problems with recently changed titles, both ours and those of cards we point to.) (* * rht 2/3/85: Now handles title changes properly. Also fixed so that changes to from links will force links to be written.) (* * rht 2/9/85: Now accepts IDs as arg.) (* * fgh 11/12/85: Updated to handle Card objects. Removed DatabaseStream argument.) (* * fgh 6/4/86 No longer asks for confirmation if no changes have been made.) (* * kef 8/7/86: Now compares ToLinks by NC.SameUIDP rather than EQ. Situation comes up in Server, when the same UIDs may not be EQ. Also, now obtains write lock on FROMLINKS before deleting FROMLINKS on the DestinationCard of a changed FROMLINK.) (* * fgh 8/30/86 Converted to use NC.WithWrotePermission macro.) (* * rht 10/16/86: Changed NC.ProtectedCardOperation wrapper placement so that card deletion could still happen for new cards.) (LET (Window Card NewFromLinks ToLinks DeletedLinks Process TextObj MadeNewLinksP ChangedFromLinksP OldFromLinks OldToLinks OperationInProgress) (SETQ Card (NC.CoerceToCard CardIdentifier)) (SETQ Window (NC.FetchWindow Card)) (if (SETQ OperationInProgress (NC.OperationInProgress Card)) then (* * Another interaction operation is in progress on this card and we have to interact with the user. Can't do.) (NC.PrintOperationInProgressMsg Window "Close w/o Saving" OperationInProgress) else (SETQ NewFromLinks (NC.FetchFromLinks Card)) (SETQ ToLinks (NC.FetchToLinks Card)) (if (OR (NULL (OR (NC.CardDirtyP Card) (NC.FetchLinksDirtyFlg Card) (NC.FetchTitleDirtyFlg Card) (NC.FetchPropListDirtyFlg Card))) (NC.AskYesOrNo "Are you sure you want to flush your changes?" " -- " "Yes" T Window NIL NIL)) then (* * EIther no changes have been made or the user has confirmed.) (if (EQ (fetch (Card Status) of Card) (QUOTE ACTIVE)) then (NC.ProtectedCardOperation Card Close% wo% Saving (* Read old card parts off notefile.) (NC.GetNoteCard Card) (* If from links have changed then we'll have to write the new ones out.) (SETQ OldFromLinks (NC.FetchFromLinks Card)) (if (NOT (NC.SameLinksP NewFromLinks OldFromLinks)) then (NC.SetFromLinks Card NewFromLinks) (SETQ ChangedFromLinksP T)) (* Delete the back links from all links that are not in the old to link set.) (SETQ OldToLinks (NC.FetchToLinks Card)) (for ToLink in ToLinks unless (for Link in OldToLinks eachtime (BLOCK) thereis (NC.SameLinkP Link ToLink)) do (LET ((DestinationCard (fetch (Link DestinationCard) of ToLink))) (* Grab the writelock on the FROMLINKS before trying to write out the change.) (NC.WithWritePermission DestinationCard (QUOTE FROMLINKS) (NC.DelFromLink ToLink) (SETQ MadeNewLinksP T)))) (* Check to make sure none of the old To links point to a deleted card. If so, replace with a deleted marker.) (SETQ DeletedLinks (bind DestinationCard for Link in OldToLinks eachtime (BLOCK) when (PROGN (SETQ DestinationCard (fetch (Link DestinationCard) of Link)) (AND (NOT (NC.ActiveCardP DestinationCard)) (EQ (QUOTE DELETED) (NC.FetchStatus DestinationCard)))) collect (NC.DelReferencesToCard Card DestinationCard) Link)) (NC.SetToLinks Card (LDIFFERENCE OldToLinks DeletedLinks)) (* Mark links dirty if we had to delete any to links or if the from links changed.) (NC.SetLinksDirtyFlg Card (OR DeletedLinks ChangedFromLinksP)) (* Mark the substance dirty if had to delete any to links.) (if DeletedLinks then (NC.MarkCardDirty Card) else (NC.MarkCardDirty Card (QUOTE RESET))) (NC.SetPropListDirtyFlg Card NIL) (if (NC.FetchTitleDirtyFlg Card) then (* If we've changed title and any of the cards pointing to this one are up on the screen, then we need to update their images.) (for FromLink in OldFromLinks bind SourceCard eachtime (BLOCK) when (AND (NC.ActiveCardP (SETQ SourceCard (fetch (Link SourceCard) of FromLink))) (WINDOWP (NC.FetchWindow SourceCard))) do (NC.UpdateLinkImages SourceCard Card)) (NC.SetTitleDirtyFlg Card NIL))) (NC.QuitCard Card T NIL NIL T) else (* If the card has never been written to the database quit w/o saving is equivalent to deleting the card.) (NC.PrintMsg Window T "This card has never been saved." (CHARACTER 13) "It will be deleted from the database." (CHARACTER 13)) (NC.DeleteNoteCards Card NIL T))))))) ) (* * Change to NCDATABASE) (DEFINEQ (NC.GetNoteCard (LAMBDA (Card) (* rht: "16-Oct-86 18:07") (* * Get a note card from the database.) (* * kirk 27Nov85 Changed to call NC.GetMainCardData) (* * rht 10/16/86: Now checks that card is active before doing Get.) (if (EQ (fetch (Card Status) of Card) (QUOTE ACTIVE)) then (WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card)) (PROGN (NC.GetMainCardData Card) (NC.GetLinks Card) (NC.GetTitle Card) (NC.GetPropList Card) (NC.ActivateCard Card) Card))))) ) (* * Change to NCLINKS) (DEFINEQ (NC.SmartDeleteLinks (LAMBDA (ListOfLinks QuietFlg InterestedWindow Don'tPutToBeDeletedCardsFlg) (* rht: "17-Oct-86 11:51") (* * Delete a bunch of links efficiently. Sort so that links with same source bunch together. This way, only read and write each source card once. If a card has the AboutToBeDeletedFlg UID prop set and Don'tPutToBeDeletedCardsFlg is non-nil, then don't put it down to the file even if changes were made. Just throw away its cache.) (* * rht 10/17/86: Now passes non-nil NoOrphanHookFlg to NC.DeleteLink unless destination card is marked as about to be deleted.) (LET (DestCardsw/oLinksCached NumLinksToDelete) (* * For each destination card, make sure its links are cached. At the same time, collect these cards for future uncaching.) (SETQ DestCardsw/oLinksCached (for Link in ListOfLinks bind DestCard when (NOT (NC.LinksCachedP (SETQ DestCard (fetch (Link DestinationCard) of Link)))) collect (NC.GetLinks DestCard) DestCard)) (* * Sort the List of links so that links with same source cards bunch together.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Sorting " (SETQ NumLinksToDelete (LENGTH ListOfLinks)) " links prior to deletion.")) (SORT ListOfLinks (FUNCTION (LAMBDA (Link1 Link2) (LESSP (fetch (Card IndexLoc) of (fetch (Link SourceCard) of Link1)) (fetch (Card IndexLoc) of (fetch (Link SourceCard) of Link2))))) ) (* * Now bring up source cards one at a time and do the delete of the links.) (OR QuietFlg (NC.PrintMsg InterestedWindow T "Deleting links: 1 out of " NumLinksToDelete " ...")) (for Link in ListOfLinks as i from 1 bind PreviousSourceCard WasNotActiveFlg SavedFromLinks HadLinksCachedFlg eachtime (BLOCK) do (OR QuietFlg (if (ZEROP (REMAINDER i 10)) then (NC.PrintMsg InterestedWindow T "Deleting links: " i " out of " NumLinksToDelete " ..."))) (LET ((SourceCard (fetch (Link SourceCard) of Link))) (if (NOT (NC.SameCardP SourceCard PreviousSourceCard)) then (* Write down changes to previous card's substance.) (if WasNotActiveFlg then (* Have to call NC.CardSaveFn first and then NC.QuitCard with Don'tSaveFlg to avoid insureProperFiling check.) (if (AND Don'tPutToBeDeletedCardsFlg (NC.UIDGetProp (fetch (Card UID) of PreviousSourceCard) (QUOTE AboutToBeDeletedFlg))) then (* Throw away cache if card about to be deleted.) (NC.DeactivateCard PreviousSourceCard) else (NC.CardSaveFn PreviousSourceCard T) (NC.QuitCard PreviousSourceCard NIL T NIL NIL NIL NIL T)) (* Recache links for previous card if they were cached before.) (if HadLinksCachedFlg then (NC.GetLinks PreviousSourceCard))) (* Cache card and overwrite from links with previously cached ones.) (if (SETQ WasNotActiveFlg (NOT (NC.ActiveCardP SourceCard))) then (* Save cached from links for this card.) (SETQ SavedFromLinks (if (SETQ HadLinksCachedFlg (NC.LinksCachedP SourceCard)) then (NC.FetchFromLinks SourceCard))) (NC.GetNoteCard SourceCard) (if HadLinksCachedFlg then (NC.SetFromLinks SourceCard SavedFromLinks))) ) (NC.DeleteLink Link (NC.UIDGetProp (fetch (Card UID) of (fetch (Link DestinationCard) of Link)) (QUOTE AboutToBeDeletedFlg))) (SETQ PreviousSourceCard SourceCard)) finally (if WasNotActiveFlg then (* Have to call NC.CardSaveFn first and then NC.QuitCard with Don'tSaveFlg to avoid insureProperFiling check.) (if (AND Don'tPutToBeDeletedCardsFlg (NC.UIDGetProp (fetch (Card UID) of PreviousSourceCard) (QUOTE AboutToBeDeletedFlg))) then (* Throw away cache if card about to be deleted.) (NC.DeactivateCard PreviousSourceCard) else (NC.CardSaveFn PreviousSourceCard T) (NC.QuitCard PreviousSourceCard NIL T NIL NIL NIL NIL T)) (* Recache links for previous card if they were cached before.) (if HadLinksCachedFlg then (NC.GetLinks PreviousSourceCard)))) (* * Finally, write down links for cards whose links have changed and whose links weren't cached when this function was called.) (for DestCard in DestCardsw/oLinksCached eachtime (BLOCK) when ( NC.FetchLinksDirtyFlg DestCard) do (NC.PutLinks DestCard)) (OR QuietFlg (NC.ClearMsg InterestedWindow T))))) ) (* * Change to NCFILEBOXCARD) (DEFINEQ (NC.FileBoxCollectChildren (LAMBDA (WindowOrTextStream Card NewChildren NoDisplayFlg) (* rht: "17-Oct-86 15:03") (* * Ask user for new children (either cards or fileboxes) for this filebox. Check to make sure that no circularities are introduced. This code is sort of the inverse of the NC.AddParents code and thus looks quite similar.) (* * rht 10/29/84: Added NoDisplayFlg to prevent error message when no appropriate elements exist. Also now returns ID if at least one child was added, NIL otherwise.) (* * fgh 11/13/85 Updated to handle Card object.) (* * rht 7/5/86: Now checks for readonly cards.) (* * rht 8/11/86: Added code to check to make sure that another operation is not in progress on this card when this fn is called.) (* * rht 10/17/86: Made successful filing operations NOT do dismiss.) (OR Card (SETQ Card (NC.CoerceToCard WindowOrTextStream))) (LET ((Window (NC.FetchWindow Card)) OperationInProgress) (if (NC.CheckForNotReadOnly Card Window "Can't do filing in ") then (if (SETQ OperationInProgress (NC.OperationInProgress Card)) then (* * Another interaction operation is in progress on this card and we have to interact with the user. Can't do.) (NC.PrintOperationInProgressMsg Window "Put Cards Here" OperationInProgress) else (NC.ProtectedCardOperation Card Put% Cards% Here (OR NewChildren (SETQ NewChildren (NC.SelectNoteCards NIL NIL NC.SelectingFileBoxChildrenMenu Card NIL " Please select new children."))) (COND ((AND NewChildren Card (for NewChild in NewChildren bind OneHook when (NC.MakeChildLink NewChild Card Window) do (SETQ OneHook T) finally (RETURN OneHook))) Card) ((NULL NoDisplayFlg) (NC.PrintMsg Window NIL "No appropriate NoteCards or FileBoxes chosen." (CHARACTER 13) "Hence no children added." (CHARACTER 13)) (DISMISS 1000) (NC.ClearMsg Window T) NIL) (T NIL)))))))) ) (PUTPROPS RHTPATCH123 COPYRIGHT ("Xerox Corporation" 1986)) (DECLARE: DONTCOPY (FILEMAP (NIL (969 7798 (NC.QuitWithoutSaving 979 . 7796)) (7832 8544 (NC.GetNoteCard 7842 . 8542)) ( 8575 14364 (NC.SmartDeleteLinks 8585 . 14362)) (14401 16923 (NC.FileBoxCollectChildren 14411 . 16921)) ))) STOP