Search in sources :

Example 1 with IWidget

use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.

the class EltGroupPropertiesPane method updateEltGroup.

public void updateEltGroup(FrameElementGroup eltGroup) {
    String eltGroupName = eltGroup.getName();
    this.eltGroupName.setText((eltGroupName != null) ? eltGroupName : "");
    this.eltGroupName.setData(eltGroup);
    IWidget remoteLabelWidget = (IWidget) eltGroup.getAttribute(WidgetAttributes.REMOTE_LABEL_ATTR);
    if (remoteLabelWidget != null) {
        remoteLabelText.setText(remoteLabelWidget.getTitle());
        remoteLabelFind.setVisible(true);
    } else {
        // Display an empty remote label to allow one to be set
        remoteLabelText.setText("");
        remoteLabelFind.setVisible(false);
    }
    remoteLabel.setVisible(true);
    remoteLabelText.setVisible(true);
    auxText.setText(eltGroup.getAuxiliaryText());
    auxText.setVisible(true);
    auxTextLabel.setVisible(true);
    groupEltsUpdater.updateTree(eltGroup.iterator());
}
Also used : IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 2 with IWidget

use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.

the class FramePropertiesPane method update.

public void update(Frame frame) {
    Object pathObj = frame.getAttribute(WidgetAttributes.IMAGE_PATH_ATTR);
    if (NullSafe.equals(WidgetAttributes.NO_IMAGE, pathObj)) {
        imagePath.setVisible(false);
        imagePathText.setVisible(false);
    } else {
        String imgPath = (String) pathObj;
        imagePath.setVisible(true);
        imagePathText.setVisible(true);
        imagePathText.setText(imgPath);
        imagePathText.setSelection(imgPath.length());
    }
    Set<TransitionSource> children = new LinkedHashSet<TransitionSource>();
    children.addAll(frame.getWidgets());
    children.addAll(frame.getInputDevices());
    widgetUpdater.updateTree(children.iterator());
    if (eltGroupTreeLabel != null) {
        Set<FrameElementGroup> grps = frame.getEltGroups();
        if (!CogToolPref.NESTED_GROUPS_SHOWN_AT_TOP_LEVEL.getBoolean()) {
            grps = filterNestedGroups(grps);
        }
        eltGroupUpdater.updateTree(grps.iterator());
        Set<SimpleWidgetGroup> implicitGroups = new HashSet<SimpleWidgetGroup>();
        for (IWidget w : frame.getWidgets()) {
            SimpleWidgetGroup g = w.getParentGroup();
            if (g != null) {
                implicitGroups.add(g);
            }
        }
        implicitGroupUpdater.updateTree(implicitGroups.iterator());
    }
    setFrameName(frame);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TransitionSource(edu.cmu.cs.hcii.cogtool.model.TransitionSource) SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) FrameElementGroup(edu.cmu.cs.hcii.cogtool.model.FrameElementGroup) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 3 with IWidget

use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.

the class SEDemoController method performSelfTransition.

protected boolean performSelfTransition(SEDemoSelectionState selection, TransitionSource source, AAction action, double delayInSecs, String delayLabel) {
    AScriptStep beforeStep = getDemoStep(selection);
    ActionScriptStep selfTransitionStep = new ActionScriptStep(action, source);
    selfTransitionStep.setDelay(delayInSecs, delayLabel);
    if (source instanceof IWidget) {
        IWidget widget = (IWidget) source;
        ActionType actionType = action.getType();
        WidgetType widgetType = widget.getWidgetType();
        if (toggleIfGermane(widget, selfTransitionStep, action)) {
        // Do nothing further
        } else if ((actionType == ActionType.KeyPress) || (actionType == ActionType.GraffitiStroke)) {
            TextAction text = (TextAction) action;
            if (widgetType == WidgetType.TextBox) {
                selfTransitionStep.overrideAttribute(widget, WidgetAttributes.APPENDED_TEXT_ATTR, text.getText());
            }
        }
    }
    return insertStep(selfTransitionStep, beforeStep, SEDemoLID.InsertSelfTransition, INSERT_SELF_TRANSITION);
}
Also used : ActionScriptStep(edu.cmu.cs.hcii.cogtool.model.ActionScriptStep) ActionType(edu.cmu.cs.hcii.cogtool.model.ActionType) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) AScriptStep(edu.cmu.cs.hcii.cogtool.model.AScriptStep) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) TextAction(edu.cmu.cs.hcii.cogtool.model.TextAction)

Example 4 with IWidget

use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.

the class SEDemoMouseState method doTransitionAction.

protected boolean doTransitionAction(TransitionSource source, int button, int state, int clickState) {
    AAction action = null;
    Set<DeviceType> deviceTypes = ui.design.getDeviceTypes();
    if (deviceTypes.contains(DeviceType.Mouse)) {
        MousePressType pt = null;
        switch(clickState) {
            case UP:
                pt = MousePressType.Up;
                break;
            case DOWN:
                pt = MousePressType.Down;
                break;
            case CLICK:
                pt = MousePressType.Click;
                break;
            case DOUBLE:
                pt = MousePressType.Double;
                break;
            case TRIPLE:
                pt = MousePressType.Triple;
                break;
            default:
                throw new IllegalArgumentException("Invalid click state received");
        }
        action = new ButtonAction(getActionButtonButton(button), pt, getActionButtonModifier(state));
    } else if (deviceTypes.contains(DeviceType.Touchscreen)) {
        TapPressType tt = null;
        switch(clickState) {
            case UP:
                tt = TapPressType.Up;
                break;
            case DOWN:
                tt = TapPressType.Down;
                break;
            case CLICK:
                tt = TapPressType.Tap;
                break;
            case DOUBLE:
                tt = TapPressType.DoubleTap;
                break;
            case TRIPLE:
                tt = TapPressType.TripleTap;
                break;
            default:
                throw new IllegalArgumentException("Invalid ClickState received");
        }
        action = new TapAction(tt);
    }
    if (clickState == CLICK) {
        if (source.getTransition(action) == null) {
            // Check to see if a doubleclick/doubletap is in the set of
            // transitions
            Iterator<AAction> iter = source.getTransitions().keySet().iterator();
            while (iter.hasNext()) {
                AAction act = iter.next();
                if ((act.getType() == ActionType.ButtonPress) && deviceTypes.contains(DeviceType.Mouse)) {
                } else if ((act.getType() == ActionType.Tap) && deviceTypes.contains(DeviceType.Touchscreen)) {
                }
            }
            if ((source instanceof IWidget) && ((IWidget) source).isStandard() && deviceTypes.contains(DeviceType.Mouse)) {
                WidgetType type = ((IWidget) source).getWidgetType();
                Object toggle = source.getAttribute(WidgetAttributes.IS_TOGGLEABLE_ATTR);
                Object isSep = source.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
                if ((type == WidgetType.Check) || (type == WidgetType.Radio) || ((type == WidgetType.PullDownItem) && NullSafe.equals(WidgetAttributes.NON_SEPARATOR, isSep)) || ((type == WidgetType.Button) && NullSafe.equals(WidgetAttributes.IS_TOGGLEABLE, toggle))) {
                    if (type == WidgetType.PullDownItem) {
                        ui.hideAllChildren();
                    }
                    AAction a = new ButtonAction(MouseButtonState.Left, MousePressType.Click, 0);
                    SEDemoUI.SelfTransition prms = new SEDemoUI.SelfTransition(ui.selection, source, a);
                    ui.performAction(SEDemoLID.InsertSelfTransition, prms);
                    return true;
                }
            }
            ui.showContextMenu(source);
        }
    }
    Transition transition = source.getTransition(action);
    if (transition != null) {
        SEDemoUI.FollowTransition prms = new SEDemoUI.FollowTransition(ui.selection, transition);
        ui.performAction(SEDemoLID.PerformTransition, prms);
        return true;
    }
    return false;
}
Also used : ButtonAction(edu.cmu.cs.hcii.cogtool.model.ButtonAction) TapAction(edu.cmu.cs.hcii.cogtool.model.TapAction) DeviceType(edu.cmu.cs.hcii.cogtool.model.DeviceType) TapPressType(edu.cmu.cs.hcii.cogtool.model.TapPressType) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) MousePressType(edu.cmu.cs.hcii.cogtool.model.MousePressType) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) AAction(edu.cmu.cs.hcii.cogtool.model.AAction) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Example 5 with IWidget

use of edu.cmu.cs.hcii.cogtool.model.IWidget in project cogtool by cogtool.

the class SEDemoUI method populateContextMenu.

protected void populateContextMenu(TransitionSource source, List<MenuItemDefinition> menuItems) {
    Collection<Transition> values = source.getTransitions().values();
    Iterator<Transition> iter = values.iterator();
    SEDemoTransitionLID itemLID;
    while (iter.hasNext()) {
        Transition trans = iter.next();
        SEDemoUI.DemoTransition ftrans = new SEDemoUI.FollowTransition(selection, trans);
        // Add the ftrans to the list in the context menus
        itemLID = new SEDemoTransitionLID("PerformDemoTransition", ftrans);
        String transitionStr = KeyDisplayUtil.convertActionToMenuText(ftrans.getLocalizedString());
        MenuItemDefinition mItem = new SimpleMenuItemDefinition(transitionStr, itemLID, MenuUtil.ENABLED);
        menuItems.add(mItem);
    }
    // Check to see if any transitions are actually available.
    if (values.size() == 0) {
        MenuItemDefinition mItem = new SimpleMenuItemDefinition(L10N.get("SE.DemoNoPredefinedTransitions", "No defined transitions for ") + source.getName(), null);
        // Add a default disabled message
        menuItems.add(mItem);
    }
    boolean selfTransitionOK = true;
    // Add a default look-at transition for all regions except Devices
    if (source.getTransitionSourceType() == TransitionSourceType.Widget) {
        IWidget widget = (IWidget) source;
        Object isSep = widget.getAttribute(WidgetAttributes.IS_SEPARATOR_ATTR);
        if ((NullSafe.equals(WidgetAttributes.IS_SEPARATOR, isSep)) || (widget.getWidgetType() == WidgetType.Noninteractive) || ((widget instanceof MenuHeader) || (widget instanceof PullDownHeader) || (widget instanceof ContextMenu))) {
            selfTransitionOK = false;
        }
        // Add standard menus to the list of items
        menuItems.add(MenuUtil.SEPARATOR);
        SEDemoUI.DemoTransition lookAtTrans = new SEDemoUI.LookAtTransition(selection, widget);
        // Add default transition options.
        String itemLabel = L10N.get("SE.DemoLookAt", "Look at") + " " + widget.getName();
        itemLID = new SEDemoTransitionLID("PerformDemoLookAtTransition", lookAtTrans);
        menuItems.add(new SimpleMenuItemDefinition(itemLabel, itemLID, MenuUtil.ENABLED));
    }
    if (selfTransitionOK) {
        menuItems.add(MenuUtil.SEPARATOR);
        itemLID = new SEDemoTransitionLID("PerformSelfTransition", new SEDemoUI.SelfTransition(selection, source, null));
        MenuItemDefinition mItem = new SimpleMenuItemDefinition(L10N.get("SE.SelfTransition", "Perform Self-transition"), itemLID, MenuUtil.ENABLED);
        menuItems.add(mItem);
    }
}
Also used : MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) SimpleMenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition) ContextMenu(edu.cmu.cs.hcii.cogtool.model.ContextMenu) PullDownHeader(edu.cmu.cs.hcii.cogtool.model.PullDownHeader) SimpleMenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition) MenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.MenuItemDefinition) SEDemoTransitionLID(edu.cmu.cs.hcii.cogtool.ui.SEDemoLID.SEDemoTransitionLID) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) EventObject(java.util.EventObject) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)93 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)29 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)20 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)19 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)15 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)15 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)12 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)11 Point (org.eclipse.draw2d.geometry.Point)11 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)10 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)9 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)9 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)9 HashSet (java.util.HashSet)8 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)7 InputDevice (edu.cmu.cs.hcii.cogtool.model.InputDevice)7 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)7 FrameEditorUI (edu.cmu.cs.hcii.cogtool.ui.FrameEditorUI)7 Iterator (java.util.Iterator)7 EventObject (java.util.EventObject)6