Class AbstractScenarioSimulationUndoableCommand<S>
- java.lang.Object
-
- org.kie.workbench.common.command.client.AbstractCommand<ScenarioSimulationContext,ScenarioSimulationViolation>
-
- org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.AbstractScenarioSimulationCommand
-
- org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.AbstractScenarioSimulationUndoableCommand<S>
-
- Type Parameters:
S- defines the changing object status during the command execution
- All Implemented Interfaces:
org.kie.workbench.common.command.client.Command<ScenarioSimulationContext,ScenarioSimulationViolation>
- Direct Known Subclasses:
AbstractScenarioGridCommand,UpdateSettingsDataCommand
public abstract class AbstractScenarioSimulationUndoableCommand<S> extends AbstractScenarioSimulationCommand
This abstract class defines a family of Commands which can be undo-able and redo-able.
-
-
Field Summary
Fields Modifier and Type Field Description protected SrestorableStatusTheScenarioSimulationContext.Statusto restore when calling undo/redo.
-
Constructor Summary
Constructors Constructor Description AbstractScenarioSimulationUndoableCommand()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Optional<org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation>>commonUndoRedoPreExecution(ScenarioSimulationContext context)Method called soon before actual undo and redo operations to preliminary execute a tab switch without altering the call stack.org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation>execute(ScenarioSimulationContext context)org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation>redo(ScenarioSimulationContext context)protected abstract org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation>setCurrentContext(ScenarioSimulationContext context)The action to perform when an UNDO or REDO is required on this command.protected abstract SsetRestorableStatusPreExecution(ScenarioSimulationContext context)It sets the status BEFORE the command is launched.org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation>undo(ScenarioSimulationContext context)-
Methods inherited from class org.drools.workbench.screens.scenariosimulation.client.commands.actualcommands.AbstractScenarioSimulationCommand
commonExecution, getId, internalExecute
-
-
-
-
Field Detail
-
restorableStatus
protected S restorableStatus
TheScenarioSimulationContext.Statusto restore when calling undo/redo. Needed only for undoable commands.
-
-
Method Detail
-
setCurrentContext
protected abstract org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation> setCurrentContext(ScenarioSimulationContext context)
The action to perform when an UNDO or REDO is required on this command. Typically it restores the previous status and it stores the current one.- Parameters:
context-- Returns:
-
setRestorableStatusPreExecution
protected abstract S setRestorableStatusPreExecution(ScenarioSimulationContext context)
It sets the status BEFORE the command is launched. Typically it clones the current status before changes are applied.- Parameters:
context-- Returns:
-
commonUndoRedoPreExecution
public abstract Optional<org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation>> commonUndoRedoPreExecution(ScenarioSimulationContext context)
Method called soon before actual undo and redo operations to preliminary execute a tab switch without altering the call stack. (eg If the command change the status of a not shown grid, this switches the tab)- Parameters:
context-- Returns:
Optional<CommandResult<ScenarioSimulationViolation>>ofCommandResultBuilder.SUCCESSif a tab switch happened, otherwiseOptional.empty()
-
execute
public org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation> execute(ScenarioSimulationContext context)
- Specified by:
executein interfaceorg.kie.workbench.common.command.client.Command<ScenarioSimulationContext,ScenarioSimulationViolation>- Overrides:
executein classAbstractScenarioSimulationCommand
-
undo
public org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation> undo(ScenarioSimulationContext context)
- Specified by:
undoin interfaceorg.kie.workbench.common.command.client.Command<ScenarioSimulationContext,ScenarioSimulationViolation>- Overrides:
undoin classAbstractScenarioSimulationCommand
-
redo
public org.kie.workbench.common.command.client.CommandResult<ScenarioSimulationViolation> redo(ScenarioSimulationContext context)
-
-