1
Vote

Multi-Document change support

description

I have been using dejavu with a multi-document app and using a seperate undo/redo area for each document.
 
One problem I came across was what to do with undo/redo actions that trancend a single document (like adding a new document, changing document order, removing documents etc..).
 
My Solution so far is this:
 
1) Replace Command.Caption with Command.CommandID (a struct with an Id field and a Caption field)
 Whenever a new Command is created the Id is given by an incrementing static index ("static int _currentId")
 UndoRedoArea.UndoCommands & RedoCommands now return an enumerable of CommandId's
 
2) I created a "master" document undo/redo area that recorded changes on a higher level then inside a document (add a new document, change document order, remove document etc..)
 
3) When I want to do an undo or redo action I compare the id's of the local document UndoRedoArea commands and the master document UndoRedoArea to figure out what to undo (or redo)
 
4) I added a ClearRedos method to UndoRedoArea so if the master UndoRedoArea is commited to I ClearUndos on all the local UndoRedoAreas or if a local UndoRedoArea is commited to I ClearUndos on the master UndoRedoArea.
 
 
It is an interesting solution and I am testing it out :)
 
I hope this makes sense to someone.

comments

SergeiArhipenko wrote Feb 18, 2008 at 2:47 PM

I did not understand points 3,4. What for do you do that?
It seems you would better use single area for all activities instead of "syncronizing" multiple areas...

djpnewton wrote Mar 6, 2008 at 12:16 AM

It seems you would better use single area for all activities instead of "syncronizing" multiple areas...
You might be right, if it does not work out I will use a single undo/redo area

wrote Feb 13, 2013 at 10:58 PM