CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.undo
Class UndoableBooleanEdit

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

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

This is an abstract class for undoable int properties. If the property is changed multiple times in sequence, then these edit events are coalesced.

Version:
1.1 2002-02-03 Supports now insignificant edits as well.
1.0 2001-10-12
Author:
Werner Randelshofer
See Also:
Serialized Form

Field Summary
protected  boolean newValue
           
protected  boolean oldValue
           
protected  java.lang.String propertyName
           
protected  java.lang.Object source
           
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
UndoableBooleanEdit(java.lang.Object source, java.lang.String propertyName, boolean oldValue, boolean newValue)
          Creates new UndoableBooleanEdit
UndoableBooleanEdit(java.lang.Object source, java.lang.String propertyName, boolean oldValue, boolean newValue, boolean isSignificant)
          Creates new UndoableBooleanEdit
 
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.
 boolean isSignificant()
          Returns false if this edit is insignificant - for example one that maintains the user's selection, but does not change any model state.
 void redo()
          Re-apply the edit, assuming that it has been undone.
abstract  void revert(boolean oldValue, boolean 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, 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 boolean oldValue

newValue

protected boolean newValue
Constructor Detail

UndoableBooleanEdit

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

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.

UndoableBooleanEdit

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

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.
isSignificant - The significance of the edit event.
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(boolean oldValue,
                            boolean newValue)
Revert the property from the oldValue to the newValue.


isSignificant

public boolean isSignificant()
Returns false if this edit is insignificant - for example one that maintains the user's selection, but does not change any model state. This status can be used by an UndoableEditListener (like UndoManager) when deciding which UndoableEdits to present to the user as Undo/Redo options, and which to perform as side effects of undoing or redoing other events.

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

(c) Werner Randelshofer.
All rights reserved.