use of edu.cmu.cs.hcii.cogtool.model.TransitionScriptStep in project cogtool by cogtool.
the class SEDemoController method performTransition.
/**
* Take the transition, and perform the action
*
* @param transition
*/
protected boolean performTransition(SEDemoSelectionState selection, Transition transition, CogToolLID lid) {
AScriptStep stepToReplace = getDemoStep(selection);
if (stepToReplace != null) {
Frame currentFrame = stepToReplace.getCurrentFrame();
if (transition.getDestination() == currentFrame) {
return insertStep(new TransitionScriptStep(transition), stepToReplace, lid, PERFORM_TRANSITION);
}
if (!interaction.confirmDestructiveInsert()) {
return false;
}
}
AScriptStep newDemoStep = new TransitionScriptStep(transition);
TransitionSource source = transition.getSource();
if (source.getFrame() == transition.getDestination() && (source instanceof IWidget)) {
toggleIfGermane((IWidget) source, newDemoStep, transition.getAction());
}
Set<AScriptStep> newDemoSteps = Collections.singleton(newDemoStep);
Set<AScriptStep> oldDemoSteps = new LinkedHashSet<AScriptStep>();
Demonstration demo = script.getDemonstration();
final int atIndex = demo.replaceSteps(stepToReplace, newDemoSteps, oldDemoSteps);
final Collection<ComputationUndoRedo> scriptsUndoRedos = DemoScriptCmd.regenerateScripts(demo, atIndex, stepToReplace, interaction);
IUndoableEdit edit = new DemoStateManager.ADemoUndoableEdit(lid, demo, newDemoSteps, oldDemoSteps, demoStateMgr) {
@Override
public String getPresentationName() {
return PERFORM_TRANSITION;
}
@Override
public void redo() {
super.redo();
demo.replaceSteps(atIndex, redoDemoSteps);
DemoScriptCmd.redoAllChanges(scriptsUndoRedos);
}
@Override
public void undo() {
super.undo();
demo.replaceSteps(atIndex, undoDemoSteps);
DemoScriptCmd.undoAllChanges(scriptsUndoRedos);
}
};
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(PERFORM_TRANSITION, lid);
editSequence.addEdit(edit);
if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
DemoScriptCmd.regenerateScripts(project, demo, demoStateMgr, interaction, editSequence);
}
editSequence.end();
undoMgr.addEdit(editSequence);
return true;
}
Aggregations