Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
* License, v. 2.0. If a copy of the MPL was not distributed with this
4
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsISupports.idl"
7
#include "nsITransaction.idl"
8
#include "nsITransactionListener.idl"
9
10
%{C++
11
namespace mozilla {
12
class TransactionManager;
13
} // namespace mozilla
14
%}
15
16
/**
17
* The nsITransactionManager interface.
18
* <P>
19
* This interface is implemented by an object that wants to
20
* manage/track transactions.
21
*/
22
[scriptable, builtinclass, uuid(c77763df-0fb9-41a8-8074-8e882f605755)]
23
interface nsITransactionManager : nsISupports
24
{
25
/**
26
* Calls a transaction's doTransaction() method, then pushes it on the
27
* undo stack.
28
* <P>
29
* This method calls the transaction's AddRef() method.
30
* The transaction's Release() method will be called when the undo or redo
31
* stack is pruned or when the transaction manager is destroyed.
32
* @param aTransaction the transaction to do.
33
*/
34
void doTransaction(in nsITransaction aTransaction);
35
36
/**
37
* Pops the topmost transaction on the undo stack, calls its
38
* undoTransaction() method, then pushes it on the redo stack.
39
*/
40
void undoTransaction();
41
42
/**
43
* Pops the topmost transaction on the redo stack, calls its
44
* redoTransaction() method, then pushes it on the undo stack.
45
*/
46
void redoTransaction();
47
48
/**
49
* Clears the undo and redo stacks.
50
*/
51
void clear();
52
53
/**
54
* Clears the undo stack only.
55
*/
56
void clearUndoStack();
57
58
/**
59
* Clears the redo stack only.
60
*/
61
void clearRedoStack();
62
63
/**
64
* Turns on the transaction manager's batch mode, forcing all transactions
65
* executed by the transaction manager's doTransaction() method to be
66
* aggregated together until EndBatch() is called. This mode allows an
67
* application to execute and group together several independent transactions
68
* so they can be undone with a single call to undoTransaction().
69
* @param aData An arbitrary nsISupports object that is associated with the
70
* batch. Can be retrieved from the undo or redo stacks.
71
*/
72
void beginBatch(in nsISupports aData);
73
74
/**
75
* Turns off the transaction manager's batch mode.
76
* @param aAllowEmpty If true, a batch containing no children will be
77
* pushed onto the undo stack. Otherwise, ending a batch with no
78
* children will result in no transactions being pushed on the undo stack.
79
*/
80
void endBatch(in boolean aAllowEmpty);
81
82
/**
83
* The number of items on the undo stack.
84
*/
85
readonly attribute long numberOfUndoItems;
86
87
/**
88
* The number of items on the redo stack.
89
*/
90
readonly attribute long numberOfRedoItems;
91
92
/**
93
* Sets the maximum number of transaction items the transaction manager will
94
* maintain at any time. This is commonly referred to as the number of levels
95
* of undo.
96
* @param aMaxCount A value of -1 means no limit. A value of zero means the
97
* transaction manager will execute each transaction, then immediately release
98
* all references it has to the transaction without pushing it on the undo
99
* stack. A value greater than zero indicates the max number of transactions
100
* that can exist at any time on both the undo and redo stacks. This method
101
* will prune the necessary number of transactions on the undo and redo
102
* stacks if the value specified is less than the number of items that exist
103
* on both the undo and redo stacks.
104
*/
105
attribute long maxTransactionCount;
106
107
/**
108
* Combines the transaction at the top of the undo stack (if any) with the
109
* preceding undo transaction (if any) into a batch transaction. Thus,
110
* a call to undoTransaction() will undo both transactions.
111
*/
112
void batchTopUndo();
113
114
/**
115
* Removes the transaction at the top of the undo stack (if any) without
116
* transacting.
117
*/
118
void removeTopUndo();
119
120
/**
121
* Returns an AddRef'd pointer to the transaction at the top of the
122
* undo stack. Callers should be aware that this method could return
123
* return a null in some implementations if there is a batch at the top
124
* of the undo stack.
125
*/
126
nsITransaction peekUndoStack();
127
128
/**
129
* Returns an AddRef'd pointer to the transaction at the top of the
130
* redo stack. Callers should be aware that this method could return
131
* return a null in some implementations if there is a batch at the top
132
* of the redo stack.
133
*/
134
nsITransaction peekRedoStack();
135
136
/**
137
* Adds a listener to the transaction manager's notification list. Listeners
138
* are notified whenever a transaction is done, undone, or redone.
139
* <P>
140
* The listener's AddRef() method is called.
141
* @param aListener the lister to add.
142
*/
143
void AddListener(in nsITransactionListener aListener);
144
145
/**
146
* Removes a listener from the transaction manager's notification list.
147
* <P>
148
* The listener's Release() method is called.
149
* @param aListener the lister to remove.
150
*/
151
void RemoveListener(in nsITransactionListener aListener);
152
153
%{C++
154
/**
155
* AsTransactionManager() returns a pointer to TransactionManager class.
156
*
157
* In order to avoid circular dependency issues, this method is defined
158
* in mozilla/TransactionManager.h. Consumers need to #include that header.
159
*/
160
inline mozilla::TransactionManager* AsTransactionManager();
161
%}
162
};