Search in sources :

Example 1 with VoiceAction

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

the class ActionProperties method updateProperties.

public void updateProperties(TransitionDelay td, AAction action, TransitionSource transitionSource) {
    delayInSecs = td.getDelayInSecs();
    delayLabel = td.getDelayLabel();
    Transition tr = transitionSource.getTransitions().get(action);
    if (tr != null) {
        // null if self-transition
        transitionDestinationLabel = tr.getDestination().getName();
    }
    if (transitionSource instanceof IWidget) {
        // TODO: Must modify this when text fields are added.
        // Text fields may not use "ButtonAction"
        AAction.ActionVisitor widgetActionVisitor = new AAction.ActionVisitor() {

            @Override
            public void visit(ButtonAction but) {
                mouseButton = but.getButton();
                buttonAction = but.getPressType();
                if (buttonAction == MousePressType.Hover) {
                    mouseButton = null;
                }
                buttonState = but.getModifiers();
                useWhichParts = ActionProperties.USE_MOUSE;
            }

            @Override
            public void visit(TapAction tap) {
                tapAction = tap.getTapPressType();
                useWhichParts = ActionProperties.USE_TOUCHSCREEN;
            }

            @Override
            public void visit(KeyAction key) {
                keyboardString = key.getText();
                keyboardIsCmd = key.isCommand();
                keyboardAction = key.getPressType();
                useWhichParts = ActionProperties.USE_KEYBOARD;
            }

            @Override
            public void visit(GraffitiAction graffiti) {
                graffitiString = graffiti.getText();
                graffitiIsCmd = graffiti.isCommand();
                useWhichParts = ActionProperties.USE_GRAFFITI_WIDGET;
            }

            @Override
            public void visit(VoiceAction voice) {
                voiceString = voice.getText();
                voiceIsCmd = voice.isCommand();
                useWhichParts = ActionProperties.USE_VOICE;
            }
        };
        action.accept(widgetActionVisitor);
        String t = ((IWidget) transitionSource).getTitle();
        if (t.length() > 0) {
            transitionSourceLabel = t + " in " + ((IWidget) transitionSource).getFrame().getName();
        } else {
            transitionSourceLabel = ((IWidget) transitionSource).getName() + " in " + ((IWidget) transitionSource).getFrame().getName();
        }
    } else {
        InputDevice deviceSource = (InputDevice) transitionSource;
        DeviceType type = deviceSource.getDeviceType();
        if (type == DeviceType.Voice) {
            VoiceAction voiceAction = (VoiceAction) action;
            voiceString = voiceAction.getText();
            voiceIsCmd = voiceAction.isCommand();
            useWhichParts = ActionProperties.USE_VOICE;
        } else {
            KeyAction keyAction = (KeyAction) action;
            keyboardString = keyAction.getText();
            keyboardAction = keyAction.getPressType();
            keyboardIsCmd = keyAction.isCommand();
            useWhichParts = ActionProperties.USE_KEYBOARD;
        }
        transitionSourceLabel = "";
    }
}
Also used : InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) VoiceAction(edu.cmu.cs.hcii.cogtool.model.VoiceAction) GraffitiAction(edu.cmu.cs.hcii.cogtool.model.GraffitiAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) KeyAction(edu.cmu.cs.hcii.cogtool.model.KeyAction) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Aggregations

AAction (edu.cmu.cs.hcii.cogtool.model.AAction)1 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)1 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)1 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)1 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)1 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)1 KeyAction (edu.cmu.cs.hcii.cogtool.model.KeyAction)1 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 VoiceAction (edu.cmu.cs.hcii.cogtool.model.VoiceAction)1