Search in sources :

Example 26 with Transition

use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.

the class DesignEditorController method createNewTransition.

// Return null to indicate cancel
protected IUndoableEdit createNewTransition(final TransitionSource source, Frame target) {
    int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
    // Helps control which options are available for editing the action
    int limitMode = ActionProperties.determineChangeActionMode(source);
    AAction action = createDefaultAction(source);
    if (action == null) {
        if (!interaction.determineNewAction(properties, deviceTypes, limitMode, L10N.get("DE.SetActionType", "Set Action Type"))) {
            // Indicate that the user canceled
            return null;
        }
        action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
        if (action == null) {
            return null;
        }
    }
    // action is not null at this point; no transition yet for this action!
    action = EditActionCmd.ensureActionIsUnique(source, action, properties, deviceTypes, limitMode, null, interaction);
    if (action == null) {
        return null;
    }
    Transition newTransition = new Transition(source, target, action);
    newTransition.setDelayInfo(properties.delayInSecs, properties.delayLabel);
    IUndoableEdit edit = DesignEditorCmd.addTransition(demoStateMgr, newTransition);
    interaction.setTransitionStatusMessage(newTransition);
    return edit;
}
Also used : Transition(edu.cmu.cs.hcii.cogtool.model.Transition) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Example 27 with Transition

use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.

the class BalsamiqButtonAPIConverter method parseTransition.

/** Helper function used by parseWidget
	 * This method is used to parse the href tag that is a link from a widget
	 * to another frame
     * 
     * @param  destinationFrameName the name of the frame that the transition 
     *                               is going to
     * @param  widget               the widget that the transition starts from
     */
protected void parseTransition(String destFrameFileName, Widget widget) {
    String frameName = (destFrameFileName.lastIndexOf(".") == -1) ? destFrameFileName : destFrameFileName.substring(0, destFrameFileName.lastIndexOf('.'));
    /* getFrame() returns the frame for the specified string. If the string is null then
		a null frame is returned. */
    Frame destinationFrame = (frameName != null) ? getFrame(frameName) : null;
    if (destinationFrame != null) {
        //Default Mouse Click Transition
        //TODO: MAKE SURE THE MOUSE IS A DEVICE. check which devices are allowed and then make an action from there
        AAction action = new ButtonAction(MouseButtonState.Left, MousePressType.Click, AAction.NONE);
        //Create the transition and add it to the widget
        Transition t = new Transition(widget, destinationFrame, action);
        if (t != null) {
            widget.addTransition(t);
        }
    }
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Example 28 with Transition

use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.

the class DesignEditorController method createChangeDelayAction.

protected IListenerAction createChangeDelayAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return DesignEditorUI.ChangeDelayParameters.class;
        }

        public boolean performAction(Object actionParms) {
            DesignEditorUI.ChangeDelayParameters prm = (DesignEditorUI.ChangeDelayParameters) actionParms;
            int numTransitions = prm.selection.getSelectedTransitionCount();
            if (numTransitions == 0) {
                interaction.protestNoSelection();
                return false;
            }
            if (numTransitions > 1) {
                interaction.protestMultipleTransitionSelection();
                return false;
            }
            final Transition transition = prm.selection.getSelectedTransitions()[0];
            final double oldDelayInSecs = transition.getDelayInSecs();
            final String oldDelayLabel = transition.getDelayLabel();
            if ((oldDelayInSecs != prm.delayInSecs) || !oldDelayLabel.equals(prm.delayLabel)) {
                final double newDelayInSecs = prm.delayInSecs;
                final String newDelayLabel = prm.delayLabel;
                transition.setDelayInfo(newDelayInSecs, newDelayLabel);
                DemoStateManager.IDesignUndoableEdit edit = new DemoStateManager.ObsoletingEdit(DesignEditorLID.ChangeDelay, demoStateMgr) {

                    @Override
                    public String getPresentationName() {
                        return changeDelay;
                    }

                    @Override
                    public void redo() {
                        super.redo();
                        transition.setDelayInfo(newDelayInSecs, newDelayLabel);
                        stateMgr.noteTransitionEdit(transition, this);
                        if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
                            DemoScriptCmd.regenerateDesignScripts(project, design, interaction);
                        }
                    }

                    @Override
                    public void undo() {
                        super.undo();
                        transition.setDelayInfo(oldDelayInSecs, oldDelayLabel);
                        stateMgr.noteTransitionEdit(transition, this);
                        if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
                            DemoScriptCmd.regenerateDesignScripts(project, design, interaction);
                        }
                    }
                };
                demoStateMgr.noteTransitionEdit(transition, edit);
                undoMgr.addEdit(edit);
                if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
                    DemoScriptCmd.regenerateDesignScripts(project, design, interaction);
                }
            }
            return true;
        }
    };
}
Also used : DesignEditorUI(edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 29 with Transition

use of edu.cmu.cs.hcii.cogtool.model.Transition in project cogtool by cogtool.

the class DesignEditorController method createDeleteTransitionAction.

// deleteFrames
protected IListenerAction createDeleteTransitionAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return DesignEditorSelectionState.class;
        }

        public boolean performAction(Object prms) {
            DesignEditorSelectionState selection = (DesignEditorSelectionState) prms;
            Transition[] transitions = selection.getSelectedTransitions();
            if ((transitions != null) && (transitions.length > 0)) {
                if (interaction.confirmDeleteTransitions(transitions)) {
                    deleteTransitions(transitions);
                    return true;
                }
            } else {
                interaction.protestNoSelection();
            }
            return false;
        }
    };
}
Also used : IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) DesignEditorSelectionState(edu.cmu.cs.hcii.cogtool.ui.DesignEditorSelectionState) Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

Example 30 with Transition

use of edu.cmu.cs.hcii.cogtool.model.Transition 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)

Aggregations

Transition (edu.cmu.cs.hcii.cogtool.model.Transition)33 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)13 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)11 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)7 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)7 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)6 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)5 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)5 MousePressType (edu.cmu.cs.hcii.cogtool.model.MousePressType)4 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)4 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)4 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)4 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)3 MouseButtonState (edu.cmu.cs.hcii.cogtool.model.MouseButtonState)3 TapPressType (edu.cmu.cs.hcii.cogtool.model.TapPressType)3 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)3 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)3 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)2 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)2 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)2