Search in sources :

Example 11 with TransitionSource

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();
    }
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource)

Example 12 with TransitionSource

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);
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

Example 13 with TransitionSource

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();
    }
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) Widget(edu.cmu.cs.hcii.cogtool.model.Widget) Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

Example 14 with TransitionSource

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);
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) Design(edu.cmu.cs.hcii.cogtool.model.Design) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Example 15 with TransitionSource

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;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Frame(edu.cmu.cs.hcii.cogtool.model.Frame) TransitionScriptStep(edu.cmu.cs.hcii.cogtool.model.TransitionScriptStep) ComputationUndoRedo(edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) AScriptStep(edu.cmu.cs.hcii.cogtool.model.AScriptStep) TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)16 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)7 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)5 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)4 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)4 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)4 AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)2 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)2 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)2 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)2 LinkedHashSet (java.util.LinkedHashSet)2 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)1 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)1 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)1 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)1 LookAtScriptStep (edu.cmu.cs.hcii.cogtool.model.LookAtScriptStep)1 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)1 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)1 TextActionSegment (edu.cmu.cs.hcii.cogtool.model.TextActionSegment)1