org.jhotdraw.beans
Class PropertyChangeEdit

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by org.jhotdraw.beans.PropertyChangeEdit
All Implemented Interfaces:
java.io.Serializable, javax.swing.undo.UndoableEdit

public class PropertyChangeEdit
extends javax.swing.undo.AbstractUndoableEdit

An UndoableEdit event which can undo a change of a JavaBeans property.

Version:
$Id: PropertyChangeEdit.java 604 2010-01-09 12:00:29Z rawcoder $
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
private  java.lang.Object newValue
          The new value of the JavaBeans property.
private  java.lang.Object oldValue
          The old value of the JavaBeans property.
private  java.lang.String presentationName
           
private  java.lang.String propertyName
          The name of the JavaBeans property.
private  java.lang.Object source
          The object to be provided as the "source" of the JavaBeans property.
private  java.lang.Class type
          The type of the property.
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, boolean oldValue, boolean newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, char oldValue, char newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, java.lang.Class<T> type, T oldValue, T newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, double oldValue, double newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, float oldValue, float newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, int oldValue, int newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, long oldValue, long newValue)
          Creates a new PropertyChangeEdit.
PropertyChangeEdit(java.lang.Object source, java.lang.String propertyName, java.lang.String oldValue, java.lang.String newValue)
          Creates a new PropertyChangeEdit.
 
Method Summary
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
          Adds the specified edit to this one, if it is a PropertyChangeEdit from the same owner and the same property.
 java.lang.String getPresentationName()
          Returns the presentation name of the undoable edit.
protected  java.lang.reflect.Method getSetter()
          Returns the setter for the property.
 void redo()
          Redoes the change.
 void setPresentationName(java.lang.String presentationName)
          Sets the presentation name of the undoable edit.
 java.lang.String toString()
          Returns a string representation of this object useful for debugging.
 void undo()
          Undoes the change.
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
canRedo, canUndo, die, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

private java.lang.Object source
The object to be provided as the "source" of the JavaBeans property.


propertyName

private java.lang.String propertyName
The name of the JavaBeans property.


oldValue

private java.lang.Object oldValue
The old value of the JavaBeans property.


newValue

private java.lang.Object newValue
The new value of the JavaBeans property.


type

private java.lang.Class type
The type of the property.


presentationName

private java.lang.String presentationName
Constructor Detail

PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          java.lang.Class<T> type,
                          T oldValue,
                          T newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          boolean oldValue,
                          boolean newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          int oldValue,
                          int newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          long oldValue,
                          long newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          float oldValue,
                          float newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          double oldValue,
                          double newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          char oldValue,
                          char newValue)
Creates a new PropertyChangeEdit.


PropertyChangeEdit

public PropertyChangeEdit(java.lang.Object source,
                          java.lang.String propertyName,
                          java.lang.String oldValue,
                          java.lang.String newValue)
Creates a new PropertyChangeEdit.

Method Detail

getSetter

protected java.lang.reflect.Method getSetter()
Returns the setter for the property.

Returns:
the setter method.

undo

public void undo()
          throws javax.swing.undo.CannotRedoException
Undoes the change.

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

redo

public void redo()
          throws javax.swing.undo.CannotRedoException
Redoes the change.

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

getPresentationName

public java.lang.String getPresentationName()
Returns the presentation name of the undoable edit. This is the same as the property name, unless you have set a different presentation name.

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

setPresentationName

public void setPresentationName(java.lang.String presentationName)
Sets the presentation name of the undoable edit.


addEdit

public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
Adds the specified edit to this one, if it is a PropertyChangeEdit from the same owner and the same property.

Specified by:
addEdit in interface javax.swing.undo.UndoableEdit
Overrides:
addEdit in class javax.swing.undo.AbstractUndoableEdit
Parameters:
anEdit - Edit to be added.
Returns:
True if added.

toString

public java.lang.String toString()
Returns a string representation of this object useful for debugging.

Overrides:
toString in class javax.swing.undo.AbstractUndoableEdit