Search in sources :

Example 1 with Transition

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

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

the class SEDemoUI method populateContextMenu.

protected void populateContextMenu(TransitionSource source, List<MenuItemDefinition> menuItems) {
    Collection<Transition> values = source.getTransitions().values();
    Iterator<Transition> iter = values.iterator();
    SEDemoTransitionLID itemLID;
    while (iter.hasNext()) {
        Transition trans = iter.next();
        SEDemoUI.DemoTransition ftrans = new SEDemoUI.FollowTransition(selection, trans);
        // Add the ftrans to the list in the context menus
        itemLID = new SEDemoTransitionLID("PerformDemoTransition", ftrans);
        String transitionStr = KeyDisplayUtil.convertActionToMenuText(ftrans.getLocalizedString());
        MenuItemDefinition mItem = new SimpleMenuItemDefinition(transitionStr, itemLID, MenuUtil.ENABLED);
        menuItems.add(mItem);
    }
    // Check to see if any transitions are actually available.
    if (values.size() == 0) {
        MenuItemDefinition mItem = new SimpleMenuItemDefinition(L10N.get("SE.DemoNoPredefinedTransitions", "No defined transitions for ") + source.getName(), null);
        // Add a default disabled message
        menuItems.add(mItem);
    }
    boolean selfTransitionOK = true;
    // Add a default look-at transition for all regions except Devices
    if (source.getTransitionSourceType() == TransitionSourceType.Widget) {
        IWidget widget = (IWidget) source;
        Object isSep = widget.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
        if ((NullSafe.equals(WidgetAttributes.IS_SEPARATOR, isSep)) || (widget.getWidgetType() == WidgetType.Noninteractive) || ((widget instanceof MenuHeader) || (widget instanceof PullDownHeader) || (widget instanceof ContextMenu))) {
            selfTransitionOK = false;
        }
        // Add standard menus to the list of items
        menuItems.add(MenuUtil.SEPARATOR);
        SEDemoUI.DemoTransition lookAtTrans = new SEDemoUI.LookAtTransition(selection, widget);
        // Add default transition options.
        String itemLabel = L10N.get("SE.DemoLookAt", "Look at") + " " + widget.getName();
        itemLID = new SEDemoTransitionLID("PerformDemoLookAtTransition", lookAtTrans);
        menuItems.add(new SimpleMenuItemDefinition(itemLabel, itemLID, MenuUtil.ENABLED));
    }
    if (selfTransitionOK) {
        menuItems.add(MenuUtil.SEPARATOR);
        itemLID = new SEDemoTransitionLID("PerformSelfTransition", new SEDemoUI.SelfTransition(selection, source, null));
        MenuItemDefinition mItem = new SimpleMenuItemDefinition(L10N.get("SE.SelfTransition", "Perform Self-transition"), itemLID, MenuUtil.ENABLED);
        menuItems.add(mItem);
    }
}
Also used : MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) SimpleMenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition) ContextMenu(edu.cmu.cs.hcii.cogtool.model.ContextMenu) PullDownHeader(edu.cmu.cs.hcii.cogtool.model.PullDownHeader) SimpleMenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition) MenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.MenuItemDefinition) SEDemoTransitionLID(edu.cmu.cs.hcii.cogtool.ui.SEDemoLID.SEDemoTransitionLID) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) EventObject(java.util.EventObject) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 3 with Transition

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

the class StructureViewUIModel method installSourceTransitions.

/**
     * Create the visible representations for all of the transitions
     * emanating from a specific source.
     * <p>
     * The figures for the source object and destination frames
     * must be created/installed before attempting to create/install
     * the visible representations for transitions.
     *
     * @param srcFrameFigure the figure for the frame containing the widget
     * @param widget         the source widget whose transitions to install
     * @author mlh
     */
protected void installSourceTransitions(DesignEditorFrame srcFrameFigure, TransitionSource source) {
    // Find the figure for the source widget
    GraphicalSource<?> sourceFigure = srcFrameFigure.getSourceFigure(source);
    Iterator<Transition> transitions = source.getTransitions().values().iterator();
    while (transitions.hasNext()) {
        Transition transition = transitions.next();
        installSourceTransition(transition, sourceFigure);
    }
}
Also used : Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

Example 4 with Transition

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

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

Transition (edu.cmu.cs.hcii.cogtool.model.Transition)33 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)13 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)11 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)7 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)7 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)6 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)5 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)5 MousePressType (edu.cmu.cs.hcii.cogtool.model.MousePressType)4 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)4 DesignEditorTransition (edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)4 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)4 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)3 MouseButtonState (edu.cmu.cs.hcii.cogtool.model.MouseButtonState)3 TapPressType (edu.cmu.cs.hcii.cogtool.model.TapPressType)3 DesignEditorUI (edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI)3 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)3 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)2 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)2 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)2