Search in sources :

Example 1 with AAction

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

the class SEDemoController method changeSelfTransition.

protected boolean changeSelfTransition(final ActionScriptStep step, final AAction newAction, final double delayInSecs, final String delayLabel) {
    final AAction oldAction = step.getAction();
    final double oldDelayInSecs = step.getDelayInSecs();
    final String oldDelayLabel = step.getDelayLabel();
    if ((!oldAction.equals(newAction)) || (delayInSecs != oldDelayInSecs) || !oldDelayLabel.equals(delayLabel)) {
        step.setAction(newAction);
        step.setDelay(delayInSecs, delayLabel);
        Demonstration demo = script.getDemonstration();
        final int atIndex = demo.getStepIndex(step);
        final Collection<ComputationUndoRedo> scriptsUndoRedos = DemoScriptCmd.regenerateScripts(demo, atIndex, step, interaction);
        IUndoableEdit edit = new AUndoableEdit(SEDemoLID.Edit) {

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

            @Override
            public void redo() {
                super.redo();
                step.setAction(newAction);
                step.setDelay(delayInSecs, delayLabel);
                DemoScriptCmd.redoAllChanges(scriptsUndoRedos);
            }

            @Override
            public void undo() {
                super.undo();
                step.setAction(oldAction);
                step.setDelay(oldDelayInSecs, oldDelayLabel);
                DemoScriptCmd.undoAllChanges(scriptsUndoRedos);
            }
        };
        CompoundUndoableEdit editSequence = new CompoundUndoableEdit(EDIT_SELF_TRANSITION, SEDemoLID.Edit);
        editSequence.addEdit(edit);
        if (CogToolPref.REGENERATE_AUTOMATICALLY.getBoolean()) {
            DemoScriptCmd.regenerateScripts(project, demo, demoStateMgr, interaction, editSequence);
        }
        editSequence.end();
        undoMgr.addEdit(editSequence);
    }
    return true;
}
Also used : ComputationUndoRedo(edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo) AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Example 2 with AAction

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

the class SEDemoMouseState method doTransitionAction.

protected boolean doTransitionAction(TransitionSource source, int button, int state, int clickState) {
    AAction action = null;
    Set<DeviceType> deviceTypes = ui.design.getDeviceTypes();
    if (deviceTypes.contains(DeviceType.Mouse)) {
        MousePressType pt = null;
        switch(clickState) {
            case UP:
                pt = MousePressType.Up;
                break;
            case DOWN:
                pt = MousePressType.Down;
                break;
            case CLICK:
                pt = MousePressType.Click;
                break;
            case DOUBLE:
                pt = MousePressType.Double;
                break;
            case TRIPLE:
                pt = MousePressType.Triple;
                break;
            default:
                throw new IllegalArgumentException("Invalid click state received");
        }
        action = new ButtonAction(getActionButtonButton(button), pt, getActionButtonModifier(state));
    } else if (deviceTypes.contains(DeviceType.Touchscreen)) {
        TapPressType tt = null;
        switch(clickState) {
            case UP:
                tt = TapPressType.Up;
                break;
            case DOWN:
                tt = TapPressType.Down;
                break;
            case CLICK:
                tt = TapPressType.Tap;
                break;
            case DOUBLE:
                tt = TapPressType.DoubleTap;
                break;
            case TRIPLE:
                tt = TapPressType.TripleTap;
                break;
            default:
                throw new IllegalArgumentException("Invalid ClickState received");
        }
        action = new TapAction(tt);
    }
    if (clickState == CLICK) {
        if (source.getTransition(action) == null) {
            // Check to see if a doubleclick/doubletap is in the set of
            // transitions
            Iterator<AAction> iter = source.getTransitions().keySet().iterator();
            while (iter.hasNext()) {
                AAction act = iter.next();
                if ((act.getType() == ActionType.ButtonPress) && deviceTypes.contains(DeviceType.Mouse)) {
                } else if ((act.getType() == ActionType.Tap) && deviceTypes.contains(DeviceType.Touchscreen)) {
                }
            }
            if ((source instanceof IWidget) && ((IWidget) source).isStandard() && deviceTypes.contains(DeviceType.Mouse)) {
                WidgetType type = ((IWidget) source).getWidgetType();
                Object toggle = source.getAttribute(WidgetAttributes.IS_TOGGLEABLE_ATTR);
                Object isSep = source.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
                if ((type == WidgetType.Check) || (type == WidgetType.Radio) || ((type == WidgetType.PullDownItem) && NullSafe.equals(WidgetAttributes.NON_SEPARATOR, isSep)) || ((type == WidgetType.Button) && NullSafe.equals(WidgetAttributes.IS_TOGGLEABLE, toggle))) {
                    if (type == WidgetType.PullDownItem) {
                        ui.hideAllChildren();
                    }
                    AAction a = new ButtonAction(MouseButtonState.Left, MousePressType.Click, 0);
                    SEDemoUI.SelfTransition prms = new SEDemoUI.SelfTransition(ui.selection, source, a);
                    ui.performAction(SEDemoLID.InsertSelfTransition, prms);
                    return true;
                }
            }
            ui.showContextMenu(source);
        }
    }
    Transition transition = source.getTransition(action);
    if (transition != null) {
        SEDemoUI.FollowTransition prms = new SEDemoUI.FollowTransition(ui.selection, transition);
        ui.performAction(SEDemoLID.PerformTransition, prms);
        return true;
    }
    return false;
}
Also used : ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 3 with AAction

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

the class NewActionChangeDialog method addMoreFields.

@Override
protected void addMoreFields() {
    GridData reqLayout;
    if (complaint != null) {
        reqLayout = new GridData();
        reqLayout.grabExcessHorizontalSpace = true;
        reqLayout.horizontalSpan = 4;
        complaintLabel = new Label(dialog, SWT.NONE);
        complaintLabel.setText(complaint);
        complaintLabel.setLayoutData(reqLayout);
        complaintLabel.setFont(FontUtils.SYMBOL_FONT);
        complaintMode = properties.useWhichParts;
    }
    reqLayout = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    reqLayout.grabExcessHorizontalSpace = true;
    reqLayout.horizontalSpan = 4;
    Composite c = new Composite(dialog, SWT.NONE);
    c.setLayoutData(reqLayout);
    propertySet = new ActionChangePropertySet(deviceTypes, c, this) {

        protected ActionProperties testEnableProps = new ActionProperties(ActionProperties.UNSET);

        @Override
        protected boolean userSelectedMode(int widgetMode) {
            boolean enableOK = super.userSelectedMode(widgetMode);
            if (complaintLabel != null) {
                complaintLabel.setVisible(widgetMode == complaintMode);
            }
            return enableOK;
        }

        @Override
        protected void enableOKButton(boolean enable) {
            // the OK button should be otherwise enabled
            if (enable) {
                if ((transitionSrc != null) && (properties != null)) {
                    propertySet.getProperties(testEnableProps);
                    AAction action = testEnableProps.buildAction();
                    Transition existingTransition = transitionSrc.getTransition(action);
                    if ((action != null) && (existingTransition != null)) {
                        enable = false;
                    }
                }
            }
            super.enableOKButton(enable);
        }
    };
    propertySet.layOutPropertiesPane();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) ActionChangePropertySet(edu.cmu.cs.hcii.cogtool.view.ActionChangePropertySet)

Example 4 with AAction

use of edu.cmu.cs.hcii.cogtool.model.AAction 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 5 with AAction

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

the class DesignExportToHTML method textSelect.

/**
	 * For checkboxes and radio buttons, clicking on the text should cause
	 * the widget to change selection.  The exception to this is when the
	 * widget already has a left-click transition defined that is not a
	 * self-transition, since then it would override the onclick property.
	 * @param widget
	 * @return
	 */
protected boolean textSelect(IWidget widget) {
    Iterator<Transition> transitions = widget.getTransitions().values().iterator();
    boolean leftClick = false;
    while (transitions.hasNext()) {
        Transition transition = transitions.next();
        AAction action = transition.getAction();
        if (action instanceof ButtonAction) {
            ButtonAction bAction = (ButtonAction) action;
            MouseButtonState buttonState = bAction.getButton();
            MousePressType pressType = bAction.getPressType();
            if (MouseButtonState.Left.equals(buttonState) && MousePressType.Click.equals(pressType)) {
                leftClick = true;
                if (transition.getDestination().equals(widget.getFrame())) {
                    return true;
                }
            }
        }
    }
    if (leftClick) {
        return false;
    }
    return true;
}
Also used : Transition(edu.cmu.cs.hcii.cogtool.model.Transition) ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) MouseButtonState(edu.cmu.cs.hcii.cogtool.model.MouseButtonState)

Aggregations

AAction (edu.cmu.cs.hcii.cogtool.model.AAction)18 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)13 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)6 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)5 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)4 MousePressType (edu.cmu.cs.hcii.cogtool.model.MousePressType)4 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)4 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)4 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)3 MouseButtonState (edu.cmu.cs.hcii.cogtool.model.MouseButtonState)3 TapPressType (edu.cmu.cs.hcii.cogtool.model.TapPressType)3 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)3 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)2 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)2 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)2 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)2 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)1 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)1 Design (edu.cmu.cs.hcii.cogtool.model.Design)1 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)1