use of edu.cmu.cs.hcii.cogtool.model.TextAction in project cogtool by cogtool.
the class SEDemoController method performSelfTransition.
protected boolean performSelfTransition(SEDemoSelectionState selection, TransitionSource source, AAction action, double delayInSecs, String delayLabel) {
AScriptStep beforeStep = getDemoStep(selection);
ActionScriptStep selfTransitionStep = new ActionScriptStep(action, source);
selfTransitionStep.setDelay(delayInSecs, delayLabel);
if (source instanceof IWidget) {
IWidget widget = (IWidget) source;
ActionType actionType = action.getType();
WidgetType widgetType = widget.getWidgetType();
if (toggleIfGermane(widget, selfTransitionStep, action)) {
// Do nothing further
} else if ((actionType == ActionType.KeyPress) || (actionType == ActionType.GraffitiStroke)) {
TextAction text = (TextAction) action;
if (widgetType == WidgetType.TextBox) {
selfTransitionStep.overrideAttribute(widget, WidgetAttributes.APPENDED_TEXT_ATTR, text.getText());
}
}
}
return insertStep(selfTransitionStep, beforeStep, SEDemoLID.InsertSelfTransition, INSERT_SELF_TRANSITION);
}
use of edu.cmu.cs.hcii.cogtool.model.TextAction in project cogtool by cogtool.
the class DesignExportToHTML method buildKeyTransitionMap.
/**
* Outputs a Javascript function that makes a map from the transition
* string to the name of the destination frame
* (treats Graffiti transitions as keyboard transitions)
*/
protected String buildKeyTransitionMap(Collection<InputDevice> devices, Collection<IWidget> widgets) {
StringBuilder html = new StringBuilder();
Iterator<InputDevice> deviceIterator = devices.iterator();
while (deviceIterator.hasNext()) {
InputDevice device = deviceIterator.next();
if (DeviceType.Keyboard.equals(device.getDeviceType()) || DeviceType.Touchscreen.equals(device.getDeviceType())) {
// first save all transitions from the device
Iterator<Transition> transitions = device.getTransitions().values().iterator();
while (transitions.hasNext()) {
Transition transition = transitions.next();
AAction action = transition.getAction();
if (action instanceof TextAction) {
String text = cleanup(((TextAction) action).getText());
html.append("keyTransitionMap[\"" + text + "\"]");
html.append(" = \'");
html.append(getFrameURL(transition.getDestination(), ".html"));
html.append("\';\n");
}
}
}
}
Iterator<IWidget> widgetIterator = widgets.iterator();
// NOTE: does not work with list box items or any menus
while (widgetIterator.hasNext()) {
IWidget w = widgetIterator.next();
String name = "\"" + w.getName() + "\"";
Iterator<Transition> wTransitions = w.getTransitions().values().iterator();
boolean foundKeyTransition = false;
while (wTransitions.hasNext()) {
Transition transition = wTransitions.next();
AAction action = transition.getAction();
if (action instanceof TextAction) {
if (!foundKeyTransition) {
foundKeyTransition = true;
html.append("focusTransitionMaps[" + name + "] = new Object();\n");
}
String key = "\"" + cleanup(((TextAction) action).getText()) + "\"";
String dest = "'" + getFrameURL(transition.getDestination(), ".html") + "'";
html.append("focusTransitionMaps[" + name + "][");
html.append(key + "] = " + dest + ";\n");
}
}
}
return html.toString();
}
Aggregations