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