use of edu.cmu.cs.hcii.cogtool.model.InputDevice 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();
}
use of edu.cmu.cs.hcii.cogtool.model.InputDevice in project cogtool by cogtool.
the class DesignEditorFrame method addTransitionChangeHandler.
public void addTransitionChangeHandler(AlertHandler handler) {
Iterator<IWidget> sources = frame.getWidgets().iterator();
while (sources.hasNext()) {
IWidget widget = sources.next();
widget.addHandler(this, TransitionSource.TransitionChange.class, handler);
}
Iterator<InputDevice> devices = frame.getInputDevices().iterator();
while (devices.hasNext()) {
InputDevice device = devices.next();
device.addHandler(this, TransitionSource.TransitionChange.class, handler);
}
transitionChangeHandler = handler;
}
use of edu.cmu.cs.hcii.cogtool.model.InputDevice in project cogtool by cogtool.
the class DesignEditorFrame method dispose.
public void dispose() {
frameUIModel.removeAllHandlers(this);
frameUIModel.dispose();
Iterator<IWidget> sources = frame.getWidgets().iterator();
while (sources.hasNext()) {
IWidget widget = sources.next();
widget.removeAllHandlers(this);
}
Iterator<InputDevice> devices = frame.getInputDevices().iterator();
while (devices.hasNext()) {
InputDevice device = devices.next();
device.removeAllHandlers(this);
}
frame.removeAllHandlers(this);
// Need to dispose all InputSources that were created by this class
Iterator<GraphicalDevice> iter = inputDevices.values().iterator();
while (iter.hasNext()) {
GraphicalDevice d = iter.next();
d.dispose();
}
}
use of edu.cmu.cs.hcii.cogtool.model.InputDevice in project cogtool by cogtool.
the class ActionProperties method setInitialActionType.
/**
* Base initial action type on given source
*/
public void setInitialActionType(TransitionSource source, Set<DeviceType> deviceTypes) {
if (source instanceof InputDevice) {
InputDevice device = (InputDevice) source;
DeviceType devType = device.getDeviceType();
if (devType == DeviceType.Keyboard) {
useWhichParts = USE_KEYBOARD;
} else if (devType == DeviceType.Mouse) {
useWhichParts = USE_MOUSE;
} else if (devType == DeviceType.Touchscreen) {
useWhichParts = USE_TOUCHSCREEN;
} else if (devType == DeviceType.Voice) {
useWhichParts = USE_VOICE;
}
} else if (source instanceof IWidget) {
IWidget widget = (IWidget) source;
WidgetType widgetType = widget.getWidgetType();
if (widgetType == WidgetType.Graffiti) {
useWhichParts = USE_GRAFFITI_WIDGET;
} else if (widgetType == WidgetType.TextBox) {
useWhichParts = USE_KEYBOARD;
} else {
setInitialActionType(source, BASE_ACTION_ON_SOURCE, deviceTypes);
}
}
}
Aggregations