< prev index next >

src/java.desktop/share/classes/javax/swing/undo/AbstractUndoableEdit.java

Print this page

        

*** 27,60 **** import java.io.Serializable; import javax.swing.UIManager; /** ! * An abstract implementation of <code>UndoableEdit</code>, * implementing simple responses to all boolean methods in * that interface. * * @author Ray Ryan */ @SuppressWarnings("serial") // Same-version serialization only public class AbstractUndoableEdit implements UndoableEdit, Serializable { /** ! * String returned by <code>getUndoPresentationName</code>; * as of Java 2 platform v1.3.1 this field is no longer used. This value * is now localized and comes from the defaults table with key ! * <code>AbstractUndoableEdit.undoText</code>. * * @see javax.swing.UIDefaults */ protected static final String UndoName = "Undo"; /** ! * String returned by <code>getRedoPresentationName</code>; * as of Java 2 platform v1.3.1 this field is no longer used. This value * is now localized and comes from the defaults table with key ! * <code>AbstractUndoableEdit.redoText</code>. * * @see javax.swing.UIDefaults */ protected static final String RedoName = "Redo"; --- 27,60 ---- import java.io.Serializable; import javax.swing.UIManager; /** ! * An abstract implementation of {@code UndoableEdit}, * implementing simple responses to all boolean methods in * that interface. * * @author Ray Ryan */ @SuppressWarnings("serial") // Same-version serialization only public class AbstractUndoableEdit implements UndoableEdit, Serializable { /** ! * String returned by {@code getUndoPresentationName}; * as of Java 2 platform v1.3.1 this field is no longer used. This value * is now localized and comes from the defaults table with key ! * {@code AbstractUndoableEdit.undoText}. * * @see javax.swing.UIDefaults */ protected static final String UndoName = "Undo"; /** ! * String returned by {@code getRedoPresentationName}; * as of Java 2 platform v1.3.1 this field is no longer used. This value * is now localized and comes from the defaults table with key ! * {@code AbstractUndoableEdit.redoText}. * * @see javax.swing.UIDefaults */ protected static final String RedoName = "Redo";
*** 63,158 **** * again if it is redone. */ boolean hasBeenDone; /** ! * True if this edit has not received <code>die</code>; defaults ! * to <code>true</code>. */ boolean alive; /** ! * Creates an <code>AbstractUndoableEdit</code> which defaults ! * <code>hasBeenDone</code> and <code>alive</code> to <code>true</code>. */ public AbstractUndoableEdit() { super(); hasBeenDone = true; alive = true; } /** ! * Sets <code>alive</code> to false. Note that this * is a one way operation; dead edits cannot be resurrected. ! * Sending <code>undo</code> or <code>redo</code> to * a dead edit results in an exception being thrown. * * <p>Typically an edit is killed when it is consolidated by ! * another edit's <code>addEdit</code> or <code>replaceEdit</code> ! * method, or when it is dequeued from an <code>UndoManager</code>. */ public void die() { alive = false; } /** ! * Throws <code>CannotUndoException</code> if <code>canUndo</code> ! * returns <code>false</code>. Sets <code>hasBeenDone</code> ! * to <code>false</code>. Subclasses should override to undo the * operation represented by this edit. Override should begin with * a call to super. * ! * @exception CannotUndoException if <code>canUndo</code> ! * returns <code>false</code> * @see #canUndo */ public void undo() throws CannotUndoException { if (!canUndo()) { throw new CannotUndoException(); } hasBeenDone = false; } /** ! * Returns true if this edit is <code>alive</code> ! * and <code>hasBeenDone</code> is <code>true</code>. * ! * @return true if this edit is <code>alive</code> ! * and <code>hasBeenDone</code> is <code>true</code> * * @see #die * @see #undo * @see #redo */ public boolean canUndo() { return alive && hasBeenDone; } /** ! * Throws <code>CannotRedoException</code> if <code>canRedo</code> ! * returns false. Sets <code>hasBeenDone</code> to <code>true</code>. * Subclasses should override to redo the operation represented by * this edit. Override should begin with a call to super. * ! * @exception CannotRedoException if <code>canRedo</code> ! * returns <code>false</code> * @see #canRedo */ public void redo() throws CannotRedoException { if (!canRedo()) { throw new CannotRedoException(); } hasBeenDone = true; } /** ! * Returns <code>true</code> if this edit is <code>alive</code> ! * and <code>hasBeenDone</code> is <code>false</code>. * ! * @return <code>true</code> if this edit is <code>alive</code> ! * and <code>hasBeenDone</code> is <code>false</code> * @see #die * @see #undo * @see #redo */ public boolean canRedo() { --- 63,158 ---- * again if it is redone. */ boolean hasBeenDone; /** ! * True if this edit has not received {@code die}; defaults ! * to {@code true}. */ boolean alive; /** ! * Creates an {@code AbstractUndoableEdit} which defaults ! * {@code hasBeenDone} and {@code alive} to {@code true}. */ public AbstractUndoableEdit() { super(); hasBeenDone = true; alive = true; } /** ! * Sets {@code alive} to false. Note that this * is a one way operation; dead edits cannot be resurrected. ! * Sending {@code undo} or {@code redo} to * a dead edit results in an exception being thrown. * * <p>Typically an edit is killed when it is consolidated by ! * another edit's {@code addEdit} or {@code replaceEdit} ! * method, or when it is dequeued from an {@code UndoManager}. */ public void die() { alive = false; } /** ! * Throws {@code CannotUndoException} if {@code canUndo} ! * returns {@code false}. Sets {@code hasBeenDone} ! * to {@code false}. Subclasses should override to undo the * operation represented by this edit. Override should begin with * a call to super. * ! * @exception CannotUndoException if {@code canUndo} ! * returns {@code false} * @see #canUndo */ public void undo() throws CannotUndoException { if (!canUndo()) { throw new CannotUndoException(); } hasBeenDone = false; } /** ! * Returns true if this edit is {@code alive} ! * and {@code hasBeenDone} is {@code true}. * ! * @return true if this edit is {@code alive} ! * and {@code hasBeenDone} is {@code true} * * @see #die * @see #undo * @see #redo */ public boolean canUndo() { return alive && hasBeenDone; } /** ! * Throws {@code CannotRedoException} if {@code canRedo} ! * returns false. Sets {@code hasBeenDone} to {@code true}. * Subclasses should override to redo the operation represented by * this edit. Override should begin with a call to super. * ! * @exception CannotRedoException if {@code canRedo} ! * returns {@code false} * @see #canRedo */ public void redo() throws CannotRedoException { if (!canRedo()) { throw new CannotRedoException(); } hasBeenDone = true; } /** ! * Returns {@code true} if this edit is {@code alive} ! * and {@code hasBeenDone} is {@code false}. * ! * @return {@code true} if this edit is {@code alive} ! * and {@code hasBeenDone} is {@code false} * @see #die * @see #undo * @see #redo */ public boolean canRedo() {
*** 193,204 **** return true; } /** * This default implementation returns "". Used by ! * <code>getUndoPresentationName</code> and ! * <code>getRedoPresentationName</code> to * construct the strings they return. Subclasses should override to * return an appropriate description of the operation this edit * represents. * * @return the empty string "" --- 193,204 ---- return true; } /** * This default implementation returns "". Used by ! * {@code getUndoPresentationName} and ! * {@code getRedoPresentationName} to * construct the strings they return. Subclasses should override to * return an appropriate description of the operation this edit * represents. * * @return the empty string ""
*** 210,229 **** return ""; } /** * Retreives the value from the defaults table with key ! * <code>AbstractUndoableEdit.undoText</code> and returns * that value followed by a space, followed by ! * <code>getPresentationName</code>. ! * If <code>getPresentationName</code> returns "", * then the defaults value is returned alone. * * @return the value from the defaults table with key ! * <code>AbstractUndoableEdit.undoText</code>, followed ! * by a space, followed by <code>getPresentationName</code> ! * unless <code>getPresentationName</code> is "" in which * case, the defaults value is returned alone. * @see #getPresentationName */ public String getUndoPresentationName() { String name = getPresentationName(); --- 210,229 ---- return ""; } /** * Retreives the value from the defaults table with key ! * {@code AbstractUndoableEdit.undoText} and returns * that value followed by a space, followed by ! * {@code getPresentationName}. ! * If {@code getPresentationName} returns "", * then the defaults value is returned alone. * * @return the value from the defaults table with key ! * {@code AbstractUndoableEdit.undoText}, followed ! * by a space, followed by {@code getPresentationName} ! * unless {@code getPresentationName} is "" in which * case, the defaults value is returned alone. * @see #getPresentationName */ public String getUndoPresentationName() { String name = getPresentationName();
*** 237,256 **** return name; } /** * Retreives the value from the defaults table with key ! * <code>AbstractUndoableEdit.redoText</code> and returns * that value followed by a space, followed by ! * <code>getPresentationName</code>. ! * If <code>getPresentationName</code> returns "", * then the defaults value is returned alone. * * @return the value from the defaults table with key ! * <code>AbstractUndoableEdit.redoText</code>, followed ! * by a space, followed by <code>getPresentationName</code> ! * unless <code>getPresentationName</code> is "" in which * case, the defaults value is returned alone. * @see #getPresentationName */ public String getRedoPresentationName() { String name = getPresentationName(); --- 237,256 ---- return name; } /** * Retreives the value from the defaults table with key ! * {@code AbstractUndoableEdit.redoText} and returns * that value followed by a space, followed by ! * {@code getPresentationName}. ! * If {@code getPresentationName} returns "", * then the defaults value is returned alone. * * @return the value from the defaults table with key ! * {@code AbstractUndoableEdit.redoText}, followed ! * by a space, followed by {@code getPresentationName} ! * unless {@code getPresentationName} is "" in which * case, the defaults value is returned alone. * @see #getPresentationName */ public String getRedoPresentationName() { String name = getPresentationName();
< prev index next >