UndoSystem
index
/home/laszlo/Dev/joko-gtk-builder/Jokosher/UndoSystem.py

#       THIS FILE IS PART OF THE JOKOSHER PROJECT AND LICENSED UNDER THE GPL. SEE
#       THE 'COPYING' FILE FOR DETAILS
#
#       UndoSystem.py
#
#       Contains the decorator needed to allow other classes to hook specific
#       function calls into the undo stack.
#
#=========================================================================

 
Modules
       
Event
Globals
IncrementalSave
Instrument
Project
ProjectManager
Utils
xml.dom.minidom

 
Classes
       
AtomicUndoAction
exceptions.Exception(exceptions.BaseException)
CancelUndoCommand

 
class AtomicUndoAction
    Contains several undo commands to be treated as a single undoable operation.
 
Example:
        When deleting several Instruments at once, an AtomicUndoAction
        containing the commands to resurrect the Instruments will be created.
        When the user requests an undo operation, all of the commands stored
        in this object will be rolled back, making the operation appear to be
        atomic from the user's perspective.
 
  Methods defined here:
AddUndoCommand(self, objectString, function, paramList)
Adds a new undo command to this AtomicUndoAction.
 
Example:
        The parameters passed to this function:
                "E2", "Move", [1, 2]
        means
                'Call Move(1, 2)' on the Event with ID=2
 
Parameters:
        objectString -- the string representing the object and its ID
                                        (ie "E2" for Event with ID == 2).
        function -- the name of the function to be called on the object.
        paramList -- a list of values to be passed to the function as parameters.
                                Key, value parameters are not supported.
GetUndoCommands(self)
Obtains the list of undo commands held by this AtomicUndoAction.
 
Returns:
        a list of tuples, each of which contains a single undo command.
StoreToXML(self, doc, node)
Stores this instance of AtomicUndoAction into an XML node.
 
Example:
                doc = xml.Document()
                node = doc.createElement("Action")
                doc.appendChild(node)
                StoreToXml(doc, node)
                
        will save this AtomicUndoAction in doc, inside node.
 
Parameters:
        doc -- XML document to save this AtomicUndoAction into.
        node -- XML node to store this AtomicUndoAction under.
                        This node's name should be "Action".
__init__(self)
Creates a new AtomicUndoAction instance.

 
class CancelUndoCommand(exceptions.Exception)
    This exception can be thrown by a decorated undo
function in order to tell the undo system to not
log the current action. This is useful if something
in the function fails and the action that would have
been logged to the undo stack was never actually completed.
 
 
Method resolution order:
CancelUndoCommand
exceptions.Exception
exceptions.BaseException
__builtin__.object

Methods defined here:
__init__(self, result=None)
Creates a new instance of CancelUndoCommand.
 
Parameters:
        result -- value the wrapped function intended to return,
                                but failed and called this exception.

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from exceptions.Exception:
__new__ = <built-in method __new__ of type object>
T.__new__(S, ...) -> a new object with type S, a subtype of T

Methods inherited from exceptions.BaseException:
__delattr__(...)
x.__delattr__('name') <==> del x.name
__getattribute__(...)
x.__getattribute__('name') <==> x.name
__getitem__(...)
x.__getitem__(y) <==> x[y]
__getslice__(...)
x.__getslice__(i, j) <==> x[i:j]
 
Use of negative indices is not supported.
__reduce__(...)
__repr__(...)
x.__repr__() <==> repr(x)
__setattr__(...)
x.__setattr__('name', value) <==> x.name = value
__setstate__(...)
__str__(...)
x.__str__() <==> str(x)
__unicode__(...)

Data descriptors inherited from exceptions.BaseException:
__dict__
args
message

 
Functions
       
UndoCommand(*command, **command_options)
Decorates functions, enabling them to be logged in the undo stack.
The decorating process is transparent to the clients.
 
Parameters:
        command -- the undo command list of strings.
        command_options -- key-value parameters to change options.
        
Returns:
        an UndoFunction which decorates the original function.