Search in sources :

Example 11 with AAction

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

Example 12 with AAction

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

the class DesignExportToHTML method parseTransitions.

/**
	 * Given the transitions from a widget, parse them and return 3 strings:
	 * first, the name of the destination frame of its hover transition;
	 * second, the map that defines its single click transitions;
	 * third, the map that defines its double click transitions.
	 * (See comments on the javascript functions for how these maps are used.)
	 */
protected String[] parseTransitions(IWidget w, boolean checkFocus, int ignoreButton) {
    String[] result = new String[2];
    result[0] = "null";
    result[1] = "[";
    // TODO: onmouseup doesn't work for middle clicks...except
    // sometimes it does, may be related to focus?
    // Always use onmouseup instead of onclick because we need to check
    // for double click here too
    Iterator<Transition> transitions = w.getTransitions().values().iterator();
    // If we are told to ignore transitions from a certain button, check
    // if the widget has any transitions defined from that button.  If not,
    // tell the javascript explicitly not to pop up the "does not help..."
    // message if that button is clicked with the IGNORE_LEFT_CLICK string
    // flag.
    boolean hasIgnoredButtonTransition = 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();
            int button = -1;
            String destName = getFrameURL(transition.getDestination(), ".html");
            int modifiers = bAction.getModifiers();
            int numClicks = 0;
            if (MousePressType.Hover.equals(pressType)) {
                result[0] = "'" + destName + "'";
            } else {
                if (MouseButtonState.Left.equals(buttonState)) {
                    button = LEFT_MOUSE;
                    if (checkFocus) {
                        destName += buildFocusSearch(w, transition.getDestination());
                    }
                } else if (MouseButtonState.Middle.equals(buttonState)) {
                    button = MIDDLE_MOUSE;
                } else if (MouseButtonState.Right.equals(buttonState)) {
                    button = RIGHT_MOUSE;
                }
                if (MousePressType.Up.equals(pressType) || MousePressType.Click.equals(pressType)) {
                    numClicks = 1;
                    if ((button == ignoreButton) && (modifiers == AAction.NONE)) {
                        hasIgnoredButtonTransition = true;
                    }
                } else if (MousePressType.Double.equals(pressType)) {
                    numClicks = 2;
                } else if (MousePressType.Triple.equals(pressType)) {
                    numClicks = 3;
                }
                if (result[1].length() > 1) {
                    result[1] += ", ";
                }
                result[1] += "[" + button + ", " + numClicks + ", " + modifiers + ", '" + destName + "']";
            }
        } else if (action instanceof TapAction) {
            TapAction bAction = (TapAction) action;
            TapPressType pressType = bAction.getTapPressType();
            String destName = getFrameURL(transition.getDestination(), ".html");
            int numClicks = 0;
            if (TapPressType.Hover.equals(pressType)) {
                result[0] = "'" + destName + "'";
            } else {
                if (TapPressType.Up.equals(pressType) || TapPressType.Tap.equals(pressType)) {
                    // TODO: Behavior is undefined if both a left-click and
                    // tap transition are created from the same widget!
                    numClicks = 1;
                    if (ignoreButton == 1) {
                        hasIgnoredButtonTransition = true;
                    }
                } else //                  }
                if (TapPressType.DoubleTap.equals(pressType)) {
                    //onAction = "ondblclick";
                    // TODO see tap
                    numClicks = 2;
                } else if (TapPressType.TripleTap.equals(pressType)) {
                    // TODO see tap
                    numClicks = 3;
                }
                if (result[1].length() > 1) {
                    result[1] += ", ";
                }
                result[1] += "[" + LEFT_MOUSE + ", " + numClicks + ", " + AAction.NONE + ", '" + destName + "']";
            }
        }
    }
    if (!hasIgnoredButtonTransition) {
        // transition already defined
        if (result[1].length() > 1) {
            result[1] += ", ";
        }
        result[1] += "[" + ignoreButton + ", 1, 0, " + IGNORE_LEFT_CLICK + "]";
    }
    result[1] += "]";
    return result;
}
Also used : TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) MouseButtonState(edu.cmu.cs.hcii.cogtool.model.MouseButtonState) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 13 with AAction

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

the class NewActionChangeDialog method setProperties.

/**
     * Remember the current values for action properties to be used
     * when creating the dialog box property options.
     *
     * @param props the current values for action properties
     * @param limitMode limits which property sets the user may use
     *                  to specify a new action (e.g., an action
     *                  for a transition from a keyboard device must
     *                  use *only* the keyboard action properties)
     * @param action the current action that generates a conflict
     * @param source the source for which the given action generates
     *               a conflict
     * @param actionTransition the existing transition from the given source
     *                         whose action is being modified; if creating
     *                         a new transition, use <code>null</code>
     */
public void setProperties(ActionProperties props, int limitMode, AAction action, TransitionSource source, Transition actionTransition) {
    // Set the propertyset if it exists, otherwise set the local var.
    if (props != null) {
        properties = props;
        mode = limitMode;
        transitionSrc = source;
        if (action != null) {
            StringBuilder buff = new StringBuilder(nonuniqueActionMsg + "\n    " + convertToDisplay(action) + " on " + source.getName());
            Map<AAction, Transition> transitions = source.getTransitions();
            if (transitions.size() > 1) {
                buff.append("\n" + actionsInUseMsg);
                Iterator<Transition> transitionIt = transitions.values().iterator();
                while (transitionIt.hasNext()) {
                    Transition t = transitionIt.next();
                    if (t != actionTransition) {
                        buff.append("\n    " + convertToDisplay(t.getAction()));
                    }
                }
            }
            complaint = buff.toString();
        }
    } else {
        throw new IllegalArgumentException("Attempted to set Action " + "properties to a null value");
    }
}
Also used : Transition(edu.cmu.cs.hcii.cogtool.model.Transition) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Example 14 with AAction

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

the class DesignEditorController method createEditTransitionAction.

// createEditDesignAction
protected IListenerAction createEditTransitionAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return DesignEditorUI.EditTransitionParameters.class;
        }

        public boolean performAction(Object prms) {
            DesignEditorUI.EditTransitionParameters parms = (DesignEditorUI.EditTransitionParameters) prms;
            Transition[] transitions = parms.selection.getSelectedTransitions();
            // Probably only one transition selected
            if ((transitions != null) && (transitions.length > 0)) {
                if (transitions.length == 1) {
                    TransitionSource source = transitions[0].getSource();
                    AAction action = transitions[0].getAction();
                    int limitMode = ActionProperties.determineChangeActionMode(source);
                    int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
                    if (!interaction.determineNewAction(transitions[0], properties, parms.useWhichParts, deviceTypes, limitMode, L10N.get("DE.ChangeActionType", "Change Action Type"))) {
                        return false;
                    }
                    action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
                    if (action == null) {
                        return false;
                    }
                    action = EditActionCmd.ensureActionIsUnique(source, action, properties, deviceTypes, limitMode, transitions[0], interaction);
                    if (action == null) {
                        return false;
                    }
                    return changeTransitionsAction(transitions, action, properties.delayInSecs, properties.delayLabel);
                } else {
                    interaction.protestMultipleTransitionSelection();
                }
            } else {
                interaction.protestNoSelection();
            }
            return false;
        }
    };
}
Also used : TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) DesignEditorUI(edu.cmu.cs.hcii.cogtool.ui.DesignEditorUI) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint)

Example 15 with AAction

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

the class DesignEditorController method createNewTransition.

// Return null to indicate cancel
protected IUndoableEdit createNewTransition(final TransitionSource source, Frame target) {
    int deviceTypes = DeviceType.buildDeviceSet(design.getDeviceTypes());
    // Helps control which options are available for editing the action
    int limitMode = ActionProperties.determineChangeActionMode(source);
    AAction action = createDefaultAction(source);
    if (action == null) {
        if (!interaction.determineNewAction(properties, deviceTypes, limitMode, L10N.get("DE.SetActionType", "Set Action Type"))) {
            // Indicate that the user canceled
            return null;
        }
        action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
        if (action == null) {
            return null;
        }
    }
    // action is not null at this point; no transition yet for this action!
    action = EditActionCmd.ensureActionIsUnique(source, action, properties, deviceTypes, limitMode, null, interaction);
    if (action == null) {
        return null;
    }
    Transition newTransition = new Transition(source, target, action);
    newTransition.setDelayInfo(properties.delayInSecs, properties.delayLabel);
    IUndoableEdit edit = DesignEditorCmd.addTransition(demoStateMgr, newTransition);
    interaction.setTransitionStatusMessage(newTransition);
    return edit;
}
Also used : Transition(edu.cmu.cs.hcii.cogtool.model.Transition) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

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