Search in sources :

Example 1 with SEDemoTransitionLID

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);
    }
}
Also used : MenuHeader(edu.cmu.cs.hcii.cogtool.model.MenuHeader) SimpleMenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition) ContextMenu(edu.cmu.cs.hcii.cogtool.model.ContextMenu) PullDownHeader(edu.cmu.cs.hcii.cogtool.model.PullDownHeader) SimpleMenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition) MenuItemDefinition(edu.cmu.cs.hcii.cogtool.util.MenuUtil.MenuItemDefinition) SEDemoTransitionLID(edu.cmu.cs.hcii.cogtool.ui.SEDemoLID.SEDemoTransitionLID) Transition(edu.cmu.cs.hcii.cogtool.model.Transition) EventObject(java.util.EventObject) IWidget(edu.cmu.cs.hcii.cogtool.model.IWidget)

Aggregations

ContextMenu (edu.cmu.cs.hcii.cogtool.model.ContextMenu)1 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)1 MenuHeader (edu.cmu.cs.hcii.cogtool.model.MenuHeader)1 PullDownHeader (edu.cmu.cs.hcii.cogtool.model.PullDownHeader)1 Transition (edu.cmu.cs.hcii.cogtool.model.Transition)1 SEDemoTransitionLID (edu.cmu.cs.hcii.cogtool.ui.SEDemoLID.SEDemoTransitionLID)1 MenuItemDefinition (edu.cmu.cs.hcii.cogtool.util.MenuUtil.MenuItemDefinition)1 SimpleMenuItemDefinition (edu.cmu.cs.hcii.cogtool.util.MenuUtil.SimpleMenuItemDefinition)1 EventObject (java.util.EventObject)1