use of edu.cmu.cs.hcii.cogtool.ui.SEDemoLID.SEDemoTransitionLID 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