Search in sources :

Example 1 with GraffitiAction

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

Example 2 with GraffitiAction

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

the class DesignEditorUI method updateView.

protected void updateView(boolean deselectAll) {
    if (view.isDisposed()) {
        return;
    }
    ActionPropertySet actionProps = view.getActionPropertySet();
    int selectedTransitionCount = selection.getSelectedTransitionCount();
    int selectedFrameCount = selection.getSelectedFrameCount();
    if (deselectAll || (selectedFrameCount + selectedTransitionCount == 0)) {
        actionProps.useParameters(ActionSet.USE_NONE);
    } else if (selectedTransitionCount == 1) {
        Transition transition = selection.getSelectedTransitions()[0];
        AAction action = transition.getAction();
        DeviceType type = action.getDefaultDeviceType();
        int device = ActionSet.USE_NONE;
        if (action instanceof GraffitiAction) {
            device = ActionSet.USE_GRAFFITI_WIDGET;
        } else if (type == DeviceType.Mouse) {
            device = ActionSet.USE_MOUSE;
        } else if (type == DeviceType.Touchscreen) {
            device = ActionSet.USE_TOUCHSCREEN;
        } else if (type == DeviceType.Keyboard) {
            device = ActionSet.USE_KEYBOARD;
        } else if (type == DeviceType.Voice) {
            device = ActionSet.USE_VOICE;
        } else if (type == null) {
            // Generally, a hover action; pick whichever is active
            if (actionProps.isMouseSelected()) {
                device = ActionSet.USE_MOUSE;
            } else if (actionProps.isTouchSelected()) {
                device = ActionSet.USE_TOUCHSCREEN;
            }
        }
        actionProps.setComposite(device);
        ActionProperties properties = view.getActionProperties();
        view.getDefaultProperties(properties);
        properties.updateProperties(transition, transition.getAction(), transition.getSource());
        int limitMode = ActionProperties.determineChangeActionMode(transition.getSource());
        actionProps.setLimitMode(limitMode, properties.useWhichParts);
        actionProps.setProperties(properties, properties.useWhichParts);
    } else if (selectedTransitionCount > 1) {
        actionProps.useParameters(ActionPropertySet.MULT_TRANS);
    }
    if (selectedFrameCount == 1) {
        actionProps.updateFrameComposite(selection.getSelectedFrames()[0]);
    } else if ((selectedFrameCount == 0) && (selectedTransitionCount == 0)) {
        actionProps.updateEmptyComposite(design, false);
    }
}
Also used : ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) GraffitiAction(edu.cmu.cs.hcii.cogtool.model.GraffitiAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) Point(org.eclipse.draw2d.geometry.Point) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Aggregations

AAction (edu.cmu.cs.hcii.cogtool.model.AAction)2 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)2 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)2 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)2 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)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 VoiceAction (edu.cmu.cs.hcii.cogtool.model.VoiceAction)1 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)1 ActionPropertySet (edu.cmu.cs.hcii.cogtool.view.ActionPropertySet)1 Point (org.eclipse.draw2d.geometry.Point)1