Mercurial > projects > dwt2
comparison org.eclipse.core.commands/src/org/eclipse/core/commands/operations/IOperationHistory.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 |
comparison
equal
deleted
inserted
replaced
11:43904fec5dca | 12:bc29606a740c |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2005, 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.core.commands.operations.IOperationHistory; | |
14 | |
15 import org.eclipse.core.commands.ExecutionException; | |
16 import org.eclipse.core.internal.commands.operations.GlobalUndoContext; | |
17 import org.eclipse.core.runtime.IAdaptable; | |
18 import org.eclipse.core.runtime.IProgressMonitor; | |
19 import org.eclipse.core.runtime.IStatus; | |
20 | |
21 import org.eclipse.core.commands.operations.IUndoContext; | |
22 import org.eclipse.core.commands.operations.IUndoableOperation; | |
23 import org.eclipse.core.commands.operations.IOperationApprover; | |
24 import org.eclipse.core.commands.operations.IOperationApprover2; | |
25 import org.eclipse.core.commands.operations.IOperationHistoryListener; | |
26 import org.eclipse.core.commands.operations.ICompositeOperation; | |
27 import org.eclipse.core.commands.operations.OperationStatus; | |
28 | |
29 import java.lang.all; | |
30 | |
31 static this(){ | |
32 IOperationHistory.GLOBAL_UNDO_CONTEXT = new GlobalUndoContext(); | |
33 IOperationHistory.NOTHING_TO_REDO_STATUS = new OperationStatus( | |
34 IStatus.INFO, OperationStatus.DEFAULT_PLUGIN_ID, | |
35 OperationStatus.NOTHING_TO_REDO, "No operation to redo", null); //$NON-NLS-1$ | |
36 IOperationHistory.NOTHING_TO_UNDO_STATUS = new OperationStatus( | |
37 IStatus.INFO, OperationStatus.DEFAULT_PLUGIN_ID, | |
38 OperationStatus.NOTHING_TO_UNDO, "No operation to undo", null); //$NON-NLS-1$ | |
39 IOperationHistory.OPERATION_INVALID_STATUS = new OperationStatus( | |
40 IStatus.ERROR, OperationStatus.DEFAULT_PLUGIN_ID, | |
41 OperationStatus.OPERATION_INVALID, "Operation is not valid", null); //$NON-NLS-1$ | |
42 } | |
43 | |
44 /** | |
45 * <p> | |
46 * IOperationHistory tracks a history of operations that can be undone or | |
47 * redone. Operations are added to the history once they have been initially | |
48 * executed. Clients may choose whether to have the operations history perform | |
49 * the initial execution or to simply add an already-executed operation to the | |
50 * history. | |
51 * </p> | |
52 * <p> | |
53 * Once operations are added to the history, the methods | |
54 * {@link #canRedo(IUndoContext)} and {@link #canUndo(IUndoContext)} are used to | |
55 * determine whether there is an operation available for undo and redo in a | |
56 * given undo context. The context-based protocol implies that there is only one | |
57 * operation that can be undone or redone at a given time in a given context. | |
58 * This is typical of a linear undo model, when only the most recently executed | |
59 * operation is available for undo. When this protocol is used, a linear model | |
60 * is enforced by the history. | |
61 * </p> | |
62 * <p> | |
63 * It is up to clients to determine how to maintain a history that is invalid or | |
64 * stale. For example, when the most recent operation for a context cannot be | |
65 * performed, clients may wish to dispose the history for that context. | |
66 * </p> | |
67 * <p> | |
68 * Additional protocol allows direct undo and redo of a specified operation, | |
69 * regardless of its position in the history. When a more flexible undo model is | |
70 * supported, these methods can be implemented to undo and redo directly | |
71 * specified operations. If an implementer of IOperationHistory does not allow | |
72 * direct undo and redo, these methods can return a status indicating that it is | |
73 * not allowed. | |
74 * </p> | |
75 * <p> | |
76 * Listeners ({@link IOperationHistoryListener}) can listen for notifications | |
77 * about changes in the history (operations added or removed), and for | |
78 * notification before and after any operation is executed, undone or redone. | |
79 * Notification of operation execution only occurs when clients direct the | |
80 * history to execute the operation. If the operation is added after it is | |
81 * executed, there can be no notification of its execution. | |
82 * </p> | |
83 * <p> | |
84 * {@link IOperationApprover} defines an interface for approving an undo or redo | |
85 * before it occurs. This is useful for injecting policy-decisions into the undo | |
86 * model - whether direct undo and redo are supported, or warning the user about | |
87 * certain kinds of operations. It can also be used when clients maintain state | |
88 * related to an operation and need to determine whether an undo or redo will | |
89 * cause any conflicts with their local state. | |
90 * </p> | |
91 * | |
92 * @since 3.1 | |
93 */ | |
94 public interface IOperationHistory { | |
95 | |
96 /** | |
97 * An operation is to be opened or closed for execution. (value is 1). | |
98 */ | |
99 public static const int EXECUTE = 1; | |
100 | |
101 /** | |
102 * An operation is to be opened for undo. (value is 2). | |
103 */ | |
104 public static const int UNDO = 2; | |
105 | |
106 /** | |
107 * An operation is to be opened for redo. (value is 3). | |
108 */ | |
109 public static const int REDO = 3; | |
110 | |
111 /** | |
112 * An undo context that can be used to refer to the global undo history. | |
113 * This context is not intended to be assigned to operations. Instead, it is | |
114 * used for querying the history or performing an undo or redo on the entire | |
115 * history, regardless of each operation's undo contexts. | |
116 */ | |
117 public static /+const+/ IUndoContext GLOBAL_UNDO_CONTEXT; | |
118 | |
119 /** | |
120 * An operation info status describing the condition that there is no | |
121 * available operation for redo. | |
122 */ | |
123 public static /+const+/ IStatus NOTHING_TO_REDO_STATUS; //$NON-NLS-1$ | |
124 | |
125 /** | |
126 * An operation info status describing the condition that there is no | |
127 * available operation for undo. | |
128 */ | |
129 public static /+const+/ IStatus NOTHING_TO_UNDO_STATUS; //$NON-NLS-1$ | |
130 | |
131 /** | |
132 * An operation error status describing the condition that the operation | |
133 * available for execution, undo or redo is not in a valid state for the | |
134 * action to be performed. | |
135 */ | |
136 public static /+const+/ IStatus OPERATION_INVALID_STATUS; //$NON-NLS-1$ | |
137 | |
138 /** | |
139 * <p> | |
140 * Add the specified operation to the history without executing it. The | |
141 * operation should have already been executed by the time it is added to | |
142 * the history. Listeners will be notified that the operation was added to | |
143 * the history (<code>OPERATION_ADDED</code>). | |
144 * </p> | |
145 * | |
146 * @param operation | |
147 * the operation to be added to the history | |
148 */ | |
149 void add(IUndoableOperation operation); | |
150 | |
151 /** | |
152 * <p> | |
153 * Add the specified approver to the list of operation approvers consulted | |
154 * by the operation history before an undo or redo is attempted. | |
155 * </p> | |
156 * | |
157 * @param approver | |
158 * the IOperationApprover to be added as an approver.the instance | |
159 * to remove. Must not be <code>null</code>. If an attempt is | |
160 * made to register an instance which is already registered with | |
161 * this instance, this method has no effect. | |
162 * | |
163 * @see org.eclipse.core.commands.operations.IOperationApprover | |
164 */ | |
165 void addOperationApprover(IOperationApprover approver); | |
166 | |
167 /** | |
168 * <p> | |
169 * Add the specified listener to the list of operation history listeners | |
170 * that are notified about changes in the history or operations that are | |
171 * executed, undone, or redone. | |
172 * </p> | |
173 * | |
174 * @param listener | |
175 * the IOperationHistoryListener to be added as a listener. Must | |
176 * not be <code>null</code>. If an attempt is made to register | |
177 * an instance which is already registered with this instance, | |
178 * this method has no effect. | |
179 * | |
180 * @see org.eclipse.core.commands.operations.IOperationHistoryListener | |
181 * @see org.eclipse.core.commands.operations.OperationHistoryEvent | |
182 */ | |
183 void addOperationHistoryListener(IOperationHistoryListener listener); | |
184 | |
185 /** | |
186 * <p> | |
187 * Close the current operation. If the operation has successfully completed, | |
188 * send listeners a <code>DONE</code>, <code>UNDONE</code>, or | |
189 * <code>REDONE</code> notification, depending on the mode. Otherwise send | |
190 * an <code>OPERATION_NOT_OK</code> notification. Add the operation to the | |
191 * history if specified and send an <code>OPERATION_ADDED</code> | |
192 * notification. | |
193 * </p> | |
194 * <p> | |
195 * Any operations that are executed and added after this operation is closed | |
196 * will no longer be considered part of this operation. | |
197 * </p> | |
198 * <p> | |
199 * This method has no effect if the caller has not previously called | |
200 * {@link #openOperation}. | |
201 * </p> | |
202 * | |
203 * @param operationOK | |
204 * <code>true</code> if the operation successfully completed. | |
205 * Listeners should be notified with <code>DONE</code>, | |
206 * <code>UNDONE</code>, or <code>REDONE</code>. | |
207 * <code>false</code> if the operation did not successfully | |
208 * complete. Listeners should be notified with | |
209 * <code>OPERATION_NOT_OK</code>. | |
210 * @param addToHistory | |
211 * <code>true</code> if the operation should be added to the | |
212 * history, <code>false</code> if it should not. If the | |
213 * <code>operationOK</code> parameter is <code>false</code>, | |
214 * the operation will never be added to the history. | |
215 * @param mode | |
216 * the mode the operation was opened in. Can be one of | |
217 * <code>EXECUTE</code>, <code>UNDO</code>, or | |
218 * <code>REDO</code>. This determines what notifications are | |
219 * sent. | |
220 */ | |
221 void closeOperation(bool operationOK, bool addToHistory, int mode); | |
222 | |
223 /** | |
224 * <p> | |
225 * Return whether there is a valid redoable operation available in the given | |
226 * context. | |
227 * </p> | |
228 * | |
229 * @param context | |
230 * the context to be checked | |
231 * @return <code>true</code> if there is a redoable operation, | |
232 * <code>false</code> otherwise. | |
233 */ | |
234 | |
235 bool canRedo(IUndoContext context); | |
236 | |
237 /** | |
238 * <p> | |
239 * Return whether there is a valid undoable operation available in the given | |
240 * context | |
241 * </p> | |
242 * | |
243 * @param context | |
244 * the context to be checked | |
245 * @return <code>true</code> if there is an undoable operation, | |
246 * <code>false</code> otherwise. | |
247 */ | |
248 bool canUndo(IUndoContext context); | |
249 | |
250 /** | |
251 * <p> | |
252 * Dispose of the specified context in the history. All operations that have | |
253 * only the given context will be disposed. References to the context in | |
254 * operations that have more than one context will also be removed. A | |
255 * history notification for the removal of each operation being disposed | |
256 * will be sent. | |
257 * </p> | |
258 * | |
259 * @param context | |
260 * the context to be disposed | |
261 * @param flushUndo | |
262 * <code>true</code> if the context should be flushed from the | |
263 * undo history, <code>false</code> if it should not | |
264 * @param flushRedo | |
265 * <code>true</code> if the context should be flushed from the | |
266 * redo history, <code>false</code> if it should not. | |
267 * @param flushContext | |
268 * <code>true</code> if the context is no longer in use and | |
269 * references to it should be flushed. | |
270 */ | |
271 void dispose(IUndoContext context, bool flushUndo, bool flushRedo, | |
272 bool flushContext); | |
273 | |
274 /** | |
275 * <p> | |
276 * Execute the specified operation and add it to the operations history if | |
277 * successful. This method is used by clients who wish operation history | |
278 * listeners to receive notifications before and after the execution of the | |
279 * operation. Execution of the operation is subject to approval by any | |
280 * registered {@link IOperationApprover2}. If execution is approved, | |
281 * listeners will be notified before (<code>ABOUT_TO_EXECUTE</code>) and | |
282 * after (<code>DONE</code> or <code>OPERATION_NOT_OK</code>). | |
283 * </p> | |
284 * <p> | |
285 * If the operation successfully executes, an additional notification that | |
286 * the operation has been added to the history (<code>OPERATION_ADDED</code>) | |
287 * will be sent. | |
288 * </p> | |
289 * | |
290 * @param operation | |
291 * the operation to be executed and then added to the history | |
292 * | |
293 * @param monitor | |
294 * the progress monitor to be used (or <code>null</code>) | |
295 * during the operation. | |
296 * | |
297 * @param info | |
298 * the IAdaptable (or <code>null</code>) provided by the | |
299 * caller in order to supply UI information for prompting the | |
300 * user if necessary. When this parameter is not | |
301 * <code>null</code>, it should minimally contain an adapter | |
302 * for the org.eclipse.swt.widgets.Shell.class. | |
303 * | |
304 * @return the IStatus indicating whether the execution succeeded. | |
305 * | |
306 * <p> | |
307 * The severity code in the returned status describes whether the operation | |
308 * succeeded and whether it was added to the history. <code>OK</code> | |
309 * severity indicates that the execute operation was successful and that the | |
310 * operation has been added to the history. Listeners will receive | |
311 * notifications about the operation's success (<code>DONE</code>) and | |
312 * about the operation being added to the history (<code>OPERATION_ADDED</code>). | |
313 * </p> | |
314 * <p> | |
315 * <code>CANCEL</code> severity indicates that the user cancelled the | |
316 * operation and that the operation was not added to the history. | |
317 * <code>ERROR</code> severity indicates that the operation did not | |
318 * successfully execute and that it was not added to the history. Any other | |
319 * severity code is not specifically interpreted by the history, and the | |
320 * operation will not be added to the history. For all severities other than | |
321 * <code>OK</code>, listeners will receive the | |
322 * <code>OPERATION_NOT_OK</code> notification instead of the | |
323 * <code>DONE</code> notification if the execution was approved and | |
324 * attempted. | |
325 * </p> | |
326 * | |
327 * @throws ExecutionException | |
328 * if an exception occurred during execution. | |
329 * | |
330 */ | |
331 IStatus execute(IUndoableOperation operation, IProgressMonitor monitor, | |
332 IAdaptable info); | |
333 | |
334 /** | |
335 * <p> | |
336 * Return the limit on the undo and redo history for a particular context. | |
337 * </p> | |
338 * | |
339 * @param context | |
340 * the context whose limit is requested | |
341 * | |
342 * @return the undo and redo history limit for the specified context. | |
343 */ | |
344 int getLimit(IUndoContext context); | |
345 | |
346 /** | |
347 * <p> | |
348 * Get the array of operations in the redo history for a the specified undo | |
349 * context. The operations are in the order that they were added to the | |
350 * history, with the most recently undone operation appearing last in the | |
351 * array. This history is used LIFO (last in, first out) when successive | |
352 * "Redo" commands are invoked. | |
353 * | |
354 * </p> | |
355 * | |
356 * @param context | |
357 * the context for the redo | |
358 * @return the array of operations in the history | |
359 */ | |
360 IUndoableOperation[] getRedoHistory(IUndoContext context); | |
361 | |
362 /** | |
363 * <p> | |
364 * Get the operation that will next be redone in the given undo context. | |
365 * </p> | |
366 * | |
367 * @param context | |
368 * the context for the redo | |
369 * @return the operation to be redone or <code>null</code> if there is no | |
370 * operation available. There is no guarantee that the returned | |
371 * operation is valid for redo. | |
372 */ | |
373 IUndoableOperation getRedoOperation(IUndoContext context); | |
374 | |
375 /** | |
376 * <p> | |
377 * Get the array of operations in the undo history for the specified undo | |
378 * context. The operations are in the order that they were added to the | |
379 * history, with the most recently added operation appearing last in the | |
380 * array. This history is used LIFO (last in, first out) when successive | |
381 * "Undo" commands are invoked. | |
382 * </p> | |
383 * | |
384 * @param context | |
385 * the context for the undo | |
386 * @return the array of operations in the history | |
387 */ | |
388 IUndoableOperation[] getUndoHistory(IUndoContext context); | |
389 | |
390 /** | |
391 * <p> | |
392 * Open this composite operation and consider it an operation that contains | |
393 * other related operations. Consider all operations that are subsequently | |
394 * executed or added to be part of this operation. When an operation is | |
395 * opened, listeners will immediately receive a notification for the opened | |
396 * operation. The specific notification depends on the mode in which the | |
397 * operation is opened (<code>ABOUT_TO_EXECUTE</code>, | |
398 * <code>ABOUT_TO_UNDO</code>, <code>ABOUT_TO_REDO</code>). | |
399 * Notifications for any other execute or add while this operation is open | |
400 * will not occur. Instead, those operations will be added to the current | |
401 * operation. | |
402 * </p> | |
403 * <p> | |
404 * Note: This method is intended to be used by legacy undo frameworks that | |
405 * do not expect related undo operations to appear in the same undo history | |
406 * as the triggering undo operation. When an operation is open, any | |
407 * subsequent requests to execute, add, undo, or redo another operation will | |
408 * result in that operation being added to the open operation. Once the | |
409 * operation is closed, the composite will be considered an atomic | |
410 * operation. Clients should not modify the composite directly (by adding | |
411 * and removing children) while it is open. | |
412 * </p> | |
413 * <p> | |
414 * When a composite is open, operations that are added to the history will | |
415 * be considered part of the open operation instead. Operations that are | |
416 * executed while a composite is open will first be executed and then added | |
417 * to the composite. | |
418 * </p> | |
419 * <p> | |
420 * Open operations cannot be nested. If this method is called when a | |
421 * different operation is open, it is presumed to be an application coding | |
422 * error and this method will throw an IllegalStateException. | |
423 * </p> | |
424 * | |
425 * @param operation | |
426 * the composite operation to be considered as the parent for all | |
427 * subsequent operations. | |
428 * @param mode | |
429 * the mode the operation is executing in. Can be one of | |
430 * <code>EXECUTE</code>, <code>UNDO</code>, or | |
431 * <code>REDO</code>. This determines what notifications are | |
432 * sent. | |
433 */ | |
434 void openOperation(ICompositeOperation operation, int mode); | |
435 | |
436 /** | |
437 * <p> | |
438 * The specified operation has changed in some way since it was added to the | |
439 * operation history. Notify listeners with an OPERATION_CHANGED event. | |
440 * </p> | |
441 * | |
442 * @param operation | |
443 * the operation that has changed. | |
444 * | |
445 */ | |
446 void operationChanged(IUndoableOperation operation); | |
447 | |
448 /** | |
449 * <p> | |
450 * Get the operation that will next be undone in the given undo context. | |
451 * </p> | |
452 * | |
453 * @param context | |
454 * the context for the undo | |
455 * @return the operation to be undone or <code>null</code> if there is no | |
456 * operation available. There is no guarantee that the available | |
457 * operation is valid for the undo. | |
458 */ | |
459 IUndoableOperation getUndoOperation(IUndoContext context); | |
460 | |
461 /** | |
462 * <p> | |
463 * Redo the most recently undone operation in the given context. The redo of | |
464 * the operation is subject to approval by any registered | |
465 * {@link IOperationApprover} before it is attempted. | |
466 * </p> | |
467 * | |
468 * @param context | |
469 * the context to be redone | |
470 * @param monitor | |
471 * the progress monitor to be used for the redo, or | |
472 * <code>null</code> if no progress monitor is provided. | |
473 * @param info | |
474 * the IAdaptable (or <code>null</code>) provided by the | |
475 * caller in order to supply UI information for prompting the | |
476 * user if necessary. When this parameter is not | |
477 * <code>null</code>, it should minimally contain an adapter | |
478 * for the org.eclipse.swt.widgets.Shell.class. | |
479 * @return the IStatus indicating whether the redo succeeded. | |
480 * | |
481 * <p> | |
482 * The severity code in the returned status describes whether the operation | |
483 * succeeded and whether it remains in the history. <code>OK</code> | |
484 * severity indicates that the redo operation was successful and (since | |
485 * release 3.2), that the operation will be placed in the undo history. | |
486 * (Prior to 3.2, a successfully redone operation would not be placed on the | |
487 * undo history if it could not be undone. Since 3.2, this is relaxed, and | |
488 * all successfully redone operations are placed in the undo history.) | |
489 * Listeners will receive the <code>REDONE</code> notification. | |
490 * </p> | |
491 * <p> | |
492 * Other severity codes (<code>CANCEL</code>, <code>ERROR</code>, | |
493 * <code>INFO</code>, etc.) are not specifically interpreted by the | |
494 * history. The operation will remain in the history and the returned status | |
495 * is simply passed back to the caller. For all severities other than | |
496 * <code>OK</code>, listeners will receive the | |
497 * <code>OPERATION_NOT_OK</code> notification instead of the | |
498 * <code>REDONE</code> notification if the redo was approved and | |
499 * attempted. | |
500 * </p> | |
501 * | |
502 * @throws ExecutionException | |
503 * if an exception occurred during redo. | |
504 * | |
505 */ | |
506 IStatus redo(IUndoContext context, IProgressMonitor monitor, IAdaptable info); | |
507 | |
508 /** | |
509 * <p> | |
510 * Redo the specified operation. The redo of the operation is subject to | |
511 * approval by any registered {@link IOperationApprover} before it is | |
512 * attempted. | |
513 * </p> | |
514 * | |
515 * @param operation | |
516 * the operation to be redone | |
517 * @param monitor | |
518 * the progress monitor to be used for the redo, or code>null</code> | |
519 * if no progress monitor is provided | |
520 * @param info | |
521 * the IAdaptable (or <code>null</code>) provided by the | |
522 * caller in order to supply UI information for prompting the | |
523 * user if necessary. When this parameter is not <code>null</code>, | |
524 * it should minimally contain an adapter for the | |
525 * org.eclipse.swt.widgets.Shell.class. | |
526 * | |
527 * @return the IStatus indicating whether the redo succeeded. | |
528 * | |
529 * <p> | |
530 * The severity code in the returned status describes whether the operation | |
531 * succeeded and whether it remains in the history. <code>OK</code> | |
532 * severity indicates that the redo operation was successful, and (since | |
533 * release 3.2), that the operation will be placed in the undo history. | |
534 * (Prior to 3.2, a successfully redone operation would not be placed on the | |
535 * undo history if it could not be undone. Since 3.2, this is relaxed, and | |
536 * all successfully redone operations are placed in the undo history.) | |
537 * Listeners will receive the <code>REDONE</code> notification. | |
538 * </p> | |
539 * <p> | |
540 * Other severity codes (<code>CANCEL</code>, <code>ERROR</code>, | |
541 * <code>INFO</code>, etc.) are not specifically interpreted by the | |
542 * history. The operation will remain in the history and the returned status | |
543 * is simply passed back to the caller. For all severities other than <code>OK</code>, | |
544 * listeners will receive the <code>OPERATION_NOT_OK</code> notification | |
545 * instead of the <code>REDONE</code> notification if the redo was | |
546 * approved and attempted. | |
547 * </p> | |
548 * | |
549 * @throws ExecutionException | |
550 * if an exception occurred during redo. | |
551 */ | |
552 IStatus redoOperation(IUndoableOperation operation, | |
553 IProgressMonitor monitor, IAdaptable info); | |
554 | |
555 /** | |
556 * <p> | |
557 * Remove the specified operation approver from the list of operation | |
558 * approvers that are consulted before an operation is undone or redone. | |
559 * </p> | |
560 * | |
561 * @param approver | |
562 * the IOperationApprover to be removed. Must not be | |
563 * <code>null</code>. If an attempt is made to remove an | |
564 * instance which is not already registered with this instance, | |
565 * this method has no effect. | |
566 */ | |
567 void removeOperationApprover(IOperationApprover approver); | |
568 | |
569 /** | |
570 * <p> | |
571 * Remove the specified listener from the list of operation history | |
572 * listeners. | |
573 * </p> | |
574 * | |
575 * @param listener | |
576 * The IOperationHistoryListener to be removed. Must not be | |
577 * <code>null</code>. If an attempt is made to remove an | |
578 * instance which is not already registered with this instance, | |
579 * this method has no effect. | |
580 */ | |
581 void removeOperationHistoryListener(IOperationHistoryListener listener); | |
582 | |
583 /** | |
584 * <p> | |
585 * Replace the specified operation in the undo or redo history with the | |
586 * provided list of replacements. This protocol is typically used when a | |
587 * composite is broken up into its atomic parts. The replacements will be | |
588 * inserted so that the first replacement will be the first of the | |
589 * replacements to be undone or redone. Listeners will be notified about the | |
590 * removal of the replaced element and the addition of each replacement. | |
591 * </p> | |
592 * | |
593 * @param operation | |
594 * The IUndoableOperation to be replaced | |
595 * @param replacements | |
596 * the array of IUndoableOperation to replace the first operation | |
597 */ | |
598 void replaceOperation(IUndoableOperation operation, | |
599 IUndoableOperation[] replacements); | |
600 | |
601 /** | |
602 * <p> | |
603 * Set the limit on the undo and redo history for a particular context. | |
604 * </p> | |
605 * | |
606 * @param context | |
607 * the context whose limit is being set. | |
608 * | |
609 * @param limit | |
610 * the maximum number of operations that should be kept in the | |
611 * undo or redo history for the specified context. Must not be | |
612 * negative. | |
613 */ | |
614 void setLimit(IUndoContext context, int limit); | |
615 | |
616 /** | |
617 * <p> | |
618 * Undo the most recently executed operation in the given context. The undo | |
619 * of the operation is subject to approval by any registered | |
620 * {@link IOperationApprover} before it is attempted. | |
621 * </p> | |
622 * | |
623 * @param context | |
624 * the context to be undone | |
625 * @param monitor | |
626 * the progress monitor to be used for the undo, or | |
627 * <code>null</code> if no progress monitor is provided. | |
628 * @param info | |
629 * the IAdaptable (or <code>null</code>) provided by the | |
630 * caller in order to supply UI information for prompting the | |
631 * user if necessary. When this parameter is not | |
632 * <code>null</code>, it should minimally contain an adapter | |
633 * for the org.eclipse.swt.widgets.Shell.class. | |
634 * | |
635 * @return the IStatus indicating whether the undo succeeded. | |
636 * | |
637 * <p> | |
638 * The severity code in the returned status describes whether the operation | |
639 * succeeded and whether it remains in the history. <code>OK</code> | |
640 * severity indicates that the undo operation was successful, and (since | |
641 * release 3.2), that the operation will be placed on the redo history. | |
642 * (Prior to 3.2, a successfully undone operation would not be placed on the | |
643 * redo history if it could not be redone. Since 3.2, this is relaxed, and | |
644 * all successfully undone operations are placed in the redo history.) | |
645 * Listeners will receive the <code>UNDONE</code> notification. | |
646 * </p> | |
647 * <p> | |
648 * Other severity codes (<code>CANCEL</code>, <code>ERROR</code>, | |
649 * <code>INFO</code>, etc.) are not specifically interpreted by the | |
650 * history. The operation will remain in the history and the returned status | |
651 * is simply passed back to the caller. For all severities other than | |
652 * <code>OK</code>, listeners will receive the | |
653 * <code>OPERATION_NOT_OK</code> notification instead of the | |
654 * <code>UNDONE</code> notification if the undo was approved and | |
655 * attempted. | |
656 * </p> | |
657 * | |
658 * @throws ExecutionException | |
659 * if an exception occurred during undo. | |
660 */ | |
661 | |
662 IStatus undo(IUndoContext context, IProgressMonitor monitor, IAdaptable info); | |
663 | |
664 /** | |
665 * <p> | |
666 * Undo the specified operation. The undo of the operation is subject to | |
667 * approval by any registered {@link IOperationApprover} before it is | |
668 * attempted. | |
669 * </p> | |
670 * | |
671 * @param operation | |
672 * the operation to be undone | |
673 * @param monitor | |
674 * the progress monitor to be used for the undo, or | |
675 * <code>null</code> if no progress monitor is provided | |
676 * @param info | |
677 * the IAdaptable (or <code>null</code>) provided by the | |
678 * caller in order to supply UI information for prompting the | |
679 * user if necessary. When this parameter is not | |
680 * <code>null</code>, it should minimally contain an adapter | |
681 * for the org.eclipse.swt.widgets.Shell.class. | |
682 * | |
683 * @return the IStatus indicating whether the undo succeeded. | |
684 * | |
685 * <p> | |
686 * The severity code in the returned status describes whether the operation | |
687 * succeeded and whether it remains in the history. <code>OK</code> | |
688 * severity indicates that the undo operation was successful, and (since | |
689 * release 3.2), that the operation will be placed on the redo history. | |
690 * (Prior to 3.2, a successfully undone operation would not be placed on the | |
691 * redo history if it could not be redone. Since 3.2, this is relaxed, and | |
692 * all successfully undone operations are placed in the redo history.) | |
693 * Listeners will receive the <code>UNDONE</code> notification. | |
694 * </p> | |
695 * <p> | |
696 * Other severity codes (<code>CANCEL</code>, <code>ERROR</code>, | |
697 * <code>INFO</code>, etc.) are not specifically interpreted by the | |
698 * history. The operation will remain in the history and the returned status | |
699 * is simply passed back to the caller. For all severities other than | |
700 * <code>OK</code>, listeners will receive the | |
701 * <code>OPERATION_NOT_OK</code> notification instead of the | |
702 * <code>UNDONE</code> notification if the undo was approved and | |
703 * attempted. | |
704 * </p> | |
705 * | |
706 * @throws ExecutionException | |
707 * if an exception occurred during undo. | |
708 */ | |
709 IStatus undoOperation(IUndoableOperation operation, | |
710 IProgressMonitor monitor, IAdaptable info); | |
711 | |
712 } |