use of edu.cmu.cs.hcii.cogtool.model.GraffitiAction 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 = "";
}
}
use of edu.cmu.cs.hcii.cogtool.model.GraffitiAction in project cogtool by cogtool.
the class DesignEditorUI method updateView.
protected void updateView(boolean deselectAll) {
if (view.isDisposed()) {
return;
}
ActionPropertySet actionProps = view.getActionPropertySet();
int selectedTransitionCount = selection.getSelectedTransitionCount();
int selectedFrameCount = selection.getSelectedFrameCount();
if (deselectAll || (selectedFrameCount + selectedTransitionCount == 0)) {
actionProps.useParameters(ActionSet.USE_NONE);
} else if (selectedTransitionCount == 1) {
Transition transition = selection.getSelectedTransitions()[0];
AAction action = transition.getAction();
DeviceType type = action.getDefaultDeviceType();
int device = ActionSet.USE_NONE;
if (action instanceof GraffitiAction) {
device = ActionSet.USE_GRAFFITI_WIDGET;
} else if (type == DeviceType.Mouse) {
device = ActionSet.USE_MOUSE;
} else if (type == DeviceType.Touchscreen) {
device = ActionSet.USE_TOUCHSCREEN;
} else if (type == DeviceType.Keyboard) {
device = ActionSet.USE_KEYBOARD;
} else if (type == DeviceType.Voice) {
device = ActionSet.USE_VOICE;
} else if (type == null) {
// Generally, a hover action; pick whichever is active
if (actionProps.isMouseSelected()) {
device = ActionSet.USE_MOUSE;
} else if (actionProps.isTouchSelected()) {
device = ActionSet.USE_TOUCHSCREEN;
}
}
actionProps.setComposite(device);
ActionProperties properties = view.getActionProperties();
view.getDefaultProperties(properties);
properties.updateProperties(transition, transition.getAction(), transition.getSource());
int limitMode = ActionProperties.determineChangeActionMode(transition.getSource());
actionProps.setLimitMode(limitMode, properties.useWhichParts);
actionProps.setProperties(properties, properties.useWhichParts);
} else if (selectedTransitionCount > 1) {
actionProps.useParameters(ActionPropertySet.MULT_TRANS);
}
if (selectedFrameCount == 1) {
actionProps.updateFrameComposite(selection.getSelectedFrames()[0]);
} else if ((selectedFrameCount == 0) && (selectedTransitionCount == 0)) {
actionProps.updateEmptyComposite(design, false);
}
}
Aggregations