use of edu.cmu.cs.hcii.cogtool.model.MousePressType 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;
}
use of edu.cmu.cs.hcii.cogtool.model.MousePressType 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;
}
use of edu.cmu.cs.hcii.cogtool.model.MousePressType in project cogtool by cogtool.
the class ActionPropertySet method layOutMouseComposite.
@Override
public void layOutMouseComposite() {
// Attach mouse button label to 5 from the properties left
FormData data = new FormData();
data.top = new FormAttachment(mouseButtonCombo, 0, SWT.CENTER);
data.left = leftAttachment;
mouseButtonLabel.setLayoutData(data);
// Attach mouse button combo to 5 pixels from the label's bottom
// Attach mouse button combo to 5 from the properties left
// Attach right of combo to end of the properties space
data = new FormData();
data.top = new FormAttachment(0, 5);
data.left = new FormAttachment(mouseButtonLabel, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
mouseButtonCombo.setLayoutData(data);
// Center button action label to 5 below the previous combo
// Attach button action label to 5 pixels from the properties left
data = new FormData();
data.top = new FormAttachment(mouseActionCombo, 0, SWT.CENTER);
data.left = leftAttachment;
mouseActionLabel.setLayoutData(data);
data = new FormData();
// Align button action combo with mouse action label
// Attach right of combo to end of the properties space
data.left = new FormAttachment(mouseButtonCombo, 0, SWT.LEFT);
data.top = new FormAttachment(mouseButtonCombo, 5);
data.right = new FormAttachment(100, -5);
mouseActionCombo.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(transitionDestinationLabelMouse, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
if (buttonModifierSet == null) {
data.top = new FormAttachment(mouseActionCombo, 5, SWT.BOTTOM);
} else {
data.top = new FormAttachment(buttonModifierSet.FUNCTION, 5, SWT.BOTTOM);
}
transitionSourceNameMouse.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(transitionSourceNameMouse, 0, SWT.CENTER);
transitionSourceLabelMouse.setLayoutData(data);
data = new FormData();
data.left = leftAttachment;
data.top = new FormAttachment(transitionDestinationNameMouse, 0, SWT.CENTER);
transitionDestinationLabelMouse.setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(transitionDestinationLabelMouse, 5, SWT.RIGHT);
data.right = new FormAttachment(100, -5);
data.top = new FormAttachment(transitionSourceNameMouse, 5, SWT.BOTTOM);
transitionDestinationNameMouse.setLayoutData(data);
SelectionListener setResetListener = new SetResetDefaultsListener(setAsDefaultMouse, restoreDefaultsMouse) {
@Override
protected boolean haveValuesChanged() {
return isMouseChanged(originalProperties);
}
@Override
protected void setDefaults(boolean isReset) {
MousePressType mpt = getMousePressType();
MouseButtonState mbs = (mpt != MousePressType.Hover) ? getMouseButton() : null;
int mods = getMouseModifiers();
setMouseDefaults(mbs, mpt, mods);
}
@Override
protected void resetDefaults() {
resetMouse();
}
};
addDefaultButtons(mouseParms, transitionDestinationNameMouse, setAsDefaultMouse, restoreDefaultsMouse, setResetListener);
}
use of edu.cmu.cs.hcii.cogtool.model.MousePressType in project cogtool by cogtool.
the class ActionSet method createMouseComposite.
protected Composite createMouseComposite() {
Composite mouseComp = new Composite(actionSettings, SWT.NONE);
mouseComp.setLayout(new FormLayout());
mouseButtonLabel = new DisplayLabel(mouseComp, SWT.NONE);
mouseButtonLabel.setText(L10N.get("DE.MouseButtonCaption", "Mouse Button") + ":");
// TODO Why is this here rather than in its natural home in the
// overridden method in ActionPropertySet?
transitionSourceLabelMouse = createTransitionSourceLabel(mouseComp);
transitionSourceNameMouse = createTransitionSourceName(mouseComp);
transitionDestinationLabelMouse = createTransitionDestinationLabel(mouseComp);
transitionDestinationNameMouse = createTransitionDestinationName(mouseComp);
mouseButtonCombo = new ComboWithEnableFix(mouseComp, SWT.DROP_DOWN | SWT.READ_ONLY);
for (MouseButtonState element : MouseButtonState.DISPLAY) {
mouseButtonCombo.add(element.toString());
}
mouseButtonCombo.select(0);
mouseButtonCombo.addSelectionListener(widgetActionChange);
mouseActionLabel = new DisplayLabel(mouseComp, SWT.NONE);
mouseActionLabel.setText(L10N.get("DE.ButtonActionCaption", "Action") + ":");
mouseActionCombo = new ComboWithEnableFix(mouseComp, SWT.DROP_DOWN | SWT.READ_ONLY);
for (MousePressType element : MousePressType.DISPLAY) {
mouseActionCombo.add(element.toString());
}
mouseActionCombo.select(0);
mouseActionCombo.addSelectionListener(widgetActionChange);
// then add modifier set for the mouse clicks.
if (DeviceType.Keyboard.isMember(deviceTypes)) {
buttonModifierSet = new ActionModifierSet(mouseActionCombo, widgetActionChange, vertical);
}
return mouseComp;
}
use of edu.cmu.cs.hcii.cogtool.model.MousePressType in project cogtool by cogtool.
the class DesignExportToHTML method getMenuMap.
/**
* Return an array of three strings, corresponding to the three possible
* mouse buttons, representing either the name of the frame transitioned to
* by that button, or 'null'.
* NOTE: Hover and multiple-click transitions don't work with menu items.
*/
protected String getMenuMap(MenuItem child) {
String result = "[";
// 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
String[] mouseUpDests = new String[4];
mouseUpDests[0] = "null";
int mouseUpButton = 0;
Iterator<Transition> transitions = child.getTransitions().values().iterator();
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");
if (!MousePressType.Hover.equals(pressType)) {
if (MouseButtonState.Left.equals(buttonState)) {
button = LEFT_MOUSE;
} else if (MouseButtonState.Middle.equals(buttonState)) {
button = MIDDLE_MOUSE;
} else if (MouseButtonState.Right.equals(buttonState)) {
button = RIGHT_MOUSE;
}
/*if (MousePressType.Click.equals(pressType) &&
(button == LEFT_MOUSE))
{
//onAction = "onclick";
// clickDest = "'" + destName + "'";
mouseUpButton = button;
mouseUpDests[mouseUpButton] = "'" + destName + "'";
}
else */
if (MousePressType.Up.equals(pressType) || MousePressType.Click.equals(pressType)) {
//onAction = "onmouseup";
mouseUpButton = button;
mouseUpDests[mouseUpButton] = "'" + destName + "'";
}
// else if (MousePressType.Double.equals(pressType)) {
// //onAction = "ondblclick";
// dblClickButton = button;
// dblClickDests[dblClickButton] = "'" + destName + "'";
// }
// else if (MousePressType.Down.equals(pressType)) {
// onAction = "onmousedown";
// }
}
} else if (action instanceof TapAction) {
TapAction bAction = (TapAction) action;
TapPressType pressType = bAction.getTapPressType();
String destName = getFrameURL(transition.getDestination(), ".html");
if (!TapPressType.Hover.equals(pressType)) {
if (TapPressType.Tap.equals(pressType)) {
// TODO: Behavior is undefined if both a left-click and
// tap transition are created from the same widget!
//onAction = "onclick";
// clickDest = "'" + destName + "'";
mouseUpButton = LEFT_MOUSE;
mouseUpDests[mouseUpButton] = "'" + destName + "'";
}
// else if (TapPressType.Up.equals(pressType)) {
// onAction = "onmouseup";
// }
// else if (TapPressType.DoubleTap.equals(pressType)) {
// //onAction = "ondblclick";
// // TODO see tap
// dblClickButton = LEFT_MOUSE;
// dblClickDests[dblClickButton] = "'" + destName + "'";
// }
// else if (TapPressType.Down.equals(pressType)) {
// //onAction = "onmousedown";
// }
}
}
}
for (int i = 1; i < mouseUpDests.length; i++) {
if (mouseUpDests[i] == null) {
mouseUpDests[i] = "null";
}
// if (dblClickDests[i] == null) {
// dblClickDests[i] = "null";
// }
result += mouseUpDests[i];
if (i < 3) {
result += ", ";
}
}
result += "]";
return result;
}
Aggregations