Search in sources :

Example 16 with Transition

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

the class DesignEditorSelectionState method getSelectedTransitions.

public Transition[] getSelectedTransitions() {
    Transition[] transitions = new Transition[selectedTransitions.size()];
    Iterator<DesignEditorTransition> transitionIterator = selectedTransitions.values().iterator();
    int i = 0;
    while (transitionIterator.hasNext()) {
        DesignEditorTransition transitionHolder = transitionIterator.next();
        transitions[i++] = transitionHolder.getTransition();
    }
    return transitions;
}
Also used : DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition)

Example 17 with Transition

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

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

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

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

the class HCIPACmd method getStartFrame.

// addHCIPATasks
protected static Frame getStartFrame(Design d) {
    Frame result = null;
    Iterator<Frame> frames = d.getFrames().iterator();
    Frame f = null;
    while (frames.hasNext()) {
        f = frames.next();
        Set<Transition> transitions = f.getIncidentTransitions();
        if (transitions.size() == 0) {
            result = f;
        }
    }
    if ((result == null) && (f != null)) {
        result = f;
    }
    return result;
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) Transition(edu.cmu.cs.hcii.cogtool.model.Transition)

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