Gridarta Editor
net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R > Class Template Reference

Implements the controller for undo/redo actions. More...

+ Inheritance diagram for net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:
+ Collaboration diagram for net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >:

Public Member Functions

int getMaxUndoStates ()
 Returns the maximum number of undo states saved for each map. More...
 
void redo ()
 "Redo" was selected. More...
 
void setAction (@NotNull final Action action, @NotNull final String name)
 Sets the Action instance for this editor action. More...
 
void setMaxUndoStates (final int maxUndoStates)
 Sets the maximum number of undo states saved for each map. More...
 
void undo ()
 "Undo" was selected. More...
 
 UndoControl (@NotNull final MapManager< G, A, R > mapManager, @NotNull final GameObjectFactory< G, A, R > gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers)
 Create a new instance. More...
 

Private Member Functions

boolean doRedo (final boolean performAction)
 Performs the "redo" action. More...
 
boolean doUndo (final boolean performAction)
 Performs the "undo" action. More...
 
void refreshMenus ()
 Enable/disable menu entries based on the current state. More...
 

Private Attributes

Action aRedo
 Action for "redo" function. More...
 
Action aUndo
 Action for "undo" function. More...
 
MapModel< G, A, R > mapModel
 Map model for the current map. More...
 
int maxUndoStates = 100
 The maximum number of undo states saved for each map. More...
 
final Map< MapModel< G, A, R >, UndoModel< G, A, R > > undoModels = new IdentityHashMap<>()
 Contains an UndoModel for each known MapModel. More...
 

Static Private Attributes

static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
 Action Builder to create Actions. More...
 

Detailed Description

Implements the controller for undo/redo actions.

Author
Andreas Kirschbaum

Definition at line 51 of file UndoControl.java.

Constructor & Destructor Documentation

◆ UndoControl()

net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.UndoControl ( @NotNull final MapManager< G, A, R >  mapManager,
@NotNull final GameObjectFactory< G, A, R >  gameObjectFactory,
@NotNull final GameObjectMatchers  gameObjectMatchers 
)

Create a new instance.

Parameters
mapManagerthe map manager
gameObjectFactorythe game object factory to use
gameObjectMatchersthe game object matchers to use

Records the map state at transaction begin time. It is used to detect (and drop) edit operations that do not change the map state.

Records the undo model at transaction begin time.

Definition at line 94 of file UndoControl.java.

References net.sf.gridarta.model.mapmodel.MapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.addMapTransactionListener(), net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.cloneAndClear(), net.sf.gridarta.model.undo.UndoModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.finish(), net.sf.gridarta.model.mapmodel.MapModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMapArchObject(), net.sf.gridarta.model.undo.UndoState< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMapArchObject(), net.sf.gridarta.model.undo.UndoModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMapTransactionListener(), net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.refreshMenus(), net.sf.gridarta.model.mapmodel.SavedSquares< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.removeEmptySquares(), net.sf.gridarta.model.undo.UndoState< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setSavedSquares(), and net.sf.gridarta.model.undo.UndoModel< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.trimToSize().

+ Here is the call graph for this function:

Member Function Documentation

◆ doRedo()

◆ doUndo()

◆ getMaxUndoStates()

int net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.getMaxUndoStates ( )

Returns the maximum number of undo states saved for each map.

Returns
the maximum number of undo states saved for each map;
0
=unlimited

Definition at line 243 of file UndoControl.java.

References net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.maxUndoStates.

◆ redo()

void net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.redo ( )

"Redo" was selected.

Definition at line 234 of file UndoControl.java.

References net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doRedo().

+ Here is the call graph for this function:

◆ refreshMenus()

◆ setAction()

void net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setAction ( @NotNull final Action  action,
@NotNull final String  name 
)

Sets the Action instance for this editor action.

Parameters
actionthe action instance
namethe name of the action

Implements net.sf.gridarta.utils.EditorAction.

Definition at line 327 of file UndoControl.java.

◆ setMaxUndoStates()

void net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.setMaxUndoStates ( final int  maxUndoStates)

Sets the maximum number of undo states saved for each map.

Parameters
maxUndoStatesthe maximum number of undo states saved for each map;
0
=unlimited

Definition at line 252 of file UndoControl.java.

References net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.maxUndoStates.

◆ undo()

void net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.undo ( )

"Undo" was selected.

Definition at line 226 of file UndoControl.java.

References net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.doUndo().

Referenced by net.sf.gridarta.actions.UndoActionsTest.testInsert1().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ ACTION_BUILDER

final ActionBuilder net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta")
staticprivate

Action Builder to create Actions.

Definition at line 57 of file UndoControl.java.

◆ aRedo

Action net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.aRedo
private

Action for "redo" function.

Definition at line 86 of file UndoControl.java.

◆ aUndo

Action net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.aUndo
private

Action for "undo" function.

Definition at line 80 of file UndoControl.java.

◆ mapModel

◆ maxUndoStates

◆ undoModels

final Map<MapModel<G, A, R>, UndoModel<G, A, R> > net.sf.gridarta.gui.undo.UndoControl< G extends GameObject< G, A, R, A extends MapArchObject< A, R extends Archetype< G, A, R >.undoModels = new IdentityHashMap<>()
private

Contains an UndoModel for each known MapModel.

Definition at line 63 of file UndoControl.java.


The documentation for this class was generated from the following file: