org.openbp.jaspira.undo
Class UndoMgr

java.lang.Object
  extended by org.openbp.jaspira.undo.UndoMgr

public class UndoMgr
extends java.lang.Object

This Manager controls the states of the application. If any plugin is performing an action and changing the state of the application it has to notify the Manager. Transitions are used to undo one or a set of actions. If a state changing process is being started a new Transition has to be created. All undoable actions fired after this will be saved in the transition.

Author:
Jens Ferchland

Nested Class Summary
 class UndoMgr.Transaction
          A Transaction is a set of actions.
 
Field Summary
static int DEFAULT_HISTORY_SIZE
          Default history size: 10 operations
static java.lang.String TRANSITION_OPTION_NAME
          Name for the max history size option
static int UNLIMITED_HISTORY_SIZE
          Unlimited history - all transitions will be saved
 
Constructor Summary
UndoMgr()
          Constructor.
 
Method Summary
 boolean canRedo()
          Returns true if a redoable transition exists.
 boolean canUndo()
          Returns true if a undoable transition exists.
 void redo()
          Redoes the next redo transition.
 void registerUndoable(Undoable undo)
          Registers an undoable action.
 void reloadHistorySize()
          Reloads the history size.
 UndoMgr.Transaction startTransaction(java.lang.String displayName)
          Starts a new Transaction and returns it.
 void stopTransaction(UndoMgr.Transaction trans)
          Stops the Transaction.
 void undo()
          Undoes the last transition.
 void updateActions()
          Updates the actions undo and redo.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNLIMITED_HISTORY_SIZE

public static final int UNLIMITED_HISTORY_SIZE
Unlimited history - all transitions will be saved

See Also:
Constant Field Values

DEFAULT_HISTORY_SIZE

public static final int DEFAULT_HISTORY_SIZE
Default history size: 10 operations

See Also:
Constant Field Values

TRANSITION_OPTION_NAME

public static final java.lang.String TRANSITION_OPTION_NAME
Name for the max history size option

See Also:
Constant Field Values
Constructor Detail

UndoMgr

public UndoMgr()
Constructor.

Method Detail

startTransaction

public UndoMgr.Transaction startTransaction(java.lang.String displayName)
Starts a new Transaction and returns it. All next registrations of undoable objects will be recorded in this transition.

Parameters:
displayName - Displayable name of the transaction.
This name might be displayed in the undo menu to identify the action to be undone.
Returns:
The new transition. If a transition is already active, no new transition will be created and null will be returned.

stopTransaction

public void stopTransaction(UndoMgr.Transaction trans)
Stops the Transaction. To be sure the right plugin stops the transition the transition object is used for identification.

Parameters:
trans - - the current transition for identification

registerUndoable

public void registerUndoable(Undoable undo)
Registers an undoable action. If no transition is active a new transition will be create.

Parameters:
undo - - the action, to undo

canRedo

public boolean canRedo()
Returns true if a redoable transition exists.

Returns:
boolean - true: redo transition exists. false: otherwise.

redo

public void redo()
Redoes the next redo transition.


canUndo

public boolean canUndo()
Returns true if a undoable transition exists.

Returns:
boolean - true: undo transition exists. false: otherwise.

undo

public void undo()
Undoes the last transition.


updateActions

public void updateActions()
Updates the actions undo and redo. Set the actions active or not.


reloadHistorySize

public void reloadHistorySize()
Reloads the history size.



Copyright © 2011. All Rights Reserved.