java.lang.Object
de.hamstersimulator.objectsfirst.commands.CommandStack
Direct Known Subclasses:
EditCommandStack

public abstract class CommandStack extends Object
  • Property Details

    • canUndo

      public ReadOnlyBooleanProperty canUndoProperty
      Getter for the canUndo property true if the game is stopped / paused and there is at least one command to undo
    • canRedo

      public ReadOnlyBooleanProperty canRedoProperty
      Getter for the canRedo property true if the game is stopped / paused and there is at least one command to redo
  • Field Details

  • Constructor Details

    • CommandStack

      public CommandStack()
  • Method Details

    • execute

      public void execute(Command command)
    • undoAll

      public void undoAll()
      Undoes all commands which are executed, in the inverse order than they where executed
    • redoAll

      public void redoAll()
      Redoes all commands which are currently undone, in the same order like they where executed first
    • undo

      public void undo()
      Undoes the last executed command, if possible
      Throws:
      IllegalStateException - if !canUndoProperty().get();
    • redo

      public void redo()
      Redoes the oldest undone command, if possible
      Throws:
      IllegalStateException - if !canRedoProperty().get();
    • hardReset

      public void hardReset()
      hard-resets the CommandStack. it clears executedCommands and undoneCommands, however, it does NOT undo all commands. If this behaviour is desired, it is necessary to call undoAll first
    • canUndoProperty

      public ReadOnlyBooleanProperty canUndoProperty()
      Getter for the canUndo property true if the game is stopped / paused and there is at least one command to undo
    • canRedoProperty

      public ReadOnlyBooleanProperty canRedoProperty()
      Getter for the canRedo property true if the game is stopped / paused and there is at least one command to redo
    • getStateLock

      protected Lock getStateLock()
      Gets a lock used to synchronize all state (mode, canUndo, canRedo) related methods
      Returns:
      the lock (always the same instance)