cmu.survey.data.databits
Class DataBitCompoundUndoableEdit<T>

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by javax.swing.undo.CompoundEdit
          extended by org.browsecode.helpers.undo.CompoundUndoableEdit2
              extended by cmu.survey.data.databits.DataBitCompoundUndoableEdit<T>
All Implemented Interfaces:
DataBitUndoableEdit<T>, java.io.Serializable, javax.swing.undo.UndoableEdit, UndoableEdit2

public class DataBitCompoundUndoableEdit<T>
extends CompoundUndoableEdit2
implements DataBitUndoableEdit<T>

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.browsecode.helpers.undo.CompoundUndoableEdit2
CompoundUndoableEdit2.ExtendedUndoException
 
Field Summary
protected  DataBit<T> dataBit
           
protected  T newValue
           
protected  T oldValue
           
 
Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Fields inherited from interface org.browsecode.helpers.undo.UndoableEdit2
debug
 
Constructor Summary
DataBitCompoundUndoableEdit(DataBit<T> dataBit)
           
DataBitCompoundUndoableEdit(DataBit<T> dataBit, java.lang.Object changeType)
           
DataBitCompoundUndoableEdit(DataBit<T> dataBit, java.lang.Object changeType, java.lang.String presentationName)
           
DataBitCompoundUndoableEdit(DataBit<T> dataBit, java.lang.Object changeType, java.lang.String presentationName, T oldValue, T newValue)
           
 
Method Summary
 boolean addEdit(DataBitUndoableEdit<T> anEdit)
           
 boolean addEditRegardlessofKey(DataBitUndoableEdit<T> anEdit)
          For internal use only -- when edits should be grouped together regardless of type.
 boolean canMergeWith(UndoableEdit2 undoableEdit)
          Whether or not this can merge with another thing.
 boolean canRedo()
           
 boolean canUndo()
           
 DataBit<T> getKeyObjectDataBit()
           
 void redo()
           
 void undo()
           
 
Methods inherited from class org.browsecode.helpers.undo.CompoundUndoableEdit2
addEdit, addEditRegardlessofKey, end, getChangeType, getEdits, getKeyObject, getPresentationName, getRedoPresentationName, getUndoPresentationName, hasEdits, isMergeSameObject, isMergeSameObjectAndType, isSignificant, setSignificant
 
Methods inherited from class javax.swing.undo.CompoundEdit
addEdit, die, isInProgress, lastEdit, toString
 
Methods inherited from class javax.swing.undo.AbstractUndoableEdit
replaceEdit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cmu.survey.data.databits.DataBitUndoableEdit
getChangeType
 
Methods inherited from interface org.browsecode.helpers.undo.UndoableEdit2
getKeyObject
 
Methods inherited from interface javax.swing.undo.UndoableEdit
addEdit, die, getPresentationName, getRedoPresentationName, getUndoPresentationName, isSignificant, replaceEdit
 

Field Detail

dataBit

protected DataBit<T> dataBit

oldValue

protected T oldValue

newValue

protected T newValue
Constructor Detail

DataBitCompoundUndoableEdit

public DataBitCompoundUndoableEdit(DataBit<T> dataBit)

DataBitCompoundUndoableEdit

public DataBitCompoundUndoableEdit(DataBit<T> dataBit,
                                   java.lang.Object changeType)

DataBitCompoundUndoableEdit

public DataBitCompoundUndoableEdit(DataBit<T> dataBit,
                                   java.lang.Object changeType,
                                   java.lang.String presentationName)

DataBitCompoundUndoableEdit

public DataBitCompoundUndoableEdit(DataBit<T> dataBit,
                                   java.lang.Object changeType,
                                   java.lang.String presentationName,
                                   T oldValue,
                                   T newValue)
Method Detail

getKeyObjectDataBit

public DataBit<T> getKeyObjectDataBit()
Specified by:
getKeyObjectDataBit in interface DataBitUndoableEdit<T>

addEditRegardlessofKey

public boolean addEditRegardlessofKey(DataBitUndoableEdit<T> anEdit)
For internal use only -- when edits should be grouped together regardless of type.

Parameters:
anEdit -
Returns:

addEdit

public boolean addEdit(DataBitUndoableEdit<T> anEdit)

canMergeWith

public boolean canMergeWith(UndoableEdit2 undoableEdit)
Description copied from class: CompoundUndoableEdit2
Whether or not this can merge with another thing. For example, you always need both of these to be true (and usually the UndoHandler will check these first) a) the keyObject's need to be identical b) the change types need to be identical c) The merges need to be consecutive or connected in some way. For example, a text editor should say yes to inserts if the inserts of each letter were consecutive, and would say no if there were inserts that were not consecutive. The UndoableEdit2 that is passed in is expected to be a CompoundUndoableEdit2 that was created by UndoHandler. Do not directly test the undoableEdit passed in with instanceof -- it will probably always fail. Instead, test the type, the key item, and if necessary, go through the stack and get the items in it to check what's in it.

Specified by:
canMergeWith in interface UndoableEdit2
Overrides:
canMergeWith in class CompoundUndoableEdit2

undo

public void undo()
          throws javax.swing.undo.CannotUndoException
Specified by:
undo in interface javax.swing.undo.UndoableEdit
Overrides:
undo in class javax.swing.undo.CompoundEdit
Throws:
javax.swing.undo.CannotUndoException

canUndo

public boolean canUndo()
Specified by:
canUndo in interface javax.swing.undo.UndoableEdit
Overrides:
canUndo in class javax.swing.undo.CompoundEdit

redo

public void redo()
          throws javax.swing.undo.CannotRedoException
Specified by:
redo in interface javax.swing.undo.UndoableEdit
Overrides:
redo in class javax.swing.undo.CompoundEdit
Throws:
javax.swing.undo.CannotRedoException

canRedo

public boolean canRedo()
Specified by:
canRedo in interface javax.swing.undo.UndoableEdit
Overrides:
canRedo in class javax.swing.undo.CompoundEdit