AbstractUndoableEdit (Java 2 Platform SE 5.0) (original) (raw)


javax.swing.undo

Class AbstractUndoableEdit

java.lang.Object extended by javax.swing.undo.AbstractUndoableEdit

All Implemented Interfaces:

Serializable, UndoableEdit

Direct Known Subclasses:

AbstractDocument.ElementEdit, CompoundEdit, DefaultStyledDocument.AttributeUndoableEdit, StateEdit


public class AbstractUndoableEdit

extends Object

implements UndoableEdit, Serializable

An abstract implementation of UndoableEdit, implementing simple responses to all boolean methods in that interface.


Field Summary
protected static String RedoName String returned by getRedoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
protected static String UndoName String returned by getUndoPresentationName; as of Java 2 platform v1.3.1 this field is no longer used.
Constructor Summary
AbstractUndoableEdit() Creates an AbstractUndoableEdit which defaults <code.hasbeendone< code=""> and alive to true.</code.hasbeendone<>
Method Summary
boolean addEdit(UndoableEdit anEdit) This default implementation returns false.
boolean canRedo() Returns true if this edit is alive and hasBeenDone is false.
boolean canUndo() Returns true if this edit is alive and hasBeenDone is true.
void die() Sets alive to false.
String getPresentationName() This default implementation returns "".
String getRedoPresentationName() Retreives the value from the defaults table with keyAbstractUndoableEdit.redoText and returns that value followed by a space, followed bygetPresentationName.
String getUndoPresentationName() Retreives the value from the defaults table with keyAbstractUndoableEdit.undoText and returns that value followed by a space, followed bygetPresentationName.
boolean isSignificant() This default implementation returns true.
void redo() Throws CannotRedoException if canRedo returns false.
boolean replaceEdit(UndoableEdit anEdit) This default implementation returns false.
String toString() Returns a string that displays and identifies this object's properties.
void undo() Throws CannotUndoException if canUndo returns false.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29)
Field Detail

UndoName

protected static final String UndoName

String returned by 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 keyAbstractUndoableEdit.undoText.

See Also:

UIDefaults, Constant Field Values


RedoName

protected static final String RedoName

String returned by 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 keyAbstractUndoableEdit.redoText.

See Also:

UIDefaults, Constant Field Values

Constructor Detail

AbstractUndoableEdit

public AbstractUndoableEdit()

Creates an AbstractUndoableEdit which defaults <code.hasbeendone< code=""> and alive to true. </code.hasbeendone<>

Method Detail

die

public void die()

Sets alive to false. Note that this is a one way operation; dead edits cannot be resurrected. Sending undo or redo to a dead edit results in an exception being thrown.

Typically an edit is killed when it is consolidated by another edit's addEdit or replaceEdit method, or when it is dequeued from an UndoManager.

Specified by:

[die](../../../javax/swing/undo/UndoableEdit.html#die%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

See Also:

CompoundEdit.die()


undo

public void undo() throws CannotUndoException

Throws CannotUndoException if canUndo returns false. Sets hasBeenDone to false. Subclasses should override to undo the operation represented by this edit. Override should begin with a call to super.

Specified by:

[undo](../../../javax/swing/undo/UndoableEdit.html#undo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Throws:

[CannotUndoException](../../../javax/swing/undo/CannotUndoException.html "class in javax.swing.undo") - if canUndo returns false

See Also:

canUndo()


canUndo

public boolean canUndo()

Returns true if this edit is alive and hasBeenDone is true.

Specified by:

[canUndo](../../../javax/swing/undo/UndoableEdit.html#canUndo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Returns:

true if this edit is alive and hasBeenDone is true

See Also:

die(), undo(), redo()


redo

public void redo() throws CannotRedoException

Throws CannotRedoException if canRedo returns false. Sets hasBeenDone to true. Subclasses should override to redo the operation represented by this edit. Override should begin with a call to super.

Specified by:

[redo](../../../javax/swing/undo/UndoableEdit.html#redo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Throws:

[CannotRedoException](../../../javax/swing/undo/CannotRedoException.html "class in javax.swing.undo") - if canRedo returns false

See Also:

canRedo()


canRedo

public boolean canRedo()

Returns true if this edit is alive and hasBeenDone is false.

Specified by:

[canRedo](../../../javax/swing/undo/UndoableEdit.html#canRedo%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Returns:

true if this edit is alive and hasBeenDone is false

See Also:

die(), undo(), redo()


addEdit

public boolean addEdit(UndoableEdit anEdit)

This default implementation returns false.

Specified by:

[addEdit](../../../javax/swing/undo/UndoableEdit.html#addEdit%28javax.swing.undo.UndoableEdit%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Parameters:

anEdit - the edit to be added

Returns:

false

See Also:

UndoableEdit.addEdit(javax.swing.undo.UndoableEdit)


replaceEdit

public boolean replaceEdit(UndoableEdit anEdit)

This default implementation returns false.

Specified by:

[replaceEdit](../../../javax/swing/undo/UndoableEdit.html#replaceEdit%28javax.swing.undo.UndoableEdit%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Parameters:

anEdit - the edit to replace

Returns:

false

See Also:

UndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit)


isSignificant

public boolean isSignificant()

This default implementation returns true.

Specified by:

[isSignificant](../../../javax/swing/undo/UndoableEdit.html#isSignificant%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Returns:

true

See Also:

UndoableEdit.isSignificant()


getPresentationName

public String getPresentationName()

This default implementation returns "". Used bygetUndoPresentationName and getRedoPresentationName to construct the strings they return. Subclasses should override to return an appropriate description of the operation this edit represents.

Specified by:

[getPresentationName](../../../javax/swing/undo/UndoableEdit.html#getPresentationName%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Returns:

the empty string ""

See Also:

getUndoPresentationName(), getRedoPresentationName()


getUndoPresentationName

public String getUndoPresentationName()

Retreives the value from the defaults table with keyAbstractUndoableEdit.undoText and returns that value followed by a space, followed bygetPresentationName. If getPresentationName returns "", then the defaults value is returned alone.

Specified by:

[getUndoPresentationName](../../../javax/swing/undo/UndoableEdit.html#getUndoPresentationName%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Returns:

the value from the defaults table with keyAbstractUndoableEdit.undoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.

See Also:

getPresentationName()


getRedoPresentationName

public String getRedoPresentationName()

Retreives the value from the defaults table with keyAbstractUndoableEdit.redoText and returns that value followed by a space, followed bygetPresentationName. If getPresentationName returns "", then the defaults value is returned alone.

Specified by:

[getRedoPresentationName](../../../javax/swing/undo/UndoableEdit.html#getRedoPresentationName%28%29) in interface [UndoableEdit](../../../javax/swing/undo/UndoableEdit.html "interface in javax.swing.undo")

Returns:

the value from the defaults table with keyAbstractUndoableEdit.redoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.

See Also:

getPresentationName()


toString

public String toString()

Returns a string that displays and identifies this object's properties.

Overrides:

[toString](../../../java/lang/Object.html#toString%28%29) in class [Object](../../../java/lang/Object.html "class in java.lang")

Returns:

a String representation of this object



Submit a bug or feature
For further API reference and developer documentation, see Java 2 SDK SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.