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