Search in sources :

Example 6 with InputDevice

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

Example 7 with InputDevice

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

the class DesignEditorFrame method addTransitionChangeHandler.

public void addTransitionChangeHandler(AlertHandler handler) {
    Iterator<IWidget> sources = frame.getWidgets().iterator();
    while (sources.hasNext()) {
        IWidget widget = sources.next();
        widget.addHandler(this, TransitionSource.TransitionChange.class, handler);
    }
    Iterator<InputDevice> devices = frame.getInputDevices().iterator();
    while (devices.hasNext()) {
        InputDevice device = devices.next();
        device.addHandler(this, TransitionSource.TransitionChange.class, handler);
    }
    transitionChangeHandler = handler;
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 8 with InputDevice

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

the class DesignEditorFrame method dispose.

public void dispose() {
    frameUIModel.removeAllHandlers(this);
    frameUIModel.dispose();
    Iterator<IWidget> sources = frame.getWidgets().iterator();
    while (sources.hasNext()) {
        IWidget widget = sources.next();
        widget.removeAllHandlers(this);
    }
    Iterator<InputDevice> devices = frame.getInputDevices().iterator();
    while (devices.hasNext()) {
        InputDevice device = devices.next();
        device.removeAllHandlers(this);
    }
    frame.removeAllHandlers(this);
    // Need to dispose all InputSources that were created by this class
    Iterator<GraphicalDevice> iter = inputDevices.values().iterator();
    while (iter.hasNext()) {
        GraphicalDevice d = iter.next();
        d.dispose();
    }
}
Also used : InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 9 with InputDevice

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

the class ActionProperties method setInitialActionType.

/**
     * Base initial action type on given source
     */
public void setInitialActionType(TransitionSource source, Set<DeviceType> deviceTypes) {
    if (source instanceof InputDevice) {
        InputDevice device = (InputDevice) source;
        DeviceType devType = device.getDeviceType();
        if (devType == DeviceType.Keyboard) {
            useWhichParts = USE_KEYBOARD;
        } else if (devType == DeviceType.Mouse) {
            useWhichParts = USE_MOUSE;
        } else if (devType == DeviceType.Touchscreen) {
            useWhichParts = USE_TOUCHSCREEN;
        } else if (devType == DeviceType.Voice) {
            useWhichParts = USE_VOICE;
        }
    } else if (source instanceof IWidget) {
        IWidget widget = (IWidget) source;
        WidgetType widgetType = widget.getWidgetType();
        if (widgetType == WidgetType.Graffiti) {
            useWhichParts = USE_GRAFFITI_WIDGET;
        } else if (widgetType == WidgetType.TextBox) {
            useWhichParts = USE_KEYBOARD;
        } else {
            setInitialActionType(source, BASE_ACTION_ON_SOURCE, deviceTypes);
        }
    }
}
Also used : DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)9 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)7 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)5 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)3 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)2 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)2 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)1 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)1 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)1 KeyAction (edu.cmu.cs.hcii.cogtool.model.KeyAction)1 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)1 TextAction (edu.cmu.cs.hcii.cogtool.model.TextAction)1 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)1 VoiceAction (edu.cmu.cs.hcii.cogtool.model.VoiceAction)1 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)1 AListenerAction (edu.cmu.cs.hcii.cogtool.util.AListenerAction)1 ClipboardUtil (edu.cmu.cs.hcii.cogtool.util.ClipboardUtil)1 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)1 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)1 RcvrClipboardException (edu.cmu.cs.hcii.cogtool.util.RcvrClipboardException)1