-
Notifications
You must be signed in to change notification settings - Fork 4
Backup CellGroup Members
#summary Description of CellGroupMember Backup
= Introduction =
Primary goal of this process is to support undo/redo functionality in Notebooks. The main problem is storing the deleted CellGroupMember(aka CGM) in a way that wouldn't interfere with the other parts of the niche and then, if necessary, easily restore that CGM back.
= Details = The process consist of three phases: backup/restore/backup deletion. Backup and restore are handled automatically in CellGroup during remove/insert of a CellGroupMember(aka CGM) by calling CellUtils.backupCell(CGM) and CellUitls.restoreCell(CGM). The backup deletion is executed at HG shutdown. CGM backup is executed as follows: All EventPubsSubs of the CGM are deleted and the info needed for their restoration is recorded in a BackupLink, which is attached to the CGM. The same thing is done to all the children of the CGM. CGM restore is the reverse: EventPubsSubs get recreated and BackupLink is deleted. Backup deletion simply removes all CGM-s pointed by a BackupLink.
BackupLink is a simple HGPlainLink containing three targets: HGHandle cell, List of EventPubSubInfo pubs, List of EventPubSubInfo subs; where EventPubSubInfo is a simple bean with info needed for EventPubSub restoration: HGHandle eventType, HGHandle pub_or_sub, HGHandle eventHandler.
= Consequences or Drawbacks = As mentioned backup/restore is handled automatically during CellGroup remove/insert, but there could be other cases. For example if a CGM is inserted in a CellGroup A and then removed from another one, the CGM will be backuped(EventPubSubs removed) and become rather unusable in the A. To avoid this, use the CellGroupMember.remove(CGM, false), which won't backup the CGM.