(FILECREATED "12-Mar-87 14:36:15" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH017.;4 24220
changes to: (VARS RGPATCH017COMS)
(FNS NC.DeleteNoteCards NC.PrintOperationInProgressMsg NC.DeleteNoteCardInternal
NC.DeleteNoteCard NC.AssignTitle)
previous date: "10-Mar-87 19:39:47" {QV}<NOTECARDS>1.3K>NEXT>RGPATCH017.;1)
(* Copyright (c) 1987 by Xerox Corporation. All rights reserved.)
(PRETTYCOMPRINT RGPATCH017COMS)
(RPAQQ RGPATCH017COMS [(* * rg 3/11/87 Fix some bugs in RGPATCH016)
(* * changes to NCINTERFACE)
(FNS NC.CopyStructure)
(* * changes to NCCARDS)
(FNS NC.DeleteNoteCards NC.DeleteNoteCard NC.AssignTitle
NC.PrintOperationInProgressMsg NC.DeleteLink)
(* * new for NCCARDS)
(FNS NC.DeleteNoteCardInternal)
(* * hack to update existing menus)
(P (NLSETQ (EDITV NC.DefaultLeftButtonMenuItems (R NC.DeleteNoteCards
NC.DeleteNoteCard])
(* * rg 3/11/87 Fix some bugs in RGPATCH016)
(* * changes to NCINTERFACE)
(DEFINEQ
(NC.CopyStructure
[LAMBDA (RootCards DestinationFileBox TraversalSpecs InterestedWindow QuietFlg)
(* Randy.Gobbel " 9-Mar-87 18:31")
(* * Copy a NoteCard structure into a filebox)
(* * kirk 13/7/86: Placed TraversalSpecs after RootCards selection and changed prompt message)
(* * rht 9/2/86: Threw away CheckFlg arg. Wasn't being used. Changed to call NCP.CollectCards instead of outdated
NC.CollectCards. Changed arg named ToPosition to DestinationFileBox. Also changed FromCard to RootCard.
Passes two link types to NC.AskTraversalSpecs.)
(* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)
(* * rht 3/9/87: Now accepts multiple root cards.)
(* * rg 3/9/87 added NC.ProtectedSessionOperation wrapper)
(DECLARE (GLOBALVARS NC.SelectingCardsMenu NC.SelectingCardMenu))
(NC.ProtectedSessionOperation "Copy Structure" InterestedWindow (SETQ RootCards (MKLIST
RootCards))
(OR RootCards (SETQ RootCards (NC.SelectNoteCards NIL NIL
NC.SelectingCardsMenu NIL
"Shift-select the root cards of the structure"))
(ERROR!))
(OR TraversalSpecs [SETQ TraversalSpecs
(NC.AskTraversalSpecs (fetch (Card NoteFile)
of (CAR RootCards))
(QUOTE (SubBox FiledCard]
(ERROR!))
(OR DestinationFileBox (SETQ DestinationFileBox
(NC.SelectNoteCards T (FUNCTION [LAMBDA (Card)
(NC.FileBoxP Card T])
NC.SelectingCardMenu NIL
"Shift-select the FileBox to contain the structure."))
(ERROR!))
(NC.CopyCards (NCP.CollectCards RootCards (fetch
(TRAVERSALSPECS LinkTypes)
of
TraversalSpecs)
(fetch (TRAVERSALSPECS Depth)
of TraversalSpecs))
DestinationFileBox RootCards QuietFlg
InterestedWindow])
)
(* * changes to NCCARDS)
(DEFINEQ
(NC.DeleteNoteCards
[LAMBDA (CardIdentifiers NoIndividualConfirmFlg DontClearFlg InterestedWindow QuietFlg
NoGroupConfirmFlg) (* Randy.Gobbel "11-Mar-87 12:13")
(* Delete note cards. If no card specified then get a
list of note cards to be deleted.
Then delete these cards.)
(* * fgh 11/11/85: Updated to handle new Card objects. Also split off main work of deleteing a single note card
into NC.DeleteNoteCard function.)
(* * kirk 21Feb86 Added InterestedWindow)
(* * kirk 29Apr86 Now returns CardIdentifiers)
(* * fgh 6/9/86 Added checks to see if other operations are in progress)
(* * rht 7/4/86: Now checks that card is not read-only.)
(* * kirk 18Aug86 Added main window for windowless cards.)
(* * rht 8/29/86: Reorganized and added call to NC.SeverAllLinks to make deleting more efficient.
Added QuietFlg, NoGroupConfirmFlg and Don'tPutToBeDeletedCardsFlg args.)
(* * rht 9/5/86: Now forces NoGroupConfirmFlg to be non-nil if NoIndividualConfirmFlg is NIL and only one card to
delete.)
(* * pmi 12/5/86: Modified message to NC.SelectNoteCards to mention SHIFT-selection.)
(* * pmi 12/12/86: Removed obsolete ReturnLinksFlg argument in call to NC.SelectNoteCards.)
(* * rht 12/16/86: Removed obsolete Don'tPutToBeDeletedCardsFlg arg.)
(* * rht 3/9/87: Changed NC.DeleteSelectingMenu to NC.SelectingCardsMenu.)
(* * rg 3/9/87 added NC.ProtectedSessionOperation wrapper)
(* * rg 3/11/87 changed call of NC.DeleteNoteCard to NC.DeleteNoteCardInternal)
(DECLARE (GLOBALVARS NC.SelectingCardsMenu))
(NC.ProtectedSessionOperation
"Delete Note Cards" InterestedWindow (OR CardIdentifiers (SETQ CardIdentifiers
(NC.SelectNoteCards NIL NIL
NC.SelectingCardsMenu
InterestedWindow
"Please shift-select the Note Cards to be deleted.")))
(* * Kludge in case args are nil, say, when we're called from a card's menu.)
(if (AND (NULL NoIndividualConfirmFlg)
(NULL NoGroupConfirmFlg)
(EQ (LENGTH (MKLIST CardIdentifiers))
1))
then (SETQ NoGroupConfirmFlg T)
(SETQ QuietFlg T))
(* * First collect cards that are deletable.)
(LET ((CardsToDelete (for CardIdentifier in (MKLIST CardIdentifiers) bind Card
eachtime (BLOCK)
when [AND (SETQ Card (NC.CoerceToCard CardIdentifier))
(if (NOT (NC.TopLevelCardP Card))
else (NC.PrintMsg (NC.FetchWindow Card)
T
"You cannot delete this FileBox."
(CHARACTER 13))
(DISMISS 1000)
(NC.ClearMsg (NC.FetchWindow Card)
T)
NIL)
(NC.CheckForNotReadOnly Card (NC.FetchWindow Card)
"Can't delete cards from a ")
(OR NoIndividualConfirmFlg
(PROG1 (NC.AskYesOrNo
"Are you sure you want to delete this?"
" -- " "Yes"
(NULL DontClearFlg)
(OR (NC.FetchWindow
Card)
InterestedWindow)
NIL NIL)
(NC.ClearMsg]
collect Card))
(NumSpecified (LENGTH (MKLIST CardIdentifiers)))
NumToDelete)
(SETQ NumToDelete (LENGTH CardsToDelete))
(if [AND (GREATERP NumToDelete 0)
(if (EQUAL NumToDelete NumSpecified)
then (OR NoGroupConfirmFlg (PROG1 (NC.AskYesOrNo
(CONCAT "You've specified "
NumToDelete
" cards to delete."
(CHARACTER 13)
"Are you sure you want to delete them? ")
NIL "Yes" (NULL DontClearFlg)
InterestedWindow)
(NC.ClearMsg)))
else (PROG1 (NC.AskYesOrNo (CONCAT "Out of " NumSpecified
" cards specified, "
(DIFFERENCE NumSpecified
NumToDelete)
" are not deletable."
(CHARACTER 13)
"Want to delete the remaining "
NumToDelete " cards? ")
NIL "Yes" (NULL DontClearFlg)
InterestedWindow)
(NC.ClearMsg]
then
(* * Mark UIDs of cards about to be deleted.)
(for Card in CardsToDelete do (NC.UIDPutProp (fetch (Card UID)
of Card)
(QUOTE
AboutToBeDeletedFlg)
T))
(* * Sever all links into and out of CardsToDelete)
(NC.SeverAllLinks CardsToDelete QuietFlg InterestedWindow)
(* * Now delete the cards one at a time.)
(OR QuietFlg (NC.PrintMsg InterestedWindow T "Deleting cards: 1 out of "
NumToDelete " ..."))
(for Card in CardsToDelete as i from 1 eachtime (BLOCK)
do (OR QuietFlg (if (ZEROP (REMAINDER i 10))
then (NC.PrintMsg InterestedWindow T
"Deleting cards: "
i " out of " NumToDelete
" ...")))
(NC.ProtectedCardOperation Card "Delete Card" InterestedWindow
(NC.DeleteNoteCardInternal Card)))
(OR QuietFlg (NC.ClearMsg InterestedWindow T))
CardIdentifiers])
(NC.DeleteNoteCard
[LAMBDA (CardIdentifier) (* Randy.Gobbel "11-Mar-87 16:30")
(* * User interface level fn to delete a single note card from a NoteFile)
(LET (Card InterestedWindow)
(NC.ProtectedCardOperation (NC.CoerceToCard CardIdentifier)
"Delete Note Card"
(NC.FetchWindow Card)
(SETQ Card (NC.CoerceToCard CardIdentifier))
(SETQ InterestedWindow (NC.FetchWindow Card))
(AND (if (NC.TopLevelCardP Card)
then (NC.PrintMsg InterestedWindow T
"You cannot delete this FileBox."
(CHARACTER 13))
(DISMISS 1000)
(NC.ClearMsg InterestedWindow T)
NIL
else T)
(NC.CheckForNotReadOnly Card InterestedWindow
"Can't delete cards from a ")
(PROG1 (NC.AskYesOrNo
"Are you sure you want to delete this?"
" -- " "Yes" T InterestedWindow
NIL NIL)
(NC.ClearMsg))
(PROGN
(* * Mark UID of card about to be deleted.)
(NC.UIDPutProp (fetch (Card UID)
of Card)
(QUOTE AboutToBeDeletedFlg)
T)
(* * Sever all links into and out of Card)
(NC.SeverAllLinks (LIST Card)
T)
(* * Now delete the card)
(NC.DeleteNoteCardInternal Card])
(NC.AssignTitle
[LAMBDA (CardIdentifier NoClearMsgFlg NewTitle) (* Randy.Gobbel "10-Mar-87 19:20")
(* * Change the title of the card specified by the WindowOrTextStreamOrID)
(* * rht 2/1/85: Changed from NC.PutTitle to NC.SetTitleDirtyFlg, unless card is not active.
We shouldn't be writing to the notefile until save time.)
(* * fgh 11/11/85: Added support for CardID, CardInfo and noteFile objects. Also entered call to Nc.StoreTitle.)
(* * fgh 6/9/86 Added code to check to make sure that another operation is not in progress on this card when this
fn is called.)
(* * fgh 6/13/86 Now spawns mouse in case called under MOUSE process.)
(* * fgh 6/27/86 returns T if completed okay.)
(* * rht 7/4/86: Added check for readonly card.)
(* * kef 7/16/86: Added obtain write permission.)
(* * kef 7/24/86: Doesn't release the write lock if this is a new card.)
(* * kef 7/30/86: Modified to check for Client's concept of whether he owns the write lock or not, thus deciding
whether or not to setup the release of the write lock afterwards.)
(* * fgh 8/30/86 Converted to use NC.IfCardPartNotBusy.)
(* * rg 3/3/87 Enlarged scope of NC.ProtectedCardOperation)
(ALLOW.BUTTON.EVENTS)
(LET ((Card (NC.CoerceToCard CardIdentifier))
ContainingCard OldTitle Window)
(NC.ProtectedCardOperation Card "Assign Title" NIL
(NC.IfCardPartNotBusy
Card
(QUOTE TITLE)
(SETQ Window (NC.FetchWindow Card))
(if (NC.CheckForNotReadOnly Card Window
"Can't change titles for cards in ")
then (COND
((SETQ NewTitle
(OR (STRINGP NewTitle)
(AND NewTitle (OR (LITATOM
NewTitle)
(NUMBERP
NewTitle))
(MKSTRING NewTitle))
(NC.AskUser
(CONCAT
"Enter the title for this card"
(CHARACTER 13))
"--> "
(COND
((AND (STREQUAL (SETQ OldTitle
(
NC.RetrieveTitle
Card))
"Untitled")
(NC.FetchNewCardFlg Card))
NIL)
(T OldTitle))
(NULL NoClearMsgFlg)
Window)))
(NC.SetTitle Card NewTitle)
(* * Now do a PutTitle so that anyone else coming along will pick up on the new title. The only exception is if
this card hasn't been written to the NoteFile yet, which is true when the NewCardFlg is T. In that case, we can't
put the title down yet, so just mark it dirty.)
(COND
((fetch (Card NewCardFlg) of Card)
(NC.SetTitleDirtyFlg Card T))
(T (NC.PutTitle Card)
(NC.SetTitleDirtyFlg Card NIL)))
(AND (WINDOWP Window)
(WINDOWPROP Window (QUOTE TITLE)
NewTitle))
(for FromLink in (NC.RetrieveFromLinks
Card)
do (AND (NC.ActiveCardP
(SETQ ContainingCard
(fetch (Link SourceCard)
of FromLink)))
(WINDOWP (NC.FetchWindow
ContainingCard))
(NC.UpdateLinkImages
ContainingCard
Card)))
T))
else NIL])
(NC.PrintOperationInProgressMsg
[LAMBDA (Window Operation OperationInProgress) (* Randy.Gobbel "11-Mar-87 11:00")
(* * Notify the user that they are attempting to do an operation while another operation is in progress.
Use a prompt window above the card's promptwindow because the card's prompt window is probably being used for the
operation.)
(* * fgh 6/9/86 First created.)
(* * RG 3/10/87 removed redundant (?) call to NC.AttachPromptWindow)
(LET (PWindow)
(if (OPENWP (SETQ PWindow (NC.AttachPromptWindow Window NIL NIL NIL T)))
then (SETQ PWindow (NC.AttachPromptWindow PWindow 1 30 NIL NIL))
else (SETQ PWindow (NC.AttachPromptWindow Window NIL 30 NIL NIL)))
(NC.PrintMsg PWindow T "## Can't " Operation (CHARACTER 13)
"## " OperationInProgress " in progress.")
(REPOSITIONATTACHEDWINDOWS Window])
(NC.DeleteLink
[LAMBDA (Link NoOrphanHookFlg Don'tDelLinkIconFlg) (* Randy.Gobbel "11-Mar-87 12:14")
(* * Delete a link with the option of not putting an orphan hook in case of last filing link.
Also option of not deleting link icon from the source card's substance.)
(* * fgh 5/2/86 Included calls to NC.DelReferencesToCardFromShowLinks in order to clean up ShowLinks windows when
links are deleted.)
(* * kef 7/17/86: Added the requirement that the write permissions be obtained for the TOLINKS of the Source Card
and the FROMLINKS of the Destination Card.)
(* * kef 7/22/86: Puts the links for the Destination Card now right away while we are still holding onto the write
lock for the FROMLINKS.)
(* * kef 7/30/86: Modified to check for Client's concept of whether he owns the write lock or not, thus deciding
whether or not to setup the release of the write lock afterwards.)
(* * fgh 8/30/86 Adpated to use NC.IfCardPartNotBusy. Note use of ERROR!. Unfortunately, it appears that the only
way to keep TEDIT from deleting the Link's Image Object is to bail out but good. The control structure here works
because NC.IfCardPartNotBusy returns NIL if the CardPart is busy. The Ts at the end as the last SExpr in each call
to NC.IfCardPartNotBusy insure that NC.IfCardPartNotBusy returns non-NIL otherwise.)
(* * rht 9/29/86: Removed the call to NC.PutFromLinks. Looks to me like it'll get called anyway by NC.DelFromLink
if necessary.)
(* * rht 10/6/86: Delete crossfilelink cards when their links are deleted.)
(* * rht 11/4/86: Now takes Don'tCreateDeletedImageObjFlg arg.)
(* * rht 11/13/86: Undid my change of 11/4/86.)
(* * rg 3/11/87 changed call of NC.DeleteNoteCard to NC.DeleteNoteCardInternal)
(AND (NC.ValidLinkP Link)
(LET ((SourceCard (fetch (Link SourceCard) of Link))
(DestinationCard (fetch (Link DestinationCard) of Link))
BusyCardPart)
(WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of SourceCard))
(OR (NC.IfCardPartNotBusy DestinationCard (QUOTE FROMLINKS)
(OR (NC.IfCardPartNotBusy
DestinationCard
(QUOTE TOLINKS)
(OR Don'tDelLinkIconFlg
(NC.DelReferencesToCard
SourceCard Link))
(NC.DelFromLink Link
NoOrphanHookFlg)
(NC.DelToLink Link)
(
NC.DelReferencesToCardFromShowLinks
SourceCard Link)
(
NC.DelReferencesToCardFromShowLinks
DestinationCard Link)
(* * This UID replacement is worrisome. Does it mean that link deletion can't be undone?)
(replace (Link UID) of Link
with -1)
T)
(ERROR!))
T)
(ERROR!)))
(* * Delete cross file link cards when their links are deleted.)
(if (NC.CrossFileLinkCardP DestinationCard)
then (NC.DeleteNoteCardInternal DestinationCard))
(if (NC.CrossFileLinkCardP SourceCard)
then (NC.DeleteNoteCardInternal SourceCard])
)
(* * new for NCCARDS)
(DEFINEQ
(NC.DeleteNoteCardInternal
[LAMBDA (Card) (* Randy.Gobbel "11-Mar-87 12:15")
(* * Delete a single note card from a NoteFile)
(* * rht 8/11/86 Now calls NC.DeleteReferencesToCardFromShowLinks to smash any link icons in show links menus
pointing to this card.)
(* * kef 7/28/86: Added code to obtain all of the write locks deemed necessary.)
(* * kef 7/30/86: Modified to check for Client's concept of whether he owns the write lock or not, thus deciding
whether or not to setup the release of the write lock afterwards.)
(* * kef 7/31/86: Added the nesting of the obtaining writelocks with deactivating the card.)
(* * fgh 8/30/86 Translated APPLY* to NC.ApplyFn. Made cosmetic changes in FOR loop concewrning WriteLocks.)
(* * rht 1/16/87: Moved call to MarkCardDeletedFn after call to NC.QuitCard.)
(* * rg 3/11/87 renamed)
(RESETLST (RESETSAVE (CURSOR WAITINGCURSOR))
(RESETSAVE NIL (BQUOTE (NC.SetBeingDeletedFlg , Card NIL)))
(WITH.MONITOR (NC.FetchMonitor (fetch (Card NoteFile) of Card))
(LET ((WriteLocks (for CardPart
in (QUOTE (SUBSTANCE TITLE TOLINKS FROMLINKS
GLOBALTOLINKS PROPLIST))
collect (CONS Card CardPart)))
ToLinks FromLinks Window BusyPart PromptWindow)
(NC.SetBeingDeletedFlg Card T)
(SETQ ToLinks (NC.RetrieveToLinks Card))
(SETQ FromLinks (NC.RetrieveFromLinks Card))
[for ToLink in ToLinks
do (NCONC WriteLocks (for CardPart
in (QUOTE (TOLINKS FROMLINKS
GLOBALTOLINKS))
collect
(CONS (fetch (Link
DestinationCard)
of ToLink)
CardPart]
[for FromLink in FromLinks
do (NCONC WriteLocks (for CardPart
in (QUOTE (SUBSTANCE TOLINKS
FROMLINKS
GLOBALTOLINKS))
collect
(CONS (fetch (Link SourceCard)
of FromLink)
CardPart]
(* * The for... loop that follows is the condition that we can obtain all of the write locks on all of the card
parts collected in WriteLocks. If we obtain a writelock, setup a RESETSAVE to release it upon exit.
Then finally, if we do obtain a write lock, return T so that the for loop's "always" condition is satisfied.
If we don't obtain a write lock for a given card part, save that one as a variable so we can report it to the user.
Then return NIL, so that the for loop's "always" condition is not satisfied, and we bump out of the for loop.)
(NC.PrintMsg (SETQ PromptWindow (NC.AttachPromptWindow
(NC.FetchWindow Card)))
T "Collecting write locks...")
(COND
((for WriteLock in WriteLocks bind WLCard WLCardPart
when (NC.ValidCardP (SETQ WLCard (CAR WriteLock)))
always (SETQ WLCardPart (CDR WriteLock))
(COND
((NC.ApplyFn ObtainWritePermissionFn WLCard
WLCardPart)
(RESETSAVE NIL
(BQUOTE
(APPLY* , (fetch
(Card
ReleaseWritePermissionFn)
of WLCard)
, WLCard , WLCardPart))
)
T)
(T (SETQ BusyPart WriteLock)
NIL)))
(* * Call off to the MarkCardDeletedFn specific to the NoteFile.)
(RESETSAVE (for CardPart
in (QUOTE (SUBSTANCE TOLINKS GLOBALTOLINKS
PROPLIST))
do (NC.ApplyFn ObtainWritePermissionFn Card
CardPart))
(BQUOTE (NC.DeactivateCard , Card T)))
(NC.ApplyFn MarkCardDeletedFn Card)
(NC.SetToLinks Card NIL)
(NC.SetFromLinks Card NIL)
(NC.PrintMsg PromptWindow NIL
"Removing links to and from other cards...")
(for ToLink in ToLinks when (NC.ValidLinkP ToLink)
do (NC.DelFromLink ToLink)
(NC.DelReferencesToCardFromShowLinks
(fetch (Link DestinationCard) of ToLink)
ToLink))
(for FromLink in FromLinks when (NC.ValidLinkP
FromLink)
do (NC.DelToLink FromLink)
(NC.DelReferencesToCard (fetch (Link SourceCard)
of FromLink)
Card)
(NC.DelReferencesToCardFromShowLinks
(fetch (Link SourceCard) of FromLink)
FromLink))
(NC.PrintMsg PromptWindow NIL "..done.")
(if (NC.ActiveCardP Card)
then (NC.TurnOffDirtyFlgs Card)
(SETQ Window (NC.FetchWindow Card))
(AND Window (NC.GreyCard Card))
(NC.CloseAllPropListEditors Card)
(NC.QuitCard Card T T))
(NC.ApplyFn MarkCardDeletedFn Card)
(NC.SetNewCardFlg Card NIL))
(T (NC.CardPartBusy (CAR BusyPart)
(CDR BusyPart)
PromptWindow])
)
(* * hack to update existing menus)
(NLSETQ (EDITV NC.DefaultLeftButtonMenuItems (R NC.DeleteNoteCards NC.DeleteNoteCard)))
(PUTPROPS RGPATCH017 COPYRIGHT ("Xerox Corporation" 1987))
(DECLARE: DONTCOPY
(FILEMAP (NIL (1012 3151 (NC.CopyStructure 1022 . 3149)) (3183 18519 (NC.DeleteNoteCards 3193 . 8951)
(NC.DeleteNoteCard 8953 . 10474) (NC.AssignTitle 10476 . 14119) (NC.PrintOperationInProgressMsg 14121
. 15109) (NC.DeleteLink 15111 . 18517)) (18548 24009 (NC.DeleteNoteCardInternal 18558 . 24007)))))
STOP