org.merlotxml.merlot
Class MerlotUndoableEdit

java.lang.Object
  extended byorg.merlotxml.merlot.MerlotUndoableEdit
All Implemented Interfaces:
MerlotConstants, javax.swing.undo.UndoableEdit

public class MerlotUndoableEdit
extends java.lang.Object
implements javax.swing.undo.UndoableEdit, MerlotConstants


Field Summary
protected  int _action
           
protected  MerlotDOMNode _node
          For deletes this is the only node, For moves, this is the node being moved.
protected  int[] _nodeLocation
          this is basically a TreePath with child indices instead of object refs of where the node used to be before being deleted or moved.
protected  java.lang.String _presName
          Presentation name
protected  DOMTreeTableAdapter _tableModel
           
static int DELETE
           
static int INSERT
           
static int MOVE
           
 
Fields inherited from interface org.merlotxml.merlot.MerlotConstants
ACTION_MENU_ACCELERATOR, ACTION_MENU_ICON, ACTION_NAME, ACTION_SHORT_DESCRIPTION, ACTION_SMALL_ICON, AFTER, BEFORE, ERR, INTO, UI, XML
 
Constructor Summary
MerlotUndoableEdit(java.lang.String pname, int action, DOMTreeTableAdapter model, MerlotDOMNode nd, int[] where)
           
 
Method Summary
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
          This UndoableEdit should absorb anEdit if it can.
 java.lang.String array2String(int[] array)
           
 boolean canRedo()
          True if it is still possible to redo this operation
 boolean canUndo()
          True if it is still possible to undo this operation
 void die()
          May be sent to inform an edit that it should no longer be used.
protected  MerlotDOMNode getParentFromLocationPath()
          This gets the parent node from the location path
 java.lang.String getPresentationName()
          Provide a localized, human readable description of this edit suitable for use in, say, a change log.
 java.lang.String getRedoPresentationName()
          Provide a localized, human readable description of the redoable form of this edit, e.g.
 java.lang.String getUndoPresentationName()
          Provide a localized, human readable description of the undoable form of this edit, e.g.
 boolean isSignificant()
          Return false if this edit is insignificant--for example one that maintains the user's selection, but does not change any model state.
 void redo()
          Re-apply the edit, assuming that it has been undone.
 boolean replaceEdit(javax.swing.undo.UndoableEdit anEdit)
          Return true if this UndoableEdit should replace anEdit.
 void setPresentationName(java.lang.String s)
           
 java.lang.String toString()
           
 void undo()
          Undo the edit that was made.
protected  void undoDelete()
           
protected  void undoInsert()
           
protected  void undoMove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DELETE

public static final int DELETE
See Also:
Constant Field Values

INSERT

public static final int INSERT
See Also:
Constant Field Values

MOVE

public static final int MOVE
See Also:
Constant Field Values

_node

protected MerlotDOMNode _node
For deletes this is the only node, For moves, this is the node being moved. For inserts this is the node being inserted.


_nodeLocation

protected int[] _nodeLocation
this is basically a TreePath with child indices instead of object refs of where the node used to be before being deleted or moved. We don't care about location when undoing an insert. We just erase it.


_tableModel

protected DOMTreeTableAdapter _tableModel

_presName

protected java.lang.String _presName
Presentation name


_action

protected int _action
Constructor Detail

MerlotUndoableEdit

public MerlotUndoableEdit(java.lang.String pname,
                          int action,
                          DOMTreeTableAdapter model,
                          MerlotDOMNode nd,
                          int[] where)
Method Detail

undo

public void undo()
          throws javax.swing.undo.CannotUndoException
Undo the edit that was made.

Specified by:
undo in interface javax.swing.undo.UndoableEdit
Throws:
javax.swing.undo.CannotUndoException

undoDelete

protected void undoDelete()
                   throws javax.swing.undo.CannotUndoException
Throws:
javax.swing.undo.CannotUndoException

undoInsert

protected void undoInsert()
                   throws javax.swing.undo.CannotUndoException
Throws:
javax.swing.undo.CannotUndoException

undoMove

protected void undoMove()
                 throws javax.swing.undo.CannotUndoException
Throws:
javax.swing.undo.CannotUndoException

getParentFromLocationPath

protected MerlotDOMNode getParentFromLocationPath()
                                           throws javax.swing.undo.CannotUndoException
This gets the parent node from the location path

Throws:
javax.swing.undo.CannotUndoException

canUndo

public boolean canUndo()
True if it is still possible to undo this operation

Specified by:
canUndo in interface javax.swing.undo.UndoableEdit

redo

public void redo()
          throws javax.swing.undo.CannotRedoException
Re-apply the edit, assuming that it has been undone.

Specified by:
redo in interface javax.swing.undo.UndoableEdit
Throws:
javax.swing.undo.CannotRedoException

canRedo

public boolean canRedo()
True if it is still possible to redo this operation

Specified by:
canRedo in interface javax.swing.undo.UndoableEdit

die

public void die()
May be sent to inform an edit that it should no longer be used. This is a useful hook for cleaning up state no longer needed once undoing or redoing is impossible--for example, deleting file resources used by objects that can no longer be undeleted. UndoManager calls this before it dequeues edits. Note that this is a one-way operation. There is no "undie" method.

Specified by:
die in interface javax.swing.undo.UndoableEdit
See Also:
CompoundEdit#die

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

replaceEdit

public boolean replaceEdit(javax.swing.undo.UndoableEdit anEdit)
Return true if this UndoableEdit should replace anEdit. The receiver should incorporate anEdit's state before returning true.

This message is the opposite of addEdit--anEdit has typically already been queued in a UndoManager (or other UndoableEditListener), and the receiver is being given a chance to take its place.

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:
replaceEdit in interface javax.swing.undo.UndoableEdit

isSignificant

public boolean isSignificant()
Return false if this edit is insignificant--for example one that maintains the user's selection, but does not change any model state. This status can be used by an UndoableEditListener (like UndoManager) when deciding which UndoableEdits to present to the user as Undo/Redo options, and which to perform as side effects of undoing or redoing other events.

Specified by:
isSignificant in interface javax.swing.undo.UndoableEdit

getPresentationName

public java.lang.String getPresentationName()
Provide a localized, human readable description of this edit suitable for use in, say, a change log.

Specified by:
getPresentationName in interface javax.swing.undo.UndoableEdit

setPresentationName

public void setPresentationName(java.lang.String s)

getUndoPresentationName

public java.lang.String getUndoPresentationName()
Provide a localized, human readable description of the undoable form of this edit, e.g. for use as an Undo menu item. Typically derived from getDescription();

Specified by:
getUndoPresentationName in interface javax.swing.undo.UndoableEdit

getRedoPresentationName

public java.lang.String getRedoPresentationName()
Provide a localized, human readable description of the redoable form of this edit, e.g. for use as a Redo menu item. Typically derived from getPresentationName();

Specified by:
getRedoPresentationName in interface javax.swing.undo.UndoableEdit

toString

public java.lang.String toString()

array2String

public java.lang.String array2String(int[] array)