KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > core > refactoring > 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.ltk.core.refactoring;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IProgressMonitor;
15
16 import org.eclipse.ltk.core.refactoring.history.IRefactoringHistoryService;
17
18 /**
19  * An undo manager keeps track of performed changes. Use the method <code>addUndo</code>
20  * to add change objects to the undo stack and <code>performUndo</code> and <code>
21  * performRedo</code> to undo or redo changes.
22  * <p>
23  * This interface is not intended to be implemented by clients. Clients should use the
24  * method {@link RefactoringCore#getUndoManager()} to access the refactoring undo manager.
25  * </p>
26  * <p>
27  * As of 3.1 the implementation of the refactoring undo manager is based on the
28  * {@link org.eclipse.core.commands.operations.IOperationHistory} provided by the
29  * <code>org.eclipse.core.commands</code> plug-in.
30  * </p>
31  * <p>
32  * As of 3.2 clients which need to examine refactorings which have been performed, undone or redone should use
33  * {@link IRefactoringHistoryService} for enhanced functionality.
34  * </p>
35  *
36  * @see org.eclipse.core.commands.operations.IOperationHistory
37  *
38  * @since 3.0
39  */

40 public interface IUndoManager {
41
42     /**
43      * Adds a listener to the undo manager. Does nothing if the listener
44      * is already present.
45      *
46      * @param listener the listener to be added to the undo manager
47      */

48     public void addListener(IUndoManagerListener listener);
49     
50     /**
51      * Removes the given listener from this undo manager. Does nothing if
52      * the listener isn't registered with this undo manager
53      *
54      * @param listener the listener to be removed
55      */

56     public void removeListener(IUndoManagerListener listener);
57     
58     /**
59      * The infrastructure is going to perform the given change. If a
60      * client calls this method it must make sure that the corresponding
61      * method {@link #changePerformed(Change)} is called after the
62      * change got executed. A typically code snippet looks as follows:
63      * <pre>
64      * Change change= ...;
65      * try {
66      * undoManager.aboutToPerformChange(change);
67      * // execute change
68      * } finally {
69      * undoManager.changePerformed(change);
70      * }
71      * </pre>
72      *
73      * @param change the change to be performed.
74      */

75     public void aboutToPerformChange(Change change);
76     
77     /**
78      * The infrastructure has performed the given change.
79      *
80      * @param change the change that was performed
81      *
82      * @deprecated use #changePerformed(Change, boolean) instead
83      */

84     public void changePerformed(Change change);
85
86     /**
87      * The infrastructure has performed the given change.
88      *
89      * @param change the change that was performed
90      * @param successful <code>true</code> if the change got executed
91      * successful; <code>false</code> otherwise.
92      *
93      * @since 3.1
94      */

95     public void changePerformed(Change change, boolean successful);
96
97     /**
98      * Adds a new undo change to this undo manager.
99      *
100      * @param name the name presented on the undo stack for the provided
101      * undo change. The name must be human readable.
102      * @param change the undo change
103      */

104     public void addUndo(String JavaDoc name, Change change);
105
106     /**
107      * Returns <code>true</code> if there is anything to undo, otherwise
108      * <code>false</code>.
109      *
110      * @return <code>true</code> if there is anything to undo, otherwise
111      * <code>false</code>
112      */

113     public boolean anythingToUndo();
114     
115     /**
116      * Returns the name of the top most undo.
117      *
118      * @return the top most undo name. Returns <code>null</code> if there
119      * aren't any changes to undo.
120      */

121     public String JavaDoc peekUndoName();
122     
123     /**
124      * Undo the top most undo change.
125      *
126      * @param query a proceed query to decide how to proceed if the validation
127      * checking of the undo change to perform returns a non OK status and the
128      * status isn't a fatal error. If <code>null</code> is passed in the
129      * undo proceeds if the status is not a fatal error.
130      * @param pm a progress monitor to report progress during performing
131      * the undo change
132      *
133      * @throws CoreException if performing the undo caused an exception
134      */

135     public void performUndo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException;
136
137     /**
138      * Returns <code>true</code> if there is anything to redo, otherwise
139      * <code>false</code>.
140      *
141      * @return <code>true</code> if there is anything to redo, otherwise
142      * <code>false</code>
143      */

144     public boolean anythingToRedo();
145     
146     /**
147      * Returns the name of the top most redo.
148      *
149      * @return the top most redo name. Returns <code>null</code> if there
150      * are no any changes to redo.
151      */

152     public String JavaDoc peekRedoName();
153     
154     /**
155      * Redo the top most redo change.
156      *
157      * @param query a proceed query to decide how to proceed if the validation
158      * checking of the redo change to perform returns a non OK status. If
159      * <code>null</code> is passed in the undo proceeds if the status
160      * is not a fatal error.
161      * @param pm a progress monitor to report progress during performing
162      * the redo change
163      *
164      * @throws CoreException if performing the redo caused an exception
165      */

166     public void performRedo(IValidationCheckResultQuery query, IProgressMonitor pm) throws CoreException;
167     
168     /**
169      * Flushes the undo manager's undo and redo stacks.
170      */

171     public void flush();
172     
173     /**
174      * Shut down the undo manager.
175      */

176     public void shutdown();
177 }
178
Popular Tags