CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.undo
Class UndoableObjectEdit

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by ch.randelshofer.undo.UndoableObjectEdit
All Implemented Interfaces:
java.io.Serializable, javax.swing.undo.UndoableEdit

public abstract class UndoableObjectEdit
extends javax.swing.undo.AbstractUndoableEdit

This is an abstract class for undoable Object properties.

Version:
1.0 2001-10-12
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
protected  java.lang.Object newValue
           
protected  java.lang.Object oldValue
           
protected  java.lang.String propertyName
           
protected  java.lang.Object source
           
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
UndoableObjectEdit(java.lang.Object source, java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Creates new IntPropertyEdit
 
Method Summary
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
          This UndoableEdit should absorb anEdit if it can.
 java.lang.String getPresentationName()
          The name to be displayed in the undo/redo menu.
 void redo()
          Re-apply the edit, assuming that it has been undone.
abstract  void revert(java.lang.Object oldValue, java.lang.Object newValue)
          Revert the property from the oldValue to the newValue.
 void undo()
          Undo the edit that was made.
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
canRedo, canUndo, die, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected java.lang.Object source

propertyName

protected java.lang.String propertyName

oldValue

protected java.lang.Object oldValue

newValue

protected java.lang.Object newValue
Constructor Detail

UndoableObjectEdit

public UndoableObjectEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          java.lang.Object oldValue,
                          java.lang.Object newValue)
Creates new IntPropertyEdit

Parameters:
source - The Object to which the property belongs.
propertyName - The name of the property.
oldValue - The old value of the property.
newValue - The new value of the property.
Method Detail

redo

public void redo()
Re-apply the edit, assuming that it has been undone.

Specified by:
redo in interface javax.swing.undo.UndoableEdit
Overrides:
redo in class javax.swing.undo.AbstractUndoableEdit

undo

public void undo()
Undo the edit that was made.

Specified by:
undo in interface javax.swing.undo.UndoableEdit
Overrides:
undo in class javax.swing.undo.AbstractUndoableEdit

getPresentationName

public java.lang.String getPresentationName()
The name to be displayed in the undo/redo menu.

Specified by:
getPresentationName in interface javax.swing.undo.UndoableEdit
Overrides:
getPresentationName in class javax.swing.undo.AbstractUndoableEdit

addEdit

public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
This UndoableEdit should absorb anEdit if it can. Return true if anEdit has been incoporated, false if it has not.

Typically the receiver is already in the queue of a UndoManager (or other UndoableEditListener), and is being given a chance to incorporate anEdit rather than letting it be added to the queue in turn.

If true is returned, from now on anEdit must return false from canUndo() and canRedo(), and must throw the appropriate exception on undo() or redo().

Specified by:
addEdit in interface javax.swing.undo.UndoableEdit
Overrides:
addEdit in class javax.swing.undo.AbstractUndoableEdit

revert

public abstract void revert(java.lang.Object oldValue,
                            java.lang.Object newValue)
Revert the property from the oldValue to the newValue.


(c) Werner Randelshofer.
All rights reserved.