Class Overview
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!
Summary
Public Methods |
void
|
end()
Gets the post-edit state of the StateEditable object and
ends the edit.
|
String
|
getPresentationName()
Gets the presentation name for this edit
|
void
|
redo()
Tells the edited object to apply the state after the edit
|
void
|
undo()
Tells the edited object to apply the state prior to the edit
|
[Expand]
Inherited Methods |
From class
javax.swing.undo.AbstractUndoableEdit
boolean
|
addEdit(UndoableEdit anEdit)
This default implementation returns false.
|
boolean
|
canRedo()
Returns true if this edit is alive
and hasBeenDone is false .
|
boolean
|
canUndo()
Returns true if this edit is alive
and hasBeenDone is true .
|
void
|
die()
Sets alive to false.
|
String
|
getPresentationName()
This default implementation returns "".
|
String
|
getRedoPresentationName()
Retreives the value from the defaults table with key
AbstractUndoableEdit.redoText and returns
that value followed by a space, followed by
getPresentationName .
|
String
|
getUndoPresentationName()
Retreives the value from the defaults table with key
AbstractUndoableEdit.undoText and returns
that value followed by a space, followed by
getPresentationName .
|
boolean
|
isSignificant()
This default implementation returns true.
|
void
|
redo()
Throws CannotRedoException if canRedo
returns false.
|
boolean
|
replaceEdit(UndoableEdit anEdit)
This default implementation returns false.
|
String
|
toString()
Returns a string that displays and identifies this
object's properties.
|
void
|
undo()
Throws CannotUndoException if canUndo
returns false .
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
From interface
javax.swing.undo.UndoableEdit
abstract
boolean
|
addEdit(UndoableEdit anEdit)
Adds an UndoableEdit to this UndoableEdit .
|
abstract
boolean
|
canRedo()
Returns true if this edit may be redone.
|
abstract
boolean
|
canUndo()
Returns true if this edit may be undone.
|
abstract
void
|
die()
Informs the edit that it should no longer be used.
|
abstract
String
|
getPresentationName()
Returns a localized, human-readable description of this edit, suitable
for use in a change log, for example.
|
abstract
String
|
getRedoPresentationName()
Returns a localized, human-readable description of the redoable form of
this edit, suitable for use as a Redo menu item, for example.
|
abstract
String
|
getUndoPresentationName()
Returns a localized, human-readable description of the undoable form of
this edit, suitable for use as an Undo menu item, for example.
|
abstract
boolean
|
isSignificant()
Returns true if this edit is considered significant.
|
abstract
void
|
redo()
Re-applies the edit.
|
abstract
boolean
|
replaceEdit(UndoableEdit anEdit)
Returns true if this UndoableEdit should replace
anEdit .
|
abstract
void
|
undo()
Undo the edit.
|
|
Constants
protected
static
final
String
RCSID
Constant Value:
"$Id: StateEdit.java,v 1.6 1997/10/01 20:05:51 sandipc Exp $"
Fields
The state information after the edit
The state information prior to the edit
protected
String
undoRedoName
The undo/redo presentation name
Public Constructors
public
StateEdit
(StateEditable anObject)
Create and return a new StateEdit.
Parameters
anObject
| The object to watch for changing state |
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 |
Public Methods
public
void
end
()
Gets the post-edit state of the StateEditable object and
ends the edit.
public
String
getPresentationName
()
Gets the presentation name for this edit
public
void
redo
()
Tells the edited object to apply the state after the edit
public
void
undo
()
Tells the edited object to apply the state prior to the edit
Protected Methods
protected
void
removeRedundantState
()
Remove redundant key/values in state hashtables.