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);
}
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;
}
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;
}
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");
}
}
}
}
}
}
}
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;
}
Aggregations