Search in sources :

Example 1 with TextAction

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

the class SEDemoController method performSelfTransition.

protected boolean performSelfTransition(SEDemoSelectionState selection, TransitionSource source, AAction action, double delayInSecs, String delayLabel) {
    AScriptStep beforeStep = getDemoStep(selection);
    ActionScriptStep selfTransitionStep = new ActionScriptStep(action, source);
    selfTransitionStep.setDelay(delayInSecs, delayLabel);
    if (source instanceof IWidget) {
        IWidget widget = (IWidget) source;
        ActionType actionType = action.getType();
        WidgetType widgetType = widget.getWidgetType();
        if (toggleIfGermane(widget, selfTransitionStep, action)) {
        // Do nothing further
        } else if ((actionType == ActionType.KeyPress) || (actionType == ActionType.GraffitiStroke)) {
            TextAction text = (TextAction) action;
            if (widgetType == WidgetType.TextBox) {
                selfTransitionStep.overrideAttribute(widget, WidgetAttributes.APPENDED_TEXT_ATTR, text.getText());
            }
        }
    }
    return insertStep(selfTransitionStep, beforeStep, SEDemoLID.InsertSelfTransition, INSERT_SELF_TRANSITION);
}
Also used : ActionScriptStep(edu.cmu.cs.hcii.cogtool.model.ActionScriptStep) ActionType(edu.cmu.cs.hcii.cogtool.model.ActionType) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) AScriptStep(edu.cmu.cs.hcii.cogtool.model.AScriptStep) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) TextAction(edu.cmu.cs.hcii.cogtool.model.TextAction)

Example 2 with TextAction

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

the class DesignExportToHTML method buildKeyTransitionMap.

/**
	 * Outputs a Javascript function that makes a map from the transition
	 * string to the name of the destination frame
	 * (treats Graffiti transitions as keyboard transitions)
	 */
protected String buildKeyTransitionMap(Collection<InputDevice> devices, Collection<IWidget> widgets) {
    StringBuilder html = new StringBuilder();
    Iterator<InputDevice> deviceIterator = devices.iterator();
    while (deviceIterator.hasNext()) {
        InputDevice device = deviceIterator.next();
        if (DeviceType.Keyboard.equals(device.getDeviceType()) || DeviceType.Touchscreen.equals(device.getDeviceType())) {
            // first save all transitions from the device
            Iterator<Transition> transitions = device.getTransitions().values().iterator();
            while (transitions.hasNext()) {
                Transition transition = transitions.next();
                AAction action = transition.getAction();
                if (action instanceof TextAction) {
                    String text = cleanup(((TextAction) action).getText());
                    html.append("keyTransitionMap[\"" + text + "\"]");
                    html.append(" = \'");
                    html.append(getFrameURL(transition.getDestination(), ".html"));
                    html.append("\';\n");
                }
            }
        }
    }
    Iterator<IWidget> widgetIterator = widgets.iterator();
    // NOTE: does not work with list box items or any menus
    while (widgetIterator.hasNext()) {
        IWidget w = widgetIterator.next();
        String name = "\"" + w.getName() + "\"";
        Iterator<Transition> wTransitions = w.getTransitions().values().iterator();
        boolean foundKeyTransition = false;
        while (wTransitions.hasNext()) {
            Transition transition = wTransitions.next();
            AAction action = transition.getAction();
            if (action instanceof TextAction) {
                if (!foundKeyTransition) {
                    foundKeyTransition = true;
                    html.append("focusTransitionMaps[" + name + "] = new Object();\n");
                }
                String key = "\"" + cleanup(((TextAction) action).getText()) + "\"";
                String dest = "'" + getFrameURL(transition.getDestination(), ".html") + "'";
                html.append("focusTransitionMaps[" + name + "][");
                html.append(key + "] = " + dest + ";\n");
            }
        }
    }
    return html.toString();
}
Also used : InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) TextAction(edu.cmu.cs.hcii.cogtool.model.TextAction) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)2 TextAction (edu.cmu.cs.hcii.cogtool.model.TextAction)2 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)1 AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)1 ActionScriptStep (edu.cmu.cs.hcii.cogtool.model.ActionScriptStep)1 ActionType (edu.cmu.cs.hcii.cogtool.model.ActionType)1 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)1