Search in sources :

Example 1 with WidgetType

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

the class FrameEditorView method updateWidgetProperties.

public void updateWidgetProperties(IWidget widget) {
    setWidgetName(widget.getName());
    setWidgetTitle(widget.getTitle());
    setWidgetAuxText(widget.getAuxiliaryText());
    WidgetType t = widget.getWidgetType();
    if (t == WidgetType.Text || t == WidgetType.Noninteractive) {
        setWidgetRenderable(false);
    } else {
        setWidgetRenderable(true);
        setWidgetRendered(widget.isRendered());
    }
    setWidgetType(t);
    // Remote labels are not standard or custom
    Boolean isStandard = Boolean.valueOf(widget.isStandard());
    if (null != widget.getAttribute(WidgetAttributes.REMOTE_LABEL_OWNER_ATTR)) {
        isStandard = null;
    }
    setWidgetMode(isStandard);
    showAttributeWidgets(widget);
}
Also used : WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType)

Example 2 with WidgetType

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

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

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

the class BalsamiqButtonAPIConverter method parseBMMLGroup.

// parseBMMLWidget
//TODO: probably need to give the group dimensions
/** Helper function used by parseFrame
	 * This method is used to parse the tags of each control tag in Balsamiq XML. A control tag
	 * represents a Balsamiq Group.
     * 
     * @param  node a node of the tree that represents a Balsamiq widget
     * @frame  frame that the widget is being added to
     * @group  parent group
     * @groupX x coordinate of parent group
     * @groupY y coordinate of parent group
     * @return      new group containing widgets
     */
public void parseBMMLGroup(Node groupXMLtag, Frame frame, SimpleWidgetGroup parentGroup, double initX, double initY) {
    SimpleWidgetGroup widgetGrp = null;
    NodeList groupSubtags = groupXMLtag.getChildNodes();
    String grpName = getAttributeValue(groupXMLtag, CONTROL_ID_ATTR);
    double x = Double.parseDouble(getAttributeValue(groupXMLtag, X_ATTR));
    double y = Double.parseDouble(getAttributeValue(groupXMLtag, Y_ATTR));
    x += initX;
    y += initY;
    if (grpName == null) {
    //TODO: report to the user
    }
    System.out.println("587-GROUP " + grpName);
    if ((grpName != null) && !"".equals(grpName)) {
        widgetGrp = groupRegistry.get(grpName);
        for (int i = 0; i < groupSubtags.getLength(); i++) {
            Node groupSubtag = groupSubtags.item(i);
            String groupSubtagName = groupSubtag.getNodeName();
            System.out.println("598-nodeName1 " + groupSubtagName);
            /*Whitespace in the DOM tree is represented as #text. Ignore these nodes*/
            if (!groupSubtagName.equals("#text")) {
                if (groupSubtagName.equalsIgnoreCase("groupChildrenDescriptors")) {
                    System.out.println("605-groupchildrendescriptors");
                    WidgetType groupType = checkWidgetGroupType(groupSubtag);
                    if (groupType != null) {
                        System.out.println("630-groupwidgetType " + groupType.getName());
                    } else {
                        System.out.println("groupwidgetType is null");
                    }
                    NodeList children2 = groupSubtag.getChildNodes();
                    for (int j = 0; j < children2.getLength(); j++) {
                        Node child3 = children2.item(j);
                        String nodeName3 = child3.getNodeName();
                        System.out.println("657- nodeName3 " + nodeName3 + " j is " + j + " length " + children2.getLength());
                        if (nodeName3.equalsIgnoreCase(CONTROL_ELT)) {
                            System.out.println("660-This is a control!");
                            Widget widget2 = null;
                            if (widgetGrp == null) {
                                if (groupType == WidgetType.Radio) {
                                    widgetGrp = new RadioButtonGroup();
                                } else if (groupType == WidgetType.Check) {
                                    System.out.println("654-grouptype is a check");
                                    widgetGrp = new GridButtonGroup();
                                } else {
                                    widgetGrp = new SimpleWidgetGroup(1);
                                }
                                widgetGrp.setName(grpName);
                                groupRegistry.put(grpName, widgetGrp);
                            }
                            try {
                                String balsamiqControlType = getAttributeValue(child3, CONTROL_TYPE_ATTR);
                                String widgetTypeString = (balsamiqControlType == null) ? null : getBMMLWidgetType(balsamiqControlType);
                                System.out.println("663-widgetTypeString " + widgetTypeString);
                                if (widgetTypeString.equals("group")) {
                                    System.out.println("682-calling bmmlgroup");
                                    parseBMMLGroup(child3, frame, widgetGrp, x, y);
                                }
                                widget2 = parseBMMLWidget(child3, frame, widgetGrp, x, y);
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            int widgetCount = widgetGrp.elementCount();
                            System.out.println("692- WIDGET COUNT for " + grpName + ": " + widgetCount + " " + widget2.getName());
                            if (widget2 != null) {
                                //TODO: check widget does not need to be added here
                                //widgetGrp.addElement(widget2);
                                widget2.setParentGroup(widgetGrp);
                                //frame.addEltGroup(gridWidgetGrp);
                                frame.addWidget(widget2);
                                widgetLoader.set(widget2, Widget.widgetTypeVAR, widget2.getWidgetType());
                            //AShape widgetShape = widget2.getShapeType();
                            //if (widgetShape != null) {
                            // widgetLoader.set(widget2, Widget.shapeVAR, widgetShape);
                            // }
                            }
                            System.out.println("696-widget2 added");
                        }
                    }
                }
            }
        }
    }
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) Widget(edu.cmu.cs.hcii.cogtool.model.Widget) RadioButtonGroup(edu.cmu.cs.hcii.cogtool.model.RadioButtonGroup) IOException(java.io.IOException) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) GridButtonGroup(edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)

Example 5 with WidgetType

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

the class FrameEditorUI method confirmRenameFigure.

protected void confirmRenameFigure() {
    if ((editor != null) && editor.inUse()) {
        String newTitle = editor.getText();
        editor.cleanup();
        // figure whose title is currently being edited
        IFigure figure = (IFigure) editor.getData();
        if (figure instanceof PotentialFigure) {
            if ("".equals(newTitle)) {
                // nothing to do if empty string on potential item!
                return;
            }
            GraphicalTraversableWidget<?> parent = potentialUIFig.getFigureOwner();
            TraversableWidget parentModel = (TraversableWidget) parent.getModel();
            boolean isRightPotentialFigure = (figure == potentialUIFig.getRightFigure());
            WidgetType type = null;
            AParentWidget header = null;
            SimpleWidgetGroup group = null;
            boolean isSeparator = false;
            if (parentModel instanceof MenuItem) {
                type = WidgetType.MenuItem;
                MenuItem parentItem = (MenuItem) parentModel;
                if (isRightPotentialFigure) {
                    // position of selected figure is on the right
                    // parent menuitem becomes a submenu; figure to be
                    // created becomes a child of the submenu
                    parentItem.setSubmenu(true);
                    header = parentItem;
                } else {
                    // if position is on the bottom and the parent is not a
                    // header, put the new widget in the same menu as the
                    // parent item
                    header = parentItem.getParent();
                    // previous item should hide children if it's a submenu
                    ((GraphicalParentWidget<?, ?>) parent).closeChildren();
                }
                if (parentModel.getWidgetType() != WidgetType.Submenu) {
                    isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
                }
            } else if (parentModel instanceof ContextMenu) {
                header = (ContextMenu) parentModel;
                type = WidgetType.MenuItem;
                isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
            } else if (parentModel instanceof MenuHeader) {
                // and hide children of the previous header
                if (isRightPotentialFigure) {
                    type = WidgetType.Menu;
                    ((GraphicalParentWidget<?, ?>) parent).closeChildren();
                    group = parentModel.getParentGroup();
                } else {
                    header = (MenuHeader) parentModel;
                    type = WidgetType.MenuItem;
                    isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
                }
            } else if (parentModel instanceof PullDownItem) {
                type = WidgetType.PullDownItem;
                if (!isRightPotentialFigure) {
                    PullDownItem parentItem = (PullDownItem) parentModel;
                    header = parentItem.getParent();
                    isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
                }
            } else if (parentModel instanceof PullDownHeader) {
                type = WidgetType.PullDownItem;
                if (!isRightPotentialFigure) {
                    header = (PullDownHeader) parentModel;
                    isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
                }
            } else if (parentModel instanceof ListItem) {
                type = WidgetType.ListBoxItem;
                group = parentModel.getParentGroup();
                isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
            } else if (parentModel instanceof GridButton) {
                type = parentModel.getWidgetType();
                group = parentModel.getParentGroup();
            }
            Rectangle r = ((PotentialFigure) figure).getUnscaledBounds();
            DoubleRectangle bounds = new DoubleRectangle(r.x, r.y, r.width, r.height);
            performAction(CogToolLID.NewWidget, new FrameEditorUI.NewWidgetParameters(bounds, header, type, view.isAutomaticCreation(), newTitle, group, isSeparator));
        } else {
            boolean isSeparator = GraphicalWidgetRenderer.SEPARATOR_STRING.equals(newTitle);
            performAction(FrameEditorLID.ChangeTitleProperty, new FrameEditorUI.ActionStringParameters(newTitle, selection, isSeparator), true);
        }
    }
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) GraphicalMenuHeader(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalMenuHeader) Rectangle(org.eclipse.draw2d.geometry.Rectangle) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) MenuItem(edu.cmu.cs.hcii.cogtool.model.MenuItem) ContextMenu(edu.cmu.cs.hcii.cogtool.model.ContextMenu) GraphicalContextMenu(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalContextMenu) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget) PullDownHeader(edu.cmu.cs.hcii.cogtool.model.PullDownHeader) DoubleRectangle(edu.cmu.cs.hcii.cogtool.model.DoubleRectangle) PotentialFigure(edu.cmu.cs.hcii.cogtool.view.PotentialFigure) TraversableWidget(edu.cmu.cs.hcii.cogtool.model.TraversableWidget) GraphicalTraversableWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalTraversableWidget) GraphicalGridButton(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalGridButton) GridButton(edu.cmu.cs.hcii.cogtool.model.GridButton) PullDownItem(edu.cmu.cs.hcii.cogtool.model.PullDownItem) GraphicalListItem(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalListItem) ListItem(edu.cmu.cs.hcii.cogtool.model.ListItem) WidgetType(edu.cmu.cs.hcii.cogtool.model.WidgetType) GraphicalParentWidget(edu.cmu.cs.hcii.cogtool.uimodel.GraphicalParentWidget) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)14 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)8 SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)4 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)3 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)3 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)3 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)2 ActionType (edu.cmu.cs.hcii.cogtool.model.ActionType)2 ContextMenu (edu.cmu.cs.hcii.cogtool.model.ContextMenu)2 DeviceType (edu.cmu.cs.hcii.cogtool.model.DeviceType)2 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)2 MenuHeader (edu.cmu.cs.hcii.cogtool.model.MenuHeader)2 PullDownHeader (edu.cmu.cs.hcii.cogtool.model.PullDownHeader)2 PullDownItem (edu.cmu.cs.hcii.cogtool.model.PullDownItem)2 RadioButtonGroup (edu.cmu.cs.hcii.cogtool.model.RadioButtonGroup)2 Iterator (java.util.Iterator)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 Button (org.eclipse.swt.widgets.Button)2 Node (org.w3c.dom.Node)2 AAction (edu.cmu.cs.hcii.cogtool.model.AAction)1