CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.undo
Class UndoableIntEdit

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

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

This is an abstract class for undoable int properties.

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

Field Summary
protected  boolean isCoalesce
           
protected  int newValue
           
protected  int oldValue
           
protected  java.lang.String propertyName
           
protected  java.lang.Object source
           
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
UndoableIntEdit(java.lang.Object source, java.lang.String propertyName, int oldValue, int newValue)
          Creates new IntPropertyEdit of which consecutive edits are not coalesced.
UndoableIntEdit(java.lang.Object source, java.lang.String propertyName, int oldValue, int newValue, boolean coalesce)
          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(int oldValue, int 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 int oldValue

newValue

protected int newValue

isCoalesce

protected boolean isCoalesce
Constructor Detail

UndoableIntEdit

public UndoableIntEdit(java.lang.Object source,
                       java.lang.String propertyName,
                       int oldValue,
                       int newValue)
Creates new IntPropertyEdit of which consecutive edits are not coalesced.

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.

UndoableIntEdit

public UndoableIntEdit(java.lang.Object source,
                       java.lang.String propertyName,
                       int oldValue,
                       int newValue,
                       boolean coalesce)
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.
coalesce - Set to true, if consecutive edits shall be coalesced.
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(int oldValue,
                            int newValue)
Revert the property from the oldValue to the newValue.


(c) Werner Randelshofer.
All rights reserved.