org.browsecode.helpers.undo
Class CompoundUndoableEdit2

java.lang.Object
  extended by javax.swing.undo.AbstractUndoableEdit
      extended by javax.swing.undo.CompoundEdit
          extended by org.browsecode.helpers.undo.CompoundUndoableEdit2
All Implemented Interfaces:
java.io.Serializable, javax.swing.undo.UndoableEdit, UndoableEdit2
Direct Known Subclasses:
DataBitCompoundUndoableEdit

public class CompoundUndoableEdit2
extends javax.swing.undo.CompoundEdit
implements UndoableEdit2

See Also:
Serialized Form

Nested Class Summary
 class CompoundUndoableEdit2.ExtendedUndoException
           
 
Field Summary
 
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
CompoundUndoableEdit2(java.lang.Object keyObject)
           
CompoundUndoableEdit2(java.lang.Object keyObject, java.lang.Object changeType)
           
CompoundUndoableEdit2(java.lang.Object keyObject, java.lang.Object changeType, java.lang.String presentationName)
           
 
Method Summary
 boolean addEdit(UndoableEdit2 anEdit)
           
 boolean addEditRegardlessofKey(UndoableEdit2 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.
 void end()
           
 java.lang.Object getChangeType()
           
 java.util.Vector<javax.swing.undo.UndoableEdit> getEdits()
           
 java.lang.Object getKeyObject()
          Returns the key object that was changed.
 java.lang.String getPresentationName()
           
 java.lang.String getRedoPresentationName()
           
 java.lang.String getUndoPresentationName()
           
 boolean hasEdits()
          Whether or not some edits have been added successfully.
protected  boolean isMergeSameObject(UndoableEdit2 undoableEdit)
          Helper merge method -- tells whether they're both the same object.
protected  boolean isMergeSameObjectAndType(UndoableEdit2 undoableEdit)
           
 boolean isSignificant()
           
 void setSignificant(java.lang.Boolean significant)
          Null means that it won't try to set the significace here -- it will get isSignificant from super.isSignificant(), i.e. all the sub-items, instead.
 
Methods inherited from class javax.swing.undo.CompoundEdit
addEdit, canRedo, canUndo, die, isInProgress, lastEdit, redo, toString, undo
 
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 javax.swing.undo.UndoableEdit
addEdit, canRedo, canUndo, die, redo, replaceEdit, undo
 

Constructor Detail

CompoundUndoableEdit2

public CompoundUndoableEdit2(java.lang.Object keyObject)

CompoundUndoableEdit2

public CompoundUndoableEdit2(java.lang.Object keyObject,
                             java.lang.Object changeType)

CompoundUndoableEdit2

public CompoundUndoableEdit2(java.lang.Object keyObject,
                             java.lang.Object changeType,
                             java.lang.String presentationName)
Method Detail

getChangeType

public java.lang.Object getChangeType()
Specified by:
getChangeType in interface UndoableEdit2

end

public void end()
Overrides:
end in class javax.swing.undo.CompoundEdit

getPresentationName

public java.lang.String getPresentationName()
Specified by:
getPresentationName in interface javax.swing.undo.UndoableEdit
Overrides:
getPresentationName in class javax.swing.undo.CompoundEdit

getUndoPresentationName

public java.lang.String getUndoPresentationName()
Specified by:
getUndoPresentationName in interface javax.swing.undo.UndoableEdit
Overrides:
getUndoPresentationName in class javax.swing.undo.CompoundEdit

getRedoPresentationName

public java.lang.String getRedoPresentationName()
Specified by:
getRedoPresentationName in interface javax.swing.undo.UndoableEdit
Overrides:
getRedoPresentationName in class javax.swing.undo.CompoundEdit

canMergeWith

public boolean canMergeWith(UndoableEdit2 undoableEdit)
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
Parameters:
undoableEdit -

isMergeSameObject

protected boolean isMergeSameObject(UndoableEdit2 undoableEdit)
Helper merge method -- tells whether they're both the same object.

Parameters:
undoableEdit -
Returns:

isMergeSameObjectAndType

protected boolean isMergeSameObjectAndType(UndoableEdit2 undoableEdit)

getKeyObject

public java.lang.Object getKeyObject()
Description copied from interface: UndoableEdit2
Returns the key object that was changed. This may be used to do a search for what other changes this change is dependent on -- so, for example, if you edit a chunk of text twice, both Deltas should return the same data storage thing which has that information. Then you can tell the user that all these things need to be undone to undo this thing alone.

Specified by:
getKeyObject in interface UndoableEdit2
Returns:

addEditRegardlessofKey

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

Parameters:
anEdit -
Returns:

addEdit

public boolean addEdit(UndoableEdit2 anEdit)

setSignificant

public void setSignificant(java.lang.Boolean significant)
Null means that it won't try to set the significace here -- it will get isSignificant from super.isSignificant(), i.e. all the sub-items, instead.

Parameters:
significant -

isSignificant

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

hasEdits

public boolean hasEdits()
Whether or not some edits have been added successfully.

Returns:

getEdits

public java.util.Vector<javax.swing.undo.UndoableEdit> getEdits()