KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > IModelUndoManager


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.pde.internal.ui.editor;
12 import org.eclipse.jface.action.IAction;
13 import org.eclipse.pde.core.IModelChangeProvider;
14
15 /**
16  * Classes that implement this interface provide undo/redo
17  * capability linked to changes reported by model change
18  * providers. Model change events carry sufficient data
19  * to be used in an undo/redo stack and reverted to or
20  * reapplied after the change.
21  * <p>Model undo manager adds itself as a change listener
22  * after being connected to the provider. It is expected
23  * to stop listening to change events after being disconnected.
24  * Changes reported while being connected are kept in the
25  * operation stack whose size can be controlled.
26  * <p>The part that uses the undo manager is responsible
27  * for supplying Undo and Redo action objects for
28  * the purpose of controlling their availability.
29  * Undo manager should keep track of its current
30  * operation stack pointer and adjust Undo/Redo action
31  * availability by calling 'setEnabled' on the
32  * provided action objects. Implementation of this
33  * interface may also opt to modify Undo/Redo action
34  * labels in order to better indicate the effect
35  * of the operations if selected (for example,
36  * 'Undo Delete' instead of 'Undo').
37  */

38 public interface IModelUndoManager {
39     /**
40      * Connects to the change provider. Until disconnecting,
41      * the manager will keep model changes in the operation
42      * stack and will be able to revert or reapply these
43      * changes in the source model.
44      * @param provider the model change provider to connect to
45      */

46     public void connect(IModelChangeProvider provider);
47     /**
48      * Disconnects from the change provider. Upon disconnecting,
49      * the manager will no longer be able to revert or reapply
50      * changes in the source model.
51      * @param provider the model change provider to disconnect from
52      */

53     public void disconnect(IModelChangeProvider provider);
54     /**
55      * Tests whether the current operation in the undo stack can
56      * be reverted.
57      * @return true if the current operation can be undone.
58      */

59     public boolean isUndoable();
60     /**
61      * Tests whether the current operation in the undo stack can
62      * be reapplied.
63      * @return true if the current operation can be redone.
64      */

65     public boolean isRedoable();
66     /**
67      * Reverts the current operation in the undo stack and decrements
68      * the stack pointer.
69      */

70     public void undo();
71     /**
72      * Reapplies the next operation in the undo stack and sets
73      * the stack pointer to that operation.
74      *
75      */

76     public void redo();
77     /**
78      * Sets the depth of the undo stack.
79      * @param limit number of levels in the undo stack.
80      */

81     public void setUndoLevelLimit(int limit);
82     /**
83      * Temporarily suspends undo manager.
84      * @param ignore if true, model changes reported by the
85      * model change provider will be ignore until this
86      * property is set to <samp>false</samp> again.
87      */

88     public void setIgnoreChanges(boolean ignore);
89     /**
90      * Connects the undo manager with the undo and redo actions
91      * in the workbench part using the manager. The manager
92      * uses these objects to enable or disable the actions
93      * according to the state of the undo stack and the current
94      * location of the stack pointer.
95      * @param undoAction the action in the workbench part that performs
96      * the undo operation.
97      * @param redoAction the action in the workbench part that performs
98      * the redo operation.
99      */

100     public void setActions(IAction undoAction, IAction redoAction);
101 }
102
Popular Tags