Frames | No Frames |
1: /* UndoableEdit.java -- 2: Copyright (C) 2002, 2006, Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: package javax.swing.undo; 39: 40: /** 41: * An editing operation that supports undo/redoability. 42: * 43: * @author Andrew Selkirk 44: */ 45: public interface UndoableEdit 46: { 47: 48: /** 49: * Incorporates another editing action into this one, thus forming a 50: * combined action. 51: * 52: * @param edit the editing action to be incorporated. 53: * 54: * @return <code>true</code> if the edit was combined successfully, and 55: * <code>false</code> if it could not be combined. 56: */ 57: boolean addEdit(UndoableEdit edit); 58: 59: /** 60: * Determines whether it would be possible to redo this editing 61: * action. 62: * 63: * @return <code>true</code> to indicate that this action can be 64: * redone, <code>false</code> otherwise. 65: * 66: * @see #redo() 67: * @see #canUndo() 68: */ 69: boolean canRedo(); 70: 71: /** 72: * Determines whether it would be possible to undo this editing 73: * action. 74: * 75: * @return <code>true</code> to indicate that this action can be 76: * undone, <code>false</code> otherwise. 77: * 78: * @see #undo() 79: * @see #canRedo() 80: */ 81: boolean canUndo(); 82: 83: /** 84: * Informs this edit action that it will no longer be used. Some 85: * actions might use this information to release resources, for 86: * example open files. Called by {@link UndoManager} before this 87: * action is removed from the edit queue. 88: */ 89: void die(); 90: 91: /** 92: * Returns a human-readable, localized name that describes this 93: * editing action and can be displayed to the user. 94: * 95: * @return The presentation name. 96: */ 97: String getPresentationName(); 98: 99: /** 100: * Returns the redo presentation name. 101: * 102: * @return The redo presentation name. 103: */ 104: String getRedoPresentationName(); 105: 106: /** 107: * Returns the undo presentation name. 108: * 109: * @return The undo presentation name. 110: */ 111: String getUndoPresentationName(); 112: 113: /** 114: * Determines whether this editing action is significant enough for 115: * being seperately undoable by the user. A typical significant 116: * action would be the resizing of an object. However, changing the 117: * selection in a text document would usually not be considered 118: * significant. 119: * 120: * @return <code>true</code> to indicate that the action is 121: * significant enough for being separately undoable, or 122: * <code>false</code> otherwise. 123: */ 124: boolean isSignificant(); 125: 126: /** 127: * Redoes this editing action. 128: * 129: * @throws CannotRedoException if the edit cannot be undone. 130: * 131: * @see #canRedo() 132: * @see #undo() 133: */ 134: void redo() throws CannotRedoException; 135: 136: /** 137: * Incorporates another editing action into this one, thus forming a 138: * combined action that replaces the argument action. 139: * 140: * @param edit the editing action to be replaced. 141: * 142: * @return <code>true</code> if the edit is successfully replaced, and 143: * <code>false</code> otherwise. 144: */ 145: boolean replaceEdit(UndoableEdit edit); 146: 147: /** 148: * Undoes this editing action. 149: * 150: * @throws CannotUndoException if the edit cannot be undone. 151: * 152: * @see #canUndo() 153: * @see #redo() 154: */ 155: void undo() throws CannotUndoException; 156: 157: }