FileDocCategorySizeDatePackage
AbstractUndoableEdit.javaAPI DocJava SE 5 API7735Fri Aug 26 14:58:22 BST 2005javax.swing.undo

AbstractUndoableEdit

public class AbstractUndoableEdit extends Object implements Serializable, UndoableEdit
An abstract implementation of UndoableEdit, implementing simple responses to all boolean methods in that interface.
version
1.29 12/19/03
author
Ray Ryan

Fields Summary
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 key AbstractUndoableEdit.undoText.
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 key AbstractUndoableEdit.redoText.
boolean
hasBeenDone
Defaults to true; becomes false if this edit is undone, true again if it is redone.
boolean
alive
True if this edit has not received die; defaults to true.
Constructors Summary
public AbstractUndoableEdit()
Creates an AbstractUndoableEdit which defaults and alive to true.


                   
      
	super();

	hasBeenDone = true;
	alive = true;
    
Methods Summary
public booleanaddEdit(javax.swing.undo.UndoableEdit anEdit)
This default implementation returns false.

param
anEdit the edit to be added
return
false
see
UndoableEdit#addEdit

	return false;
    
public booleancanRedo()
Returns true if this edit is alive and hasBeenDone is false.

return
true if this edit is alive and hasBeenDone is false
see
#die
see
#undo
see
#redo

	return alive && !hasBeenDone;
    
public booleancanUndo()
Returns true if this edit is alive and hasBeenDone is true.

return
true if this edit is alive and hasBeenDone is true
see
#die
see
#undo
see
#redo

	return alive && hasBeenDone;
    
public voiddie()
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.

	alive = false;
    
public java.lang.StringgetPresentationName()
This default implementation returns "". Used by getUndoPresentationName and 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 ""
see
#getUndoPresentationName
see
#getRedoPresentationName

	return "";
    
public java.lang.StringgetRedoPresentationName()
Retreives the value from the defaults table with key AbstractUndoableEdit.redoText and returns that value followed by a space, followed by getPresentationName. If getPresentationName returns "", then the defaults value is returned alone.

return
the value from the defaults table with key AbstractUndoableEdit.redoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.
see
#getPresentationName

	String name = getPresentationName();
	if (!"".equals(name)) {
	    name = UIManager.getString("AbstractUndoableEdit.redoText") +
                " " + name;
	} else {
	    name = UIManager.getString("AbstractUndoableEdit.redoText");
	}

	return name;
    
public java.lang.StringgetUndoPresentationName()
Retreives the value from the defaults table with key AbstractUndoableEdit.undoText and returns that value followed by a space, followed by getPresentationName. If getPresentationName returns "", then the defaults value is returned alone.

return
the value from the defaults table with key AbstractUndoableEdit.undoText, followed by a space, followed by getPresentationName unless getPresentationName is "" in which case, the defaults value is returned alone.
see
#getPresentationName

	String name = getPresentationName();
	if (!"".equals(name)) {
	    name = UIManager.getString("AbstractUndoableEdit.undoText") +
                " " + name;
	} else {
	    name = UIManager.getString("AbstractUndoableEdit.undoText");
	}

	return name;
    
public booleanisSignificant()
This default implementation returns true.

return
true
see
UndoableEdit#isSignificant

	return true;
    
public voidredo()
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.

exception
CannotRedoException if canRedo returns false
see
#canRedo

	if (!canRedo()) {
	    throw new CannotRedoException();
	}
	hasBeenDone = true;
    
public booleanreplaceEdit(javax.swing.undo.UndoableEdit anEdit)
This default implementation returns false.

param
anEdit the edit to replace
return
false
see
UndoableEdit#replaceEdit

	return false;
    
public java.lang.StringtoString()
Returns a string that displays and identifies this object's properties.

return
a String representation of this object

	return super.toString()
	    + " hasBeenDone: " + hasBeenDone
	    + " alive: " + alive;
    
public voidundo()
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.

exception
CannotUndoException if canUndo returns false
see
#canUndo

	if (!canUndo()) {
	    throw new CannotUndoException();
	}
	hasBeenDone = false;