UndoStack (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.event
Class UndoStack

    java.lang.Object
      com.bbn.openmap.MapHandlerChild
          com.bbn.openmap.OMComponent
              com.bbn.openmap.event.UndoStack

All Implemented Interfaces:
  LightMapHandlerChild, PropertyConsumer, java.awt.event.ActionListener, java.beans.beancontext.BeanContextChild, java.beans.beancontext.BeanContextMembershipListener, java.util.EventListener

    public class UndoStack

extends OMComponent
implements java.awt.event.ActionListener

Provides a stack of actions that can be undone/redone. The UndoEvent objects contain the information needed to implement the actions. The UndoStack is told to push UndoEvents on their source objects by UndoStackTriggers using a regular ActionListener/ActionEvent mechanism. The UndoStack is an ActionListener to the triggers (GUI buttons/menu items that say Undo or Redo).

Field Summary
`static java.lang.String` | `ClearCmd`
`static java.lang.String` | `ClearRedoCmd`
`static java.lang.String` | `ClearUndoCmd`
`protected UndoEvent` | `currentState` The notion of the current state is important.
`static int` | `DEFAULT_MAX_SIZE`
`static java.lang.String` | `RedoCmd`
`protected java.util.Stack<UndoEvent>` | `redoStack`
`static int` | `REMEMBER_ALL`
`protected int` | `stackSize`
`protected UndoStackSupport` | `triggers`
`static java.lang.String` | `UndoCmd`
`protected java.util.Stack<UndoEvent>` | `undoStack`

Fields inherited from class com.bbn.openmap.OMComponent
`i18n, propertyPrefix`

Fields inherited from class com.bbn.openmap.MapHandlerChild
`beanContextChildSupport, isolated`

Fields inherited from interface com.bbn.openmap.PropertyConsumer
`EditorProperty, initPropertiesProperty, LabelEditorProperty, ScopedEditorProperty`

Constructor Summary
`UndoStack()`

Method Summary
`void` | `actionPerformed(java.awt.event.ActionEvent ae)`
`void` | `addUndoStackTrigger(UndoStackTrigger trigger)` UndoStackTriggers should call this method to add themselves for stack notifications, and all will be well.
`void` | `clearStacks(boolean clearUndoStack, boolean clearRedoStack)` Clear out the chosen undo stacks and fire an event to update the triggers on stack status.
`void` | `fireStackStatus()`
`protected UndoEvent` | `getWhatWillHappenNextFromStack(java.util.Stack<UndoEvent> stack)`
`protected void` | `redo()` Take a UndoEvent off the forwardStack, and push it on the backStack.
`protected void` | `rememberLastThing(UndoEvent event)` Put a new UndoEvent on the backStack, to remember for later in case we need to back up.
`void` | `removeUndoStackTrigger(UndoStackTrigger trigger)` UndoStackTriggers should call this method to remove themselves from stack notifications, and all will be well.
`void` | `setTheWayThingsAre(UndoEvent event)` Sets the current state of some object on the stack.
`protected void` | `undo()` Take a UndoEvent off the backStack, and push it on the forward stack, and invoke the new currentState so the source component gets modified.

Methods inherited from class com.bbn.openmap.OMComponent
`getProperties, getPropertyInfo, getPropertyPrefix, setProperties, setProperties, setPropertyPrefix`

Methods inherited from class com.bbn.openmap.MapHandlerChild
`addPropertyChangeListener, addVetoableChangeListener, childrenAdded, childrenRemoved, findAndInit, findAndInit, findAndUndo, firePropertyChange, fireVetoableChange, getBeanContext, isIsolated, removePropertyChangeListener, removeVetoableChangeListener, setBeanContext, setIsolated`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_MAX_SIZE

    public static final int DEFAULT_MAX_SIZE

See Also:
  Constant Field Values

### REMEMBER_ALL

    public static final int REMEMBER_ALL

See Also:
  Constant Field Values

### currentState

    protected transient UndoEvent currentState

  The notion of the current state is important. When the user does something, a component that is interested in undo/redo should push a current state to this stack. This current state reflects the state of some object at the current time. If another state gets set, then the old state is now put on the undo stack. If the undo command is given to this stack, then an event is popped off the undo stack, set to be the current state. The old state gets pushed to the redo stack.

### stackSize

    protected int stackSize

### UndoCmd

    public static final transient java.lang.String UndoCmd

See Also:
  Constant Field Values

### RedoCmd

    public static final transient java.lang.String RedoCmd

See Also:
  Constant Field Values

### ClearUndoCmd

    public static final transient java.lang.String ClearUndoCmd

See Also:
  Constant Field Values

### ClearRedoCmd

    public static final transient java.lang.String ClearRedoCmd

See Also:
  Constant Field Values

### ClearCmd

    public static final transient java.lang.String ClearCmd

See Also:
  Constant Field Values

### undoStack

    protected final java.util.Stack<UndoEvent> undoStack

### redoStack

    protected final java.util.Stack<UndoEvent> redoStack

### triggers

    protected final UndoStackSupport triggers

Constructor Detail

### UndoStack

    public UndoStack()

Method Detail

### setTheWayThingsAre

    public void setTheWayThingsAre(UndoEvent event)

  Sets the current state of some object on the stack. The stack doesn't care what that event/state represents, since it has all the info needed to tell components how to get back to this state later. Anyway, this current state kinda hangs out in limbo. If another event/state comes in, the current state gets pushed on the undo stack. The redo stack gets cleared, since a new state path forward has been established.

  Parameters:
    `event` -

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent ae)

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`

### rememberLastThing

    protected void rememberLastThing(UndoEvent event)

  Put a new UndoEvent on the backStack, to remember for later in case we need to back up.

  Parameters:
    `event` - UndoEvent.

### undo

    protected void undo()

  Take a UndoEvent off the backStack, and push it on the forward stack, and invoke the new currentState so the source component gets modified.

### redo

    protected void redo()

  Take a UndoEvent off the forwardStack, and push it on the backStack.

### clearStacks

    public void clearStacks(boolean clearUndoStack,
                            boolean clearRedoStack)

  Clear out the chosen undo stacks and fire an event to update the triggers on stack status. Also sets the current state, which isn't held by either stack, to null.

  Parameters:
    `clearUndoStack` - clear out the undo stack.
    `clearRedoStack` - clear out the redo stack.

### fireStackStatus

    public void fireStackStatus()

### getWhatWillHappenNextFromStack

    protected UndoEvent getWhatWillHappenNextFromStack(java.util.Stack<UndoEvent> stack)

### addUndoStackTrigger

    public void addUndoStackTrigger(UndoStackTrigger trigger)

  UndoStackTriggers should call this method to add themselves for stack notifications, and all will be well.

### removeUndoStackTrigger

    public void removeUndoStackTrigger(UndoStackTrigger trigger)

  UndoStackTriggers should call this method to remove themselves from stack notifications, and all will be well.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details