dsto.dfc.swing.undo
Class PropertyEdit

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by dsto.dfc.swing.undo.AbstractMonitoredEdit
          extended by dsto.dfc.swing.undo.PropertyEdit
All Implemented Interfaces:
Iconic, MonitoredEdit, Restorable, Copyable, Serializable, Cloneable, UndoableEdit
Direct Known Subclasses:
PropertyEditBean

public class PropertyEdit
extends AbstractMonitoredEdit

Used to undo property changes.

Version:
$Revision$
Author:
Peter J Smet, Derek Weber
See Also:
Serialized Form

Field Summary
 Object newValue
          The new value of the property.
 Object oldValue
          The old value of the property.
 String propertyName
          The name of the changed property.
 Object source
          The source of the property change.
 
Fields inherited from class dsto.dfc.swing.undo.AbstractMonitoredEdit
alive, ICON, parameterNames, parameterValues
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Fields inherited from interface dsto.dfc.swing.icons.Iconic
NULL_ICON
 
Constructor Summary
PropertyEdit()
          For bean serialisation only
PropertyEdit(Object source, String propertyName, Object oldValue, Object newValue)
          Constructs a PropertyEdit with the supplied information.
PropertyEdit(PropertyChangeEvent event)
          Constructs a PropertyEdit from the PropertyChangeEvent.
 
Method Summary
 String getDescription()
          Returns a description of this type of UndoableEdit.
 String getPresentationName()
          Returns a presentation name of the form:
 String getPropertyName()
           
 String getRedoPresentationName()
           
 String getUndoPresentationName()
           
 void redo()
          Sets the source's propertyName value to newValue.
 void setPropertyName(String propertyName)
           
protected  void setPropertyValue(Object value, RuntimeException undoRedoException)
          Attempts to set the propertyName property of source to value and throws undoRedoException if it does not succeed.
 void undo()
          Sets the source's propertyName value to oldValue.
protected  void writeSource(ObjectOutputStream out)
          Override this method if your source is not serialisable.
protected  void writeValue(Object value, ObjectOutputStream out)
          Override with value specific code if value is not serialisable.
 
Methods inherited from class dsto.dfc.swing.undo.AbstractMonitoredEdit
canRedo, canUndo, clone, die, getIcon, getLargeIcon, getName, getParameterNames, getParameterValues, restoreContext, setParameterNames, setParameterValues
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
addEdit, isSignificant, replaceEdit, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.undo.UndoableEdit
addEdit, isSignificant, replaceEdit
 

Field Detail

source

public transient Object source
The source of the property change.


propertyName

public String propertyName
The name of the changed property.


oldValue

public transient Object oldValue
The old value of the property.


newValue

public transient Object newValue
The new value of the property.

Constructor Detail

PropertyEdit

public PropertyEdit()
For bean serialisation only


PropertyEdit

public PropertyEdit(Object source,
                    String propertyName,
                    Object oldValue,
                    Object newValue)
Constructs a PropertyEdit with the supplied information.


PropertyEdit

public PropertyEdit(PropertyChangeEvent event)
Constructs a PropertyEdit from the PropertyChangeEvent.

Method Detail

getPropertyName

public String getPropertyName()

setPropertyName

public void setPropertyName(String propertyName)

getDescription

public String getDescription()
Returns a description of this type of UndoableEdit.

Specified by:
getDescription in interface MonitoredEdit
Specified by:
getDescription in class AbstractMonitoredEdit

setPropertyValue

protected void setPropertyValue(Object value,
                                RuntimeException undoRedoException)
Attempts to set the propertyName property of source to value and throws undoRedoException if it does not succeed. Used by undo() and redo().


undo

public void undo()
          throws CannotUndoException
Sets the source's propertyName value to oldValue.

Specified by:
undo in interface UndoableEdit
Overrides:
undo in class AbstractMonitoredEdit
Throws:
CannotUndoException

redo

public void redo()
          throws CannotRedoException
Sets the source's propertyName value to newValue.

Specified by:
redo in interface UndoableEdit
Overrides:
redo in class AbstractMonitoredEdit
Throws:
CannotRedoException

getPresentationName

public String getPresentationName()
Returns a presentation name of the form:
   "source " change " propertyName [oldValue} -> newValue]@quot;
 
If the Object.toString() methods of the source, oldValue, or newValue are memory references, then their class name is displayed instead for readability purposes.

Specified by:
getPresentationName in interface UndoableEdit
Overrides:
getPresentationName in class AbstractUndoableEdit

getUndoPresentationName

public String getUndoPresentationName()
Specified by:
getUndoPresentationName in interface UndoableEdit
Overrides:
getUndoPresentationName in class AbstractMonitoredEdit

getRedoPresentationName

public String getRedoPresentationName()
Specified by:
getRedoPresentationName in interface UndoableEdit
Overrides:
getRedoPresentationName in class AbstractMonitoredEdit

writeSource

protected void writeSource(ObjectOutputStream out)
                    throws IOException
Override this method if your source is not serialisable. Make sure that only one Object is written to the out stream, however.

Throws:
IOException

writeValue

protected void writeValue(Object value,
                          ObjectOutputStream out)
                   throws IOException
Override with value specific code if value is not serialisable.

Throws:
IOException


Copyright © 2008 Commonwealth of Australia