use of edu.cmu.cs.hcii.cogtool.model.HandLocation in project cogtool by cogtool.
the class SEDemoController method setMouseHandAction.
// resetComputations
protected void setMouseHandAction(final boolean mouseHand) {
final Demonstration demo = script.getDemonstration();
final boolean oldMouseHand = demo.getMouseHand();
final DefaultModelGeneratorState initialState = demo.getInitialState();
final HandLocation mouseHandLoc = initialState.getHandLocation(oldMouseHand);
final DemoStateManager.IConformanceUndoRedo conformanceUndoRedo = demoStateMgr.restoreConformance(demo);
demo.setMouseHand(mouseHand);
initialState.setHandLocation(mouseHand, mouseHandLoc);
initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
final Collection<ComputationUndoRedo> scriptsUndoRedos = DemoScriptCmd.regenerateScripts(demo, 0, demo.getStepAt(0), interaction);
IUndoableEdit edit = new AUndoableEdit(SEDemoLID.SetMouseHand) {
@Override
public String getPresentationName() {
return SET_MOUSE_HAND;
}
@Override
public void redo() {
super.redo();
conformanceUndoRedo.redo();
initialState.setHandLocation(mouseHand, mouseHandLoc);
initialState.setHandLocation(!mouseHand, HandLocation.OnKeyboard);
// Do this last as it will alert
demo.setMouseHand(mouseHand);
DemoScriptCmd.redoAllChanges(scriptsUndoRedos);
}
@Override
public void undo() {
super.undo();
conformanceUndoRedo.undo();
initialState.setHandLocation(oldMouseHand, mouseHandLoc);
initialState.setHandLocation(!oldMouseHand, HandLocation.OnKeyboard);
// Do this last as it will alert
demo.setMouseHand(oldMouseHand);
DemoScriptCmd.undoAllChanges(scriptsUndoRedos);
}
};
undoMgr.addEdit(edit);
}
Aggregations