Mercurial > projects > dwt-addons
annotate dwtx/text/undo/IDocumentUndoManager.d @ 159:7926b636c282
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Wed, 27 Aug 2008 01:57:58 +0200 |
parents | 93a6ec48fd28 |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2006 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.text.undo.IDocumentUndoManager; | |
14 | |
159 | 15 // import dwtx.text.undo.DocumentUndoManager; // packageimport |
16 // import dwtx.text.undo.DocumentUndoManagerRegistry; // packageimport | |
131 | 17 import dwtx.text.undo.DocumentUndoEvent; // packageimport |
18 import dwtx.text.undo.IDocumentUndoListener; // packageimport | |
159 | 19 // import dwtx.text.undo.UndoMessages; // packageimport |
131 | 20 |
21 | |
129 | 22 import dwt.dwthelper.utils; |
23 | |
24 import dwtx.core.commands.ExecutionException; | |
25 import dwtx.core.commands.operations.IUndoContext; | |
26 | |
27 /** | |
28 * Interface for a document undo manager. Tracks changes in a document and | |
29 * builds a history of text commands that describe the undoable changes to the | |
30 * document. | |
31 * <p> | |
32 * Clients must explicitly connect to the undo manager to express their interest | |
33 * in the undo history. Clients should disconnect from the undo manager when | |
34 * they are no longer interested in tracking the undo history. If there are no | |
35 * clients connected to the undo manager, it will not track the document's | |
36 * changes and will dispose of any history that was previously kept.</p> | |
37 * <p> | |
38 * Clients may also listen to the undo manager for notifications before and | |
39 * after undo or redo events are performed. Clients must connect to the undo | |
40 * manager in addition to registering listeners.</p> | |
41 * <p> | |
42 * Clients may implement this interface. | |
43 * </p> | |
159 | 44 * |
129 | 45 * @see DocumentUndoManagerRegistry |
46 * @see IDocumentUndoListener | |
47 * @see dwtx.jface.text.IDocument | |
48 * @since 3.2 | |
49 */ | |
50 public interface IDocumentUndoManager { | |
51 | |
52 /** | |
53 * Adds the specified listener to the list of document undo listeners that | |
54 * are notified before and after changes are undone or redone in the | |
55 * document. This method has no effect if the instance being added is | |
56 * already in the list. | |
57 * <p> | |
58 * Notifications will not be received if there are no clients connected to | |
59 * the receiver. Registering a document undo listener does not implicitly | |
60 * connect the listener to the receiver.</p> | |
61 * <p> | |
62 * Document undo listeners must be prepared to receive notifications from a | |
63 * background thread. Any UI access occurring inside the implementation must | |
64 * be properly synchronized using the techniques specified by the client's | |
65 * widget library.</p> | |
159 | 66 * |
129 | 67 * @param listener the document undo listener to be added as a listener |
68 */ | |
69 void addDocumentUndoListener(IDocumentUndoListener listener); | |
70 | |
71 /** | |
72 * Removes the specified listener from the list of document undo listeners. | |
73 * <p> | |
74 * Removing a listener which is not registered has no effect | |
75 * </p> | |
159 | 76 * |
129 | 77 * @param listener the document undo listener to be removed |
78 */ | |
79 void removeDocumentUndoListener(IDocumentUndoListener listener); | |
80 | |
81 /** | |
82 * Returns the undo context registered for this document | |
159 | 83 * |
129 | 84 * @return the undo context registered for this document |
85 */ | |
86 IUndoContext getUndoContext(); | |
87 | |
88 /** | |
89 * Closes the currently open text edit and open a new one. | |
90 */ | |
91 void commit(); | |
92 | |
93 /** | |
94 * Connects to the undo manager. Used to signify that a client is monitoring | |
95 * the history kept by the undo manager. This message has no effect if the | |
96 * client is already connected. | |
159 | 97 * |
129 | 98 * @param client the object connecting to the undo manager |
99 */ | |
100 void connect(Object client); | |
101 | |
102 /** | |
103 * Disconnects from the undo manager. Used to signify that a client is no | |
104 * longer monitoring the history kept by the undo manager. If all clients | |
105 * have disconnected from the undo manager, the undo history will be | |
106 * deleted. | |
159 | 107 * |
129 | 108 * @param client the object disconnecting from the undo manager |
109 */ | |
110 void disconnect(Object client); | |
111 | |
112 /** | |
113 * Signals the undo manager that all subsequent changes until | |
114 * <code>endCompoundChange</code> is called are to be undone in one piece. | |
115 */ | |
116 void beginCompoundChange(); | |
117 | |
118 /** | |
119 * Signals the undo manager that the sequence of changes which started with | |
120 * <code>beginCompoundChange</code> has been finished. All subsequent | |
121 * changes are considered to be individually undo-able. | |
122 */ | |
123 void endCompoundChange(); | |
124 | |
125 /** | |
126 * Sets the limit of the undo history to the specified value. The provided | |
127 * limit will supersede any previously set limit. | |
159 | 128 * |
129 | 129 * @param undoLimit the length of this undo manager's history |
130 */ | |
131 void setMaximalUndoLevel(int undoLimit); | |
159 | 132 |
129 | 133 /** |
134 * Resets the history of the undo manager. After that call, | |
135 * there aren't any undo-able or redo-able text changes. | |
136 */ | |
137 void reset(); | |
138 | |
139 /** | |
140 * Returns whether at least one text change can be rolled back. | |
141 * | |
142 * @return <code>true</code> if at least one text change can be rolled back | |
143 */ | |
144 bool undoable(); | |
145 | |
146 /** | |
147 * Returns whether at least one text change can be repeated. A text change | |
148 * can be repeated only if it was executed and rolled back. | |
149 * | |
150 * @return <code>true</code> if at least on text change can be repeated | |
151 */ | |
152 bool redoable(); | |
153 | |
154 /** | |
155 * Rolls back the most recently executed text change. | |
159 | 156 * |
129 | 157 * @throws ExecutionException if an exception occurred during undo |
158 */ | |
139
93a6ec48fd28
Regexp throws removal in interfaces
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
159 void undo() ; |
129 | 160 |
161 /** | |
162 * Repeats the most recently rolled back text change. | |
159 | 163 * |
129 | 164 * @throws ExecutionException if an exception occurred during redo |
165 */ | |
139
93a6ec48fd28
Regexp throws removal in interfaces
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
166 void redo() ; |
129 | 167 |
168 /** | |
169 * Transfers the undo history from the specified document undo manager to | |
159 | 170 * this undo manager. This message should only be used when it is known |
129 | 171 * that the content of the document of the original undo manager when the |
159 | 172 * last undo operation was recorded is the same as this undo manager's |
129 | 173 * current document content, since the undo history is based on document |
159 | 174 * indexes. It is the responsibility of the caller |
175 * to ensure that this call is used correctly. | |
176 * | |
129 | 177 * @param manager the document undo manger whose history is to be transferred to the receiver |
178 */ | |
179 public void transferUndoHistory(IDocumentUndoManager manager); | |
180 | |
181 } |