dip.gui.undo
Class UndoRedoManager

java.lang.Object
  extended byjavax.swing.undo.AbstractUndoableEdit
      extended byjavax.swing.undo.CompoundEdit
          extended byjavax.swing.undo.UndoManager
              extended bydip.gui.undo.UndoRedoManager
All Implemented Interfaces:
java.util.EventListener, java.io.Serializable, javax.swing.undo.UndoableEdit, javax.swing.event.UndoableEditListener

public class UndoRedoManager
extends javax.swing.undo.UndoManager

Manages Undo/Redo events, and associated Edit menu items involving Undo and Redo.

This is not a singleton.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.undo.CompoundEdit
edits
 
Fields inherited from class javax.swing.undo.AbstractUndoableEdit
RedoName, UndoName
 
Constructor Summary
UndoRedoManager(ClientFrame clientFrame, OrderDisplayPanel orderDisplayPanel)
          Constructor
 
Method Summary
 boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
          Add an Edit (UndoableEdit)
 void discardAllEdits()
          Throw away all stored edits
 void dumpEdits()
          For debugging: lists edits.
 void filterF2F()
          Filters the Undo list, in reverse order, removing all actions until the first UndoResolve action is detected.
 ClientFrame getClientFrame()
          Returns the ClientFrame object
 OrderDisplayPanel getOrderDisplayPanel()
          Returns the OrderDisplayPanel associated with this UndoRedo manager.
 void redo()
          Redo last undo
 void refreshMenu()
          Refreshes the menu items, enabling & adding action names as appropriate.
 void setClientFrame(ClientFrame clientFrame)
          Can be used post-deserialization
 void setOrderDisplayPanel(OrderDisplayPanel orderDisplayPanel)
          Can be used post-deserialization
 void simplify()
          Simplifies the undo list.
 void undo()
          Undo an UndoableEdit
 void undoOrRedo()
          Undo or Redo
 
Methods inherited from class javax.swing.undo.UndoManager
canRedo, canUndo, canUndoOrRedo, editToBeRedone, editToBeUndone, end, getLimit, getRedoPresentationName, getUndoOrRedoPresentationName, getUndoPresentationName, redoTo, setLimit, toString, trimEdits, trimForLimit, undoableEditHappened, undoTo
 
Methods inherited from class javax.swing.undo.CompoundEdit
die, getPresentationName, isInProgress, isSignificant, lastEdit
 
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
 

Constructor Detail

UndoRedoManager

public UndoRedoManager(ClientFrame clientFrame,
                       OrderDisplayPanel orderDisplayPanel)
Constructor

Method Detail

setClientFrame

public void setClientFrame(ClientFrame clientFrame)
Can be used post-deserialization


setOrderDisplayPanel

public void setOrderDisplayPanel(OrderDisplayPanel orderDisplayPanel)
Can be used post-deserialization


addEdit

public boolean addEdit(javax.swing.undo.UndoableEdit anEdit)
Add an Edit (UndoableEdit)


redo

public void redo()
Redo last undo


undo

public void undo()
Undo an UndoableEdit


discardAllEdits

public void discardAllEdits()
Throw away all stored edits


undoOrRedo

public void undoOrRedo()
Undo or Redo


dumpEdits

public void dumpEdits()
For debugging: lists edits.


getOrderDisplayPanel

public OrderDisplayPanel getOrderDisplayPanel()
Returns the OrderDisplayPanel associated with this UndoRedo manager.


getClientFrame

public ClientFrame getClientFrame()
Returns the ClientFrame object


refreshMenu

public void refreshMenu()
Refreshes the menu items, enabling & adding action names as appropriate. This is mode-aware; undo/redo is only available when in MODE_EDIT and MODE_ORDER.


filterF2F

public void filterF2F()
Filters the Undo list, in reverse order, removing all actions until the first UndoResolve action is detected. This is used when in F2F and switching powers, so that a power can 'undo' but cannot undo or see another power's moves.


simplify

public void simplify()
Simplifies the undo list. We save all undoable actions for the current TurnState. However, after the TurnState has been resolved, all old actions (order adds/deletes, edit actions, etc) except for UndoResolve are eliminated.

The rationale for this is this enables quickly undoing a number of resolves, and simplifies the task of going 'back in time' to change the game.



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.