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;
}
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);
}
}
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);
}
}
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();
}
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 = "";
}
}
Aggregations