comparison org.eclipse.text/src/org/eclipse/text/undo/IDocumentUndoManager.d @ 12:bc29606a740c

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