use of edu.cmu.cs.hcii.cogtool.model.DeviceType in project cogtool by cogtool.
the class DesignEditorController method createPasteAction.
protected IListenerAction createPasteAction() {
return new AListenerAction() {
public boolean performAction(Object prms) {
try {
Collection<Object> objects = CogToolClipboard.fetchCogToolObjects();
if ((objects != null) && (objects.size() > 0)) {
CompoundUndoableEdit editSequence = new CompoundUndoableEdit(L10N.get("UNDO.Paste", "Paste"), DesignEditorLID.Paste);
Set<DeviceType> devTypes = design.getDeviceTypes();
int numPasted = 0;
Iterator<Object> objIt = objects.iterator();
while (objIt.hasNext()) {
Object o = objIt.next();
if (o instanceof Frame) {
Frame frame = (Frame) o;
makeFrameNameUnique(frame);
// Find an unoccupied starting position
// by cascading.
DoublePoint origin = frame.getFrameOrigin();
DesignUtil.findDistinctOrigin(design, origin, 16.0, 16.0);
// Union devices
Iterator<InputDevice> frameDevices = frame.getInputDevices().iterator();
while (frameDevices.hasNext()) {
InputDevice inputDevice = frameDevices.next();
DeviceType devType = inputDevice.getDeviceType();
if (!devTypes.contains(devType)) {
DesignCmd.addDevice(design, devType);
}
}
Iterator<DeviceType> designDevTypes = devTypes.iterator();
while (designDevTypes.hasNext()) {
DeviceType devType = designDevTypes.next();
if (frame.getInputDevice(devType) == null) {
frame.addInputDevice(devType);
}
}
addFrame(frame, editSequence);
numPasted++;
} else if (o instanceof Transition) {
Transition t = (Transition) o;
DeviceType device = t.getAction().getDefaultDeviceType();
if (!devTypes.contains(device)) {
DesignCmd.addDevice(design, device);
}
IUndoableEdit edit = DesignEditorCmd.addTransition(demoStateMgr, t);
editSequence.addEdit(edit);
numPasted++;
}
}
editSequence.end();
undoMgr.addEdit(editSequence);
interaction.setStatusMessage(numPasted + " " + pasteComplete);
} else {
interaction.setStatusMessage(nothingPasted);
}
} catch (IOException e) {
throw new RcvrClipboardException(e);
} catch (ParserConfigurationException e) {
throw new RcvrClipboardException(e);
} catch (SAXException e) {
throw new RcvrClipboardException(e);
} catch (ClipboardUtil.ClipboardException e) {
throw new RcvrClipboardException(e);
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.DeviceType in project cogtool by cogtool.
the class FrameEditorController method createWidget.
private Widget createWidget(WidgetType defaultType, DoubleRectangle bounds, String widgetTitle, boolean isStandard) {
Widget widget;
// the user specified actual bounds interactively
if (isStandard) {
if (defaultType == WidgetType.Menu) {
SimpleWidgetGroup newMenuHeaderGroup = new SimpleWidgetGroup(SimpleWidgetGroup.HORIZONTAL);
widget = new MenuHeader(newMenuHeaderGroup, bounds, widgetTitle);
} else if (defaultType == WidgetType.PullDownList) {
widget = new PullDownHeader(bounds, widgetTitle);
} else if (defaultType == WidgetType.ContextMenu) {
widget = new ContextMenu(bounds, widgetTitle);
// The default value for CONTEXT_MENU_ACTION_ATTR
// is RIGHT_CLICK; must change to TAP_HOLD if the devices
// contain a Touchscreen but not a Mouse
Set<DeviceType> deviceTypes = design.getDeviceTypes();
if (deviceTypes.contains(DeviceType.Touchscreen) && !deviceTypes.contains(DeviceType.Mouse)) {
widget.setAttribute(WidgetAttributes.CONTEXT_MENU_ACTION_ATTR, WidgetAttributes.TAP_HOLD);
}
} else if (defaultType == WidgetType.ListBoxItem) {
SimpleWidgetGroup newListItemGroup = new SimpleWidgetGroup(SimpleWidgetGroup.VERTICAL);
widget = new ListItem(newListItemGroup, bounds, widgetTitle);
newListItemGroup.setAttribute(WidgetAttributes.FIRST_VISIBLE_ATTR, widget);
} else if (defaultType == WidgetType.Radio) {
RadioButtonGroup newRadioGroup = new RadioButtonGroup();
widget = new RadioButton(newRadioGroup, bounds, widgetTitle);
} else if (defaultType == WidgetType.Check) {
GridButtonGroup newCheckGroup = new GridButtonGroup();
widget = new CheckBox(newCheckGroup, bounds, widgetTitle);
} else {
// Create new widget in specified location
// Note: could be a child widget;
// if so, the user is managing the hierarchy!
widget = new Widget(bounds, defaultType);
}
widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR, WidgetAttributes.IS_STANDARD);
} else {
// Create new widget in specified location
// Note: could be a child widget;
// if so, the user is managing the hierarchy!
widget = new Widget(bounds, defaultType);
widget.setAttribute(WidgetAttributes.IS_STANDARD_ATTR, WidgetAttributes.IS_CUSTOM);
}
return widget;
}
use of edu.cmu.cs.hcii.cogtool.model.DeviceType in project cogtool by cogtool.
the class EditActionCmd method createDefaultAction.
// buildActionFromProperties
/**
* Based on the given transition source and/or the given type of transition
* to prefer, return a new action based on the current default settings.
* The current default settings are also copied into the controller's
* ActionProperties instance variable. If it is not possible to create
* the action, <code>null</code> is returned.
*
* @param source
* @return
*/
public static AAction createDefaultAction(Design design, TransitionSource source, ActionType desiredTransitionType, ActionProperties properties) {
if (source instanceof InputDevice) {
InputDevice device = (InputDevice) source;
DeviceType type = device.getDeviceType();
if (type == DeviceType.Keyboard) {
return properties.createKeyAction();
}
if (type == DeviceType.Voice) {
return properties.createVoiceAction();
}
}
// At this point, ensure source is an IWidget!
if (source instanceof IWidget) {
IWidget widget = (IWidget) source;
if (desiredTransitionType == ActionProperties.BASE_ACTION_ON_SOURCE) {
if (widget.getWidgetType() == WidgetType.Graffiti) {
return properties.createGraffitiAction();
}
Set<DeviceType> designDeviceTypes = design.getDeviceTypes();
// If both mouse and touchscreen exist, mouse has precedence
if (designDeviceTypes.contains(DeviceType.Mouse)) {
return properties.createMouseAction();
}
if (designDeviceTypes.contains(DeviceType.Touchscreen)) {
return properties.createTouchAction();
}
// Only other devices available should be Keyboard or Voice!
if (designDeviceTypes.contains(DeviceType.Keyboard)) {
return properties.createKeyAction();
}
if (designDeviceTypes.contains(DeviceType.Voice)) {
return properties.createVoiceAction();
}
} else {
// Base action on desiredTransitionType
if (desiredTransitionType == ActionType.ButtonPress) {
return properties.createMouseAction();
} else if (desiredTransitionType == ActionType.KeyPress) {
return properties.createKeyAction();
} else if (desiredTransitionType == ActionType.Tap) {
return properties.createTouchAction();
} else if (desiredTransitionType == ActionType.GraffitiStroke) {
return properties.createGraffitiAction();
} else if (desiredTransitionType == ActionType.Voice) {
return properties.createVoiceAction();
}
}
}
return null;
}
use of edu.cmu.cs.hcii.cogtool.model.DeviceType in project cogtool by cogtool.
the class ActionPropertySet method updateEmptyComposite.
public void updateEmptyComposite(Design design, boolean selectFirst) {
designName.setData(design);
designName.setText(design.getName());
Set<DeviceType> devices = design.getDeviceTypes();
for (int i = 0; i < DeviceType.DISPLAY_ORDER.length; i++) {
if (DeviceType.Display.equals(DeviceType.DISPLAY_ORDER[i]) || devices.contains(DeviceType.DISPLAY_ORDER[i])) {
deviceButtons[i].setSelection(true);
}
}
SkinType skin = design.getSkin();
if (SkinType.WireFrame.equals(skin)) {
skinCombo.select(0);
} else if (SkinType.MacOSX.equals(skin)) {
skinCombo.select(1);
} else if (SkinType.WinXP.equals(skin)) {
skinCombo.select(2);
}
updateTree(design);
if (selectFirst && frameTree.getItemCount() > 0) {
frameTree.setSelection(frameTree.getItem(0));
}
}
use of edu.cmu.cs.hcii.cogtool.model.DeviceType 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