Package com.uppaal.model.core2
Class CommandManager
java.lang.Object
com.uppaal.model.core2.CommandManager
public class CommandManager extends Object
The central class for the command manager
-
Constructor Summary
Constructors Constructor Description CommandManager()
Default constructor.CommandManager(CommandManager orig)
Copy constructor, because "clone()" idiom is badly broken and only version number is preserved anyway. -
Method Summary
Modifier and Type Method Description void
addCommandListener(CommandListener listener)
Adds editing command listenerboolean
canRedo()
Can redoboolean
canUndo()
Can undovoid
execute(Command command)
Execute a command.void
execute(Command... commands)
Execute the commandsCommand
getLastCommand()
Returns the most recent command executedint
getVersion()
Get the version numbervoid
redo()
Redo last undone command.void
removeCommandListener(CommandListener listener)
removes editing command listenervoid
undo()
Undo last command.
-
Constructor Details
-
CommandManager
public CommandManager()Default constructor. -
CommandManager
Copy constructor, because "clone()" idiom is badly broken and only version number is preserved anyway.- Parameters:
orig
- the original command manager
-
-
Method Details
-
getVersion
public int getVersion()Get the version number- Returns:
- the version number
-
execute
Execute a command. Increases the version number.- Parameters:
command
- - The command line
-
execute
Execute the commands- Parameters:
commands
- - The commands
-
getLastCommand
Returns the most recent command executed- Returns:
- - the most recent executed command or null if no such command
-
undo
Undo last command. Decreases the version number.- Throws:
CannotUndoException
- when the undo-list is empty.
-
canUndo
public boolean canUndo()Can undo- Returns:
- - Undo list is empty
-
redo
Redo last undone command. Increases the version number.- Throws:
CannotRedoException
- when redo-list is empty
-
canRedo
public boolean canRedo()Can redo- Returns:
- - Redo list is empty
-
addCommandListener
Adds editing command listener- Parameters:
listener
- - command listener
-
removeCommandListener
removes editing command listener- Parameters:
listener
- - command listener
-