use of edu.cmu.cs.hcii.cogtool.model.TransitionSource in project cogtool by cogtool.
the class DesignEditorTransition method dispose.
public void dispose() {
TransitionSource source = transition.getSource();
source.removeAllHandlers(this);
source.getFrame().removeAllHandlers(this);
transition.getDestination().removeAllHandlers(this);
transition.removeAllHandlers(this);
if (sourceHandle != null) {
sourceHandle.dispose();
targetHandle.dispose();
}
}
use of edu.cmu.cs.hcii.cogtool.model.TransitionSource in project cogtool by cogtool.
the class AbstractGraphicalSource method dispose.
/**
* Release resources held by the graphical source
*/
public void dispose() {
TransitionSource source = getModel();
Iterator<Transition> modelTransitions = source.getTransitions().values().iterator();
while (modelTransitions.hasNext()) {
Transition t = modelTransitions.next();
t.removeAllHandlers(this);
t.getDestination().removeAllHandlers(this);
}
source.removeAllHandlers(this);
}
use of edu.cmu.cs.hcii.cogtool.model.TransitionSource in project cogtool by cogtool.
the class AbstractGraphicalSource method setSourceModel.
// Must be called by subclass constructor
protected void setSourceModel(T m) {
if (m == null) {
throw new IllegalArgumentException("Cannot set the model of a graphical source to null");
}
TransitionSource oldModel = getModel();
if (oldModel != m) {
if (oldModel != null) {
oldModel.removeAllHandlers(this);
}
setModel(m);
buildToolTip();
getModel().addHandler(this, Widget.WidgetChange.class, this.changeHandler);
getModel().addHandler(this, TransitionSource.TransitionChange.class, this.transitionChangeHandler);
Iterator<Transition> modelTransitions = getModel().getTransitions().values().iterator();
while (modelTransitions.hasNext()) {
Transition t = modelTransitions.next();
t.addHandler(this, Transition.ActionChange.class, this.changeHandler);
t.addHandler(this, Transition.DestinationChange.class, this.changeHandler);
t.getDestination().addHandler(this, NameChangeAlert.class, this.changeHandler);
}
// Inherit attributes from model
updateAttributes();
}
}
use of edu.cmu.cs.hcii.cogtool.model.TransitionSource in project cogtool by cogtool.
the class SEDemoController method performEditSelfTransition.
// performChangeDelay
protected boolean performEditSelfTransition(ActionScriptStep step) {
TransitionSource source = step.getStepFocus();
AAction action = step.getAction();
Design design = source.getFrame().getDesign();
int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
int limitMode = ActionProperties.determineChangeActionMode(source);
properties.updateProperties(step, action, source);
if (!interaction.determineNewAction(properties, deviceTypes, limitMode, EDIT_SELF_TRANSITION)) {
return false;
}
action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
if (action == null) {
return false;
}
action = EditActionCmd.ensureActionIsUnique(source, action, properties, deviceTypes, limitMode, null, interaction);
if (action == null) {
return false;
}
return changeSelfTransition(step, action, properties.delayInSecs, properties.delayLabel);
}
use of edu.cmu.cs.hcii.cogtool.model.TransitionSource 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