001: /*******************************************************************************
002: * Copyright (c) 2000, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.pde.internal.ui.editor;
011:
012: import org.eclipse.jface.action.IAction;
013: import org.eclipse.pde.core.IModelChangeProvider;
014:
015: /**
016: * Classes that implement this interface provide undo/redo
017: * capability linked to changes reported by model change
018: * providers. Model change events carry sufficient data
019: * to be used in an undo/redo stack and reverted to or
020: * reapplied after the change.
021: * <p>Model undo manager adds itself as a change listener
022: * after being connected to the provider. It is expected
023: * to stop listening to change events after being disconnected.
024: * Changes reported while being connected are kept in the
025: * operation stack whose size can be controlled.
026: * <p>The part that uses the undo manager is responsible
027: * for supplying Undo and Redo action objects for
028: * the purpose of controlling their availability.
029: * Undo manager should keep track of its current
030: * operation stack pointer and adjust Undo/Redo action
031: * availability by calling 'setEnabled' on the
032: * provided action objects. Implementation of this
033: * interface may also opt to modify Undo/Redo action
034: * labels in order to better indicate the effect
035: * of the operations if selected (for example,
036: * 'Undo Delete' instead of 'Undo').
037: */
038: public interface IModelUndoManager {
039: /**
040: * Connects to the change provider. Until disconnecting,
041: * the manager will keep model changes in the operation
042: * stack and will be able to revert or reapply these
043: * changes in the source model.
044: * @param provider the model change provider to connect to
045: */
046: public void connect(IModelChangeProvider provider);
047:
048: /**
049: * Disconnects from the change provider. Upon disconnecting,
050: * the manager will no longer be able to revert or reapply
051: * changes in the source model.
052: * @param provider the model change provider to disconnect from
053: */
054: public void disconnect(IModelChangeProvider provider);
055:
056: /**
057: * Tests whether the current operation in the undo stack can
058: * be reverted.
059: * @return true if the current operation can be undone.
060: */
061: public boolean isUndoable();
062:
063: /**
064: * Tests whether the current operation in the undo stack can
065: * be reapplied.
066: * @return true if the current operation can be redone.
067: */
068: public boolean isRedoable();
069:
070: /**
071: * Reverts the current operation in the undo stack and decrements
072: * the stack pointer.
073: */
074: public void undo();
075:
076: /**
077: * Reapplies the next operation in the undo stack and sets
078: * the stack pointer to that operation.
079: *
080: */
081: public void redo();
082:
083: /**
084: * Sets the depth of the undo stack.
085: * @param limit number of levels in the undo stack.
086: */
087: public void setUndoLevelLimit(int limit);
088:
089: /**
090: * Temporarily suspends undo manager.
091: * @param ignore if true, model changes reported by the
092: * model change provider will be ignore until this
093: * property is set to <samp>false</samp> again.
094: */
095: public void setIgnoreChanges(boolean ignore);
096:
097: /**
098: * Connects the undo manager with the undo and redo actions
099: * in the workbench part using the manager. The manager
100: * uses these objects to enable or disable the actions
101: * according to the state of the undo stack and the current
102: * location of the stack pointer.
103: * @param undoAction the action in the workbench part that performs
104: * the undo operation.
105: * @param redoAction the action in the workbench part that performs
106: * the redo operation.
107: */
108: public void setActions(IAction undoAction, IAction redoAction);
109: }
|