javax.swing.undo
Class StateEdit

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.undo.AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit 
      extended by javax.swing.undo.StateEdit
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit

public class StateEdit
extends AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit

StateEdit is a general edit for objects that change state. Objects being edited must conform to the StateEditable interface.

This edit class works by asking an object to store it's state in Hashtables before and after editing occurs. Upon undo or redo the object is told to restore it's state from these Hashtables.

A state edit is used as follows:
        // Create the edit during the "before" state of the object
        StateEdit newEdit = new StateEdit(myObject);
        // Modify the object
        myObject.someStateModifyingMethod();
        // "end" the edit when you are done modifying the object
        newEdit.end();
 

Note that when a StateEdit ends, it removes redundant state from the Hashtables - A state Hashtable is not guaranteed to contain all keys/values placed into it when the state is stored!

See Also:
StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable , Serialized Form

Field Summary
protected  StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable object sample code for javax.swing.undo.StateEdit.object definition code for javax.swing.undo.StateEdit.object
          The object being edited
protected  Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable <Object sample code for java.lang.Object definition code for java.lang.Object ,Object sample code for java.lang.Object definition code for java.lang.Object > postState sample code for javax.swing.undo.StateEdit.postState definition code for javax.swing.undo.StateEdit.postState
          The state information after the edit
protected  Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable <Object sample code for java.lang.Object definition code for java.lang.Object ,Object sample code for java.lang.Object definition code for java.lang.Object > preState sample code for javax.swing.undo.StateEdit.preState definition code for javax.swing.undo.StateEdit.preState
          The state information prior to the edit
protected static String sample code for java.lang.String definition code for java.lang.String RCSID sample code for javax.swing.undo.StateEdit.RCSID definition code for javax.swing.undo.StateEdit.RCSID
           
protected  String sample code for java.lang.String definition code for java.lang.String undoRedoName sample code for javax.swing.undo.StateEdit.undoRedoName definition code for javax.swing.undo.StateEdit.undoRedoName
          The undo/redo presentation name
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
RedoName sample code for javax.swing.undo.AbstractUndoableEdit.RedoName definition code for javax.swing.undo.AbstractUndoableEdit.RedoName , UndoName sample code for javax.swing.undo.AbstractUndoableEdit.UndoName definition code for javax.swing.undo.AbstractUndoableEdit.UndoName
 
Constructor Summary
StateEdit sample code for javax.swing.undo.StateEdit.StateEdit(javax.swing.undo.StateEditable) definition code for javax.swing.undo.StateEdit.StateEdit(javax.swing.undo.StateEditable) (StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  anObject)
          Create and return a new StateEdit.
StateEdit sample code for javax.swing.undo.StateEdit.StateEdit(javax.swing.undo.StateEditable, java.lang.String) definition code for javax.swing.undo.StateEdit.StateEdit(javax.swing.undo.StateEditable, java.lang.String) (StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  anObject, String sample code for java.lang.String definition code for java.lang.String  name)
          Create and return a new StateEdit with a presentation name.
 
Method Summary
 void end sample code for javax.swing.undo.StateEdit.end() definition code for javax.swing.undo.StateEdit.end() ()
          Gets the post-edit state of the StateEditable object and ends the edit.
 String sample code for java.lang.String definition code for java.lang.String getPresentationName sample code for javax.swing.undo.StateEdit.getPresentationName() definition code for javax.swing.undo.StateEdit.getPresentationName() ()
          Gets the presentation name for this edit
protected  void init sample code for javax.swing.undo.StateEdit.init(javax.swing.undo.StateEditable, java.lang.String) definition code for javax.swing.undo.StateEdit.init(javax.swing.undo.StateEditable, java.lang.String) (StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  anObject, String sample code for java.lang.String definition code for java.lang.String  name)
           
 void redo sample code for javax.swing.undo.StateEdit.redo() definition code for javax.swing.undo.StateEdit.redo() ()
          Tells the edited object to apply the state after the edit
protected  void removeRedundantState sample code for javax.swing.undo.StateEdit.removeRedundantState() definition code for javax.swing.undo.StateEdit.removeRedundantState() ()
          Remove redundant key/values in state hashtables.
 void undo sample code for javax.swing.undo.StateEdit.undo() definition code for javax.swing.undo.StateEdit.undo() ()
          Tells the edited object to apply the state prior to the edit
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
addEdit sample code for javax.swing.undo.AbstractUndoableEdit.addEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.undo.AbstractUndoableEdit.addEdit(javax.swing.undo.UndoableEdit) , canRedo sample code for javax.swing.undo.AbstractUndoableEdit.canRedo() definition code for javax.swing.undo.AbstractUndoableEdit.canRedo() , canUndo sample code for javax.swing.undo.AbstractUndoableEdit.canUndo() definition code for javax.swing.undo.AbstractUndoableEdit.canUndo() , die sample code for javax.swing.undo.AbstractUndoableEdit.die() definition code for javax.swing.undo.AbstractUndoableEdit.die() , getRedoPresentationName sample code for javax.swing.undo.AbstractUndoableEdit.getRedoPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getRedoPresentationName() , getUndoPresentationName sample code for javax.swing.undo.AbstractUndoableEdit.getUndoPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getUndoPresentationName() , isSignificant sample code for javax.swing.undo.AbstractUndoableEdit.isSignificant() definition code for javax.swing.undo.AbstractUndoableEdit.isSignificant() , replaceEdit sample code for javax.swing.undo.AbstractUndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit) definition code for javax.swing.undo.AbstractUndoableEdit.replaceEdit(javax.swing.undo.UndoableEdit) , toString sample code for javax.swing.undo.AbstractUndoableEdit.toString() definition code for javax.swing.undo.AbstractUndoableEdit.toString()
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

RCSID sample code for javax.swing.undo.StateEdit.RCSID

protected static final String sample code for java.lang.String definition code for java.lang.String  RCSID
See Also:
Constant Field Values

object sample code for javax.swing.undo.StateEdit.object

protected StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  object
The object being edited


preState sample code for javax.swing.undo.StateEdit.preState

protected Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable <Object sample code for java.lang.Object definition code for java.lang.Object ,Object sample code for java.lang.Object definition code for java.lang.Object > preState
The state information prior to the edit


postState sample code for javax.swing.undo.StateEdit.postState

protected Hashtable sample code for java.util.Hashtable definition code for java.util.Hashtable <Object sample code for java.lang.Object definition code for java.lang.Object ,Object sample code for java.lang.Object definition code for java.lang.Object > postState
The state information after the edit


undoRedoName sample code for javax.swing.undo.StateEdit.undoRedoName

protected String sample code for java.lang.String definition code for java.lang.String  undoRedoName
The undo/redo presentation name

Constructor Detail

StateEdit sample code for javax.swing.undo.StateEdit(javax.swing.undo.StateEditable) definition code for javax.swing.undo.StateEdit(javax.swing.undo.StateEditable)

public StateEdit(StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  anObject)
Create and return a new StateEdit.

Parameters:
anObject - The object to watch for changing state
See Also:
StateEdit sample code for javax.swing.undo.StateEdit definition code for javax.swing.undo.StateEdit

StateEdit sample code for javax.swing.undo.StateEdit(javax.swing.undo.StateEditable, java.lang.String) definition code for javax.swing.undo.StateEdit(javax.swing.undo.StateEditable, java.lang.String)

public StateEdit(StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  anObject,
                 String sample code for java.lang.String definition code for java.lang.String  name)
Create and return a new StateEdit with a presentation name.

Parameters:
anObject - The object to watch for changing state
name - The presentation name to be used for this edit
See Also:
StateEdit sample code for javax.swing.undo.StateEdit definition code for javax.swing.undo.StateEdit
Method Detail

init sample code for javax.swing.undo.StateEdit.init(javax.swing.undo.StateEditable, java.lang.String) definition code for javax.swing.undo.StateEdit.init(javax.swing.undo.StateEditable, java.lang.String)

protected void init(StateEditable sample code for javax.swing.undo.StateEditable definition code for javax.swing.undo.StateEditable  anObject,
                    String sample code for java.lang.String definition code for java.lang.String  name)

end sample code for javax.swing.undo.StateEdit.end() definition code for javax.swing.undo.StateEdit.end()

public void end()
Gets the post-edit state of the StateEditable object and ends the edit.


undo sample code for javax.swing.undo.StateEdit.undo() definition code for javax.swing.undo.StateEdit.undo()

public void undo()
Tells the edited object to apply the state prior to the edit

Specified by:
undo sample code for javax.swing.undo.UndoableEdit.undo() definition code for javax.swing.undo.UndoableEdit.undo() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
undo sample code for javax.swing.undo.AbstractUndoableEdit.undo() definition code for javax.swing.undo.AbstractUndoableEdit.undo() in class AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
See Also:
AbstractUndoableEdit.canUndo() sample code for javax.swing.undo.AbstractUndoableEdit.canUndo() definition code for javax.swing.undo.AbstractUndoableEdit.canUndo()

redo sample code for javax.swing.undo.StateEdit.redo() definition code for javax.swing.undo.StateEdit.redo()

public void redo()
Tells the edited object to apply the state after the edit

Specified by:
redo sample code for javax.swing.undo.UndoableEdit.redo() definition code for javax.swing.undo.UndoableEdit.redo() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
redo sample code for javax.swing.undo.AbstractUndoableEdit.redo() definition code for javax.swing.undo.AbstractUndoableEdit.redo() in class AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
See Also:
AbstractUndoableEdit.canRedo() sample code for javax.swing.undo.AbstractUndoableEdit.canRedo() definition code for javax.swing.undo.AbstractUndoableEdit.canRedo()

getPresentationName sample code for javax.swing.undo.StateEdit.getPresentationName() definition code for javax.swing.undo.StateEdit.getPresentationName()

public String sample code for java.lang.String definition code for java.lang.String  getPresentationName()
Gets the presentation name for this edit

Specified by:
getPresentationName sample code for javax.swing.undo.UndoableEdit.getPresentationName() definition code for javax.swing.undo.UndoableEdit.getPresentationName() in interface UndoableEdit sample code for javax.swing.undo.UndoableEdit definition code for javax.swing.undo.UndoableEdit
Overrides:
getPresentationName sample code for javax.swing.undo.AbstractUndoableEdit.getPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getPresentationName() in class AbstractUndoableEdit sample code for javax.swing.undo.AbstractUndoableEdit definition code for javax.swing.undo.AbstractUndoableEdit
Returns:
the empty string ""
See Also:
AbstractUndoableEdit.getUndoPresentationName() sample code for javax.swing.undo.AbstractUndoableEdit.getUndoPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getUndoPresentationName() , AbstractUndoableEdit.getRedoPresentationName() sample code for javax.swing.undo.AbstractUndoableEdit.getRedoPresentationName() definition code for javax.swing.undo.AbstractUndoableEdit.getRedoPresentationName()

removeRedundantState sample code for javax.swing.undo.StateEdit.removeRedundantState() definition code for javax.swing.undo.StateEdit.removeRedundantState()

protected void removeRedundantState()
Remove redundant key/values in state hashtables.