nsITransactionManager

This interface is implemented by an object that wants to manage/track transactions.
Inherits from: nsISupports Last changed in Gecko 1.7

Method overview

void AddListener(in nsITransactionListener aListener);
void beginBatch();
void clear();
void doTransaction(in nsITransaction aTransaction);
void endBatch();
nsITransactionList getRedoList();
nsITransactionList getUndoList();
nsITransaction peekRedoStack();
nsITransaction peekUndoStack();
void redoTransaction();
void RemoveListener(in nsITransactionListener aListener);
void undoTransaction();

Attributes

Attribute Type Description
maxTransactionCount long

Sets the maximum number of transaction items the transaction manager will maintain at any time. This is commonly referred to as the number of levels of undo.

A value of -1 means no limit. A value of zero means the transaction manager will execute each transaction, then immediately release all references it has to the transaction without pushing it on the undo stack. A value greater than zero indicates the max number of transactions that can exist at any time on both the undo and redo stacks. This method will prune the necessary number of transactions on the undo and redo stacks if the value specified is less than the number of items that exist on both the undo and redo stacks.
numberOfRedoItems long The number of items on the redo stack. Read only.
numberOfUndoItems long The number of items on the undo stack. Read only.

Methods

AddListener()

Adds a listener to the transaction manager's notification list. Listeners are notified whenever a transaction is done, undone, or redone. The listener's nsITransactionListener.AddRef() method is called.

void AddListener(
  in nsITransactionListener aListener
);
Parameters
aListener
The nsITransactionListener to add.

beginBatch()

Turns on the transaction manager's batch mode, forcing all transactions executed by the transaction manager's doTransaction() method to be aggregated together until EndBatch() is called. This mode allows an application to execute and group together several independent transactions so they can be undone with a single call to undoTransaction().

void beginBatch();
Parameters

None.

clear()

Clears the undo and redo stacks.

void clear();
Parameters

None.

doTransaction()

Calls a transaction's nsITransaction.doTransaction() method, then pushes it on the undo stack. This method calls the transaction's nsITransaction.AddRef() method. The transaction's nsITransaction.Release() method will be called when the undo or redo stack is pruned or when the transaction manager is destroyed.

void doTransaction(
  in nsITransaction aTransaction
);
Parameters
aTransaction
The nsITransaction to do.

endBatch()

Turns off the transaction manager's batch mode.

void endBatch();
Parameters

None.

getRedoList()

Returns the list of nsITransaction on the redo stack. Note that the transaction at the top of the redo stack will actually be at the index n-1 in the list, where n is the number of items in the list.

nsITransactionList getRedoList();
Parameters

None.

Return value

A list of nsITransaction on the redo stack.

getUndoList()

Returns the list of nsITransaction on the undo stack. Note that the transaction at the top of the undo stack will actually be at the index n-1 in the list, where n is the number of items in the list.

nsITransactionList getUndoList();
Parameters

None.

Return value

A list of nsITransaction on the undo stack.

peekRedoStack()

Returns an AddRef'd pointer to the nsITransaction at the top of the redo stack. Callers should be aware that this method could return a null in some implementations if there is a batch at the top of the redo stack.

nsITransaction peekRedoStack();
Parameters

None.

Return value

An AddRef'd pointer to the nsITransaction at the top of the redo stack.

peekUndoStack()

Returns an AddRef'd pointer to the nsITransaction at the top of the undo stack. Callers should be aware that this method could return a null in some implementations if there is a batch at the top of the undo stack.

nsITransaction peekUndoStack();
Parameters

None.

Return value

An AddRef'd pointer to the nsITransaction at the top of the undo stack.

redoTransaction()

Pops the topmost transaction on the redo stack, calls it's nsITransaction.redoTransaction() method, then pushes it on the undo stack.

void redoTransaction();
Parameters

None.

RemoveListener()

Removes a listener from the transaction manager's notification list. The listener's nsITransactionListener.Release() method is called.

void RemoveListener(
  in nsITransactionListener aListener
);
Parameters
aListener
The nsITransactionListener to remove.

undoTransaction()

Pops the topmost transaction on the undo stack, calls it's nsITransaction.undoTransaction() method, then pushes it on the redo stack.

void undoTransaction();
Parameters

None.

See also