KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > IUndoManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 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  *******************************************************************************/

11 package org.eclipse.jface.text;
12
13 /**
14  * An undo manager is connected to at most one
15  * {@link org.eclipse.jface.text.ITextViewer}.
16  * <p>
17  * It monitors the text viewer and keeps a history of the changes applied to the
18  * viewer. The undo manager groups those changes into user interactions which on
19  * an undo request are rolled back in one atomic change.</p>
20  * <p>
21  * In order to provide backward compatibility for clients of
22  * <code>IUndoManager</code>, extension interfaces are used as a means of
23  * evolution. The following extension interfaces exist:
24  * <ul>
25  * <li>{@link org.eclipse.jface.text.IUndoManagerExtension} since version 3.1
26  * introducing access to the undo context.</li>
27  * </ul></p>
28  * <p>
29  * Clients may implement this interface or use the standard implementation
30  * <code>TextViewerUndoManager</code>.
31  * </p>
32  *
33  * @see TextViewerUndoManager
34  * @see IUndoManagerExtension
35  */

36 public interface IUndoManager {
37
38     /**
39      * Connects this undo manager to the given text viewer.
40      *
41      * @param viewer the viewer the undo manager is connected to
42      */

43     void connect(ITextViewer viewer);
44
45     /**
46      * Disconnects this undo manager from its text viewer.
47      * If this undo manager hasn't been connected before this
48      * operation has no effect.
49      */

50     void disconnect();
51
52     /**
53      * Signals the undo manager that all subsequent changes until
54      * <code>endCompoundChange</code> is called are to be undone in one piece.
55      */

56     void beginCompoundChange();
57
58     /**
59      * Signals the undo manager that the sequence of changes which started with
60      * <code>beginCompoundChange</code> has been finished. All subsequent changes
61      * are considered to be individually undo-able.
62      */

63     void endCompoundChange();
64
65     /**
66      * Resets the history of the undo manager. After that call,
67      * there aren't any undo-able or redo-able text changes.
68      */

69     void reset();
70
71     /**
72      * The given parameter determines the maximal length of the history
73      * remembered by the undo manager.
74      *
75      * @param undoLevel the length of this undo manager's history
76      */

77     void setMaximalUndoLevel(int undoLevel);
78
79     /**
80      * Returns whether at least one text change can be rolled back.
81      *
82      * @return <code>true</code> if at least one text change can be rolled back
83      */

84     boolean undoable();
85
86     /**
87      * Returns whether at least one text change can be repeated. A text change
88      * can be repeated only if it was executed and rolled back.
89      *
90      * @return <code>true</code> if at least on text change can be repeated
91      */

92     boolean redoable();
93
94     /**
95      * Rolls back the most recently executed text change.
96      */

97     void undo();
98
99     /**
100      * Repeats the most recently rolled back text change.
101      */

102     void redo();
103
104 }
105
Popular Tags