Search in sources :

Example 1 with SimpleWidgetGroup

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

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

the class AbstractGraphicalParentWidget method selectChild.

protected GraphicalWidget<?> selectChild() {
    AParentWidget hdr = getModel();
    SimpleWidgetGroup childItems = hdr.getChildren();
    if ((childItems != null) && (childItems.size() > 0)) {
        return this.figureSpt.getWidgetFigure(childItems.get(0));
    }
    return null;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) AParentWidget(edu.cmu.cs.hcii.cogtool.model.AParentWidget)

Example 3 with SimpleWidgetGroup

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

the class FrameUIModel method getPrevInGroup.

public GraphicalWidget<?> getPrevInGroup(GraphicalWidget<?> fromWidgetFig) {
    IWidget modelWidget = fromWidgetFig.getModel();
    SimpleWidgetGroup group = modelWidget.getParentGroup();
    if (group != null) {
        int widgetIndex = group.indexOf(modelWidget);
        if (widgetIndex > 0) {
            return getWidgetFigure(group.get(widgetIndex - 1));
        }
    }
    return null;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with SimpleWidgetGroup

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

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

the class RendererSupport method isRadioSelected.

public static boolean isRadioSelected(IWidget attributed, DefaultSEUIModel attrOverride) {
    Object value = Boolean.FALSE;
    if (attrOverride == null) {
        value = attributed.getAttribute(WidgetAttributes.IS_SELECTED_ATTR);
        return ((Boolean) value).booleanValue();
    }
    boolean selected = false;
    SimpleWidgetGroup group = attributed.getParentGroup();
    Iterator<Object> overrides = attrOverride.getCurrentOverrides(group, WidgetAttributes.SELECTION_ATTR);
    if (overrides.hasNext()) {
        value = overrides.next();
        if (attributed.equals(value)) {
            selected = true;
        }
    }
    return selected;
}
Also used : SimpleWidgetGroup(edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)

Aggregations

SimpleWidgetGroup (edu.cmu.cs.hcii.cogtool.model.SimpleWidgetGroup)45 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)32 FrameElement (edu.cmu.cs.hcii.cogtool.model.FrameElement)16 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)14 AParentWidget (edu.cmu.cs.hcii.cogtool.model.AParentWidget)13 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)10 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)10 ChildWidget (edu.cmu.cs.hcii.cogtool.model.ChildWidget)9 HashSet (java.util.HashSet)8 TraversableWidget (edu.cmu.cs.hcii.cogtool.model.TraversableWidget)7 Point (org.eclipse.draw2d.geometry.Point)7 GridButtonGroup (edu.cmu.cs.hcii.cogtool.model.GridButtonGroup)6 ListItem (edu.cmu.cs.hcii.cogtool.model.ListItem)6 MenuHeader (edu.cmu.cs.hcii.cogtool.model.MenuHeader)6 Iterator (java.util.Iterator)6 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)5 ContextMenu (edu.cmu.cs.hcii.cogtool.model.ContextMenu)4 GridButton (edu.cmu.cs.hcii.cogtool.model.GridButton)4 Widget (edu.cmu.cs.hcii.cogtool.model.Widget)4 WidgetType (edu.cmu.cs.hcii.cogtool.model.WidgetType)4