Search in sources :

Example 6 with IActionVisitor

use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.

the class TreeContextMenu method handleOwnerEnabledChanged.

protected void handleOwnerEnabledChanged() {
    ITree container = getContainer();
    if (container != null) {
        final boolean enabled = container.isEnabled();
        acceptVisitor(new IActionVisitor() {

            @Override
            public int visit(IAction action) {
                if (action instanceof IMenu) {
                    IMenu menu = (IMenu) action;
                    if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
                        menu.setEnabledInheritAccessibility(enabled);
                    }
                }
                return CONTINUE;
            }
        });
    }
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree)

Example 7 with IActionVisitor

use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.

the class TreeContextMenu method calculateEnableState.

/**
 * @param ownerSelection
 */
protected void calculateEnableState(Collection<? extends ITreeNode> ownerSelection) {
    boolean enabled = true;
    for (ITreeNode node : ownerSelection) {
        if (!node.isEnabled()) {
            enabled = false;
            break;
        }
    }
    final boolean inheritedEnability = enabled;
    acceptVisitor(new IActionVisitor() {

        @Override
        public int visit(IAction action) {
            if (action instanceof IMenu) {
                IMenu menu = (IMenu) action;
                if (!menu.hasChildActions() && menu.isInheritAccessibility()) {
                    menu.setEnabledInheritAccessibility(inheritedEnability);
                }
            }
            return CONTINUE;
        }
    });
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IMenu(org.eclipse.scout.rt.client.ui.action.menu.IMenu) ITreeNode(org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode) IAction(org.eclipse.scout.rt.client.ui.action.IAction)

Example 8 with IActionVisitor

use of org.eclipse.scout.rt.client.ui.action.IActionVisitor in project scout.rt by eclipse.

the class AbstractMenu method afterChildMenusAdd.

protected void afterChildMenusAdd(Collection<? extends IMenu> newChildMenus) {
    if (CollectionUtility.hasElements(newChildMenus)) {
        final Object ownerValue = m_ownerValue;
        IActionVisitor visitor = new IActionVisitor() {

            @Override
            public int visit(IAction action) {
                if (action instanceof IMenu) {
                    IMenu menu = (IMenu) action;
                    try {
                        if (ObjectUtility.notEquals(menu.getOwnerValue(), ownerValue)) {
                            menu.handleOwnerValueChanged(ownerValue);
                        }
                    } catch (RuntimeException e) {
                        LOG.error("error during handle owner value changed.", e);
                    }
                }
                return CONTINUE;
            }
        };
        for (IMenu m : newChildMenus) {
            m.acceptVisitor(visitor);
        }
    }
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IAction(org.eclipse.scout.rt.client.ui.action.IAction)

Aggregations

IAction (org.eclipse.scout.rt.client.ui.action.IAction)8 IActionVisitor (org.eclipse.scout.rt.client.ui.action.IActionVisitor)8 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)6 ArrayList (java.util.ArrayList)1 IActionFilter (org.eclipse.scout.rt.client.ui.action.IActionFilter)1 IContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IContextMenu)1 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)1 ITableRow (org.eclipse.scout.rt.client.ui.basic.table.ITableRow)1 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)1 ITreeNode (org.eclipse.scout.rt.client.ui.basic.tree.ITreeNode)1 BooleanHolder (org.eclipse.scout.rt.platform.holders.BooleanHolder)1