Search in sources :

Example 6 with DeviceType

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;
        }
    };
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) AListenerAction(edu.cmu.cs.hcii.cogtool.util.AListenerAction) RcvrClipboardException(edu.cmu.cs.hcii.cogtool.util.RcvrClipboardException) CompoundUndoableEdit(edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit) RcvrIOException(edu.cmu.cs.hcii.cogtool.util.RcvrIOException) IOException(java.io.IOException) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) SAXException(org.xml.sax.SAXException) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) ClipboardUtil(edu.cmu.cs.hcii.cogtool.util.ClipboardUtil) DoublePoint(edu.cmu.cs.hcii.cogtool.model.DoublePoint) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 7 with DeviceType

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;
}
Also used : DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) CheckBox(edu.cmu.cs.hcii.cogtool.model.CheckBox) ChildWidget(edu.cmu.cs.hcii.cogtool.model.ChildWidget) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) TraversableWidget(edu.cmu.cs.hcii.cogtool.model.TraversableWidget) AMenuWidget(edu.cmu.cs.hcii.cogtool.model.AMenuWidget) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) Widget(edu.cmu.cs.hcii.cogtool.model.Widget) RadioButtonGroup(edu.cmu.cs.hcii.cogtool.model.RadioButtonGroup) ContextMenu(edu.cmu.cs.hcii.cogtool.model.ContextMenu) PullDownHeader(edu.cmu.cs.hcii.cogtool.model.PullDownHeader) ListItem(edu.cmu.cs.hcii.cogtool.model.ListItem) RadioButton(edu.cmu.cs.hcii.cogtool.model.RadioButton) GridButtonGroup(edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)

Example 8 with DeviceType

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;
}
Also used : DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) InputDevice(edu.cmu.cs.hcii.cogtool.model.InputDevice) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 9 with DeviceType

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));
    }
}
Also used : DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) SkinType(edu.cmu.cs.hcii.cogtool.model.SkinType) Point(org.eclipse.swt.graphics.Point)

Example 10 with DeviceType

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);
    }
}
Also used : ActionPropertySet(edu.cmu.cs.hcii.cogtool.view.ActionPropertySet) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) GraffitiAction(edu.cmu.cs.hcii.cogtool.model.GraffitiAction) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) DesignEditorTransition(edu.cmu.cs.hcii.cogtool.uimodel.DesignEditorTransition) Point(org.eclipse.draw2d.geometry.Point) AAction(edu.cmu.cs.hcii.cogtool.model.AAction)

Aggregations

DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)14 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)6 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)5 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)5 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)4 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)3 ButtonAction (edu.cmu.cs.hcii.cogtool.model.ButtonAction)2 GraffitiAction (edu.cmu.cs.hcii.cogtool.model.GraffitiAction)2 TapAction (edu.cmu.cs.hcii.cogtool.model.TapAction)2 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)2 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)2 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)2 PageInfo (edu.cmu.cs.hcii.cogtool.controller.WebCrawler.PageInfo)1 AMenuWidget (edu.cmu.cs.hcii.cogtool.model.AMenuWidget)1 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)1 ActionType (edu.cmu.cs.hcii.cogtool.model.ActionType)1 CheckBox (edu.cmu.cs.hcii.cogtool.model.CheckBox)1 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)1 ContextMenu (edu.cmu.cs.hcii.cogtool.model.ContextMenu)1 Design (edu.cmu.cs.hcii.cogtool.model.Design)1