jcreek.cke.browser
Class UndoHandler

java.lang.Object
  extended byjcreek.cke.browser.UndoHandler
All Implemented Interfaces:
java.util.EventListener, javax.swing.event.UndoableEditListener

public class UndoHandler
extends java.lang.Object
implements javax.swing.event.UndoableEditListener

This class handles all things undo-related in Creek. It creates and manages the undo manager object. It also has the undo and redo actions and registers them with the MainWindow class.

Version:
Author:

Field Summary
protected  RedoAction redoAction
          Our global redo action.
protected  CreekUndoManager undo
          Global undo manager for performing undo/redo events.
protected  UndoAction undoAction
          Our global undo action.
 
Constructor Summary
UndoHandler()
          Creates a new UndoHandler object, to handle undoable edit events.
 
Method Summary
 void reattachEdits(CreekDocument oldDoc, CreekDocument newDoc)
          Tell the edits associated with the old document that they should reattach themselves to the new document.
 void removeEdits(CreekDocument doc)
          Trim the edits associated with the given document.
 void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
          Called when a document has performed an edit.
 void update()
          Causes the undo and redo actions to update themselves.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

undo

protected CreekUndoManager undo
Global undo manager for performing undo/redo events.


undoAction

protected UndoAction undoAction
Our global undo action.


redoAction

protected RedoAction redoAction
Our global redo action.

Constructor Detail

UndoHandler

public UndoHandler()
Creates a new UndoHandler object, to handle undoable edit events. Also creates the undo/redo actions and sets up the undo manager.

Method Detail

reattachEdits

public void reattachEdits(CreekDocument oldDoc,
                          CreekDocument newDoc)
Tell the edits associated with the old document that they should reattach themselves to the new document.

Parameters:
oldDoc - previous document
newDoc - new document

removeEdits

public void removeEdits(CreekDocument doc)
Trim the edits associated with the given document.

Parameters:
doc - document being closed

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
Called when a document has performed an edit. The edit is added to undo manager and the undo/redo actions are updated.

Specified by:
undoableEditHappened in interface javax.swing.event.UndoableEditListener
Parameters:
e - undoable edit event

update

public void update()
Causes the undo and redo actions to update themselves.



Created at IDI, NTNU by the Artificial Intelligence and Learning group