Search in sources :

Example 11 with IAction

use of org.eclipse.scout.rt.client.ui.action.IAction 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 12 with IAction

use of org.eclipse.scout.rt.client.ui.action.IAction 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)

Example 13 with IAction

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

the class JsonAction method initJsonProperties.

@Override
protected void initJsonProperties(ACTION model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_TEXT, model) {

        @Override
        protected String modelValue() {
            return getModel().getText();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_ICON_ID, model) {

        @Override
        protected String modelValue() {
            return getModel().getIconId();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return BinaryResourceUrlUtility.createIconUrl((String) value);
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_TOOLTIP_TEXT, model) {

        @Override
        protected String modelValue() {
            return getModel().getTooltipText();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>("toggleAction", model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isToggleAction();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_SELECTED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isSelected();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isVisible();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_KEY_STROKE, model) {

        @Override
        protected String modelValue() {
            return getModel().getKeyStroke();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_KEYSTROKE_FIRE_POLICY, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getKeyStrokeFirePolicy();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_HORIZONTAL_ALIGNMENT, model) {

        @Override
        protected Integer modelValue() {
            return (int) getModel().getHorizontalAlignment();
        }
    });
    putJsonProperty(new JsonProperty<ACTION>(IAction.PROP_CSS_CLASS, model) {

        @Override
        protected String modelValue() {
            return getModel().getCssClass();
        }
    });
    putJsonProperty(new JsonAdapterProperty<ACTION>(IActionNode.PROP_CHILD_ACTIONS, model, getUiSession()) {

        @Override
        protected JsonAdapterPropertyConfig createConfig() {
            return new JsonAdapterPropertyConfigBuilder().filter(new DisplayableActionFilter<IAction>()).build();
        }

        @Override
        protected Object modelValue() {
            if (getModel() instanceof IActionNode) {
                return ((IActionNode) getModel()).getChildActions();
            }
            return null;
        }
    });
}
Also used : JsonAdapterPropertyConfig(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig) IAction(org.eclipse.scout.rt.client.ui.action.IAction) IActionNode(org.eclipse.scout.rt.client.ui.action.tree.IActionNode) JsonAdapterPropertyConfigBuilder(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder) JSONObject(org.json.JSONObject)

Aggregations

IAction (org.eclipse.scout.rt.client.ui.action.IAction)13 IActionVisitor (org.eclipse.scout.rt.client.ui.action.IActionVisitor)8 IMenu (org.eclipse.scout.rt.client.ui.action.menu.IMenu)8 ArrayList (java.util.ArrayList)5 JsonAdapterPropertyConfig (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig)3 JsonAdapterPropertyConfigBuilder (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder)3 JSONObject (org.json.JSONObject)3 List (java.util.List)2 ITable (org.eclipse.scout.rt.client.ui.basic.table.ITable)2 ITree (org.eclipse.scout.rt.client.ui.basic.tree.ITree)2 ResourceListTransferObject (org.eclipse.scout.rt.client.ui.dnd.ResourceListTransferObject)2 LinkedList (java.util.LinkedList)1 DeepLinkException (org.eclipse.scout.rt.client.deeplink.DeepLinkException)1 IDeviceTransformationService (org.eclipse.scout.rt.client.transformation.IDeviceTransformationService)1 IEventHistory (org.eclipse.scout.rt.client.ui.IEventHistory)1 ActionFinder (org.eclipse.scout.rt.client.ui.action.ActionFinder)1 IActionFilter (org.eclipse.scout.rt.client.ui.action.IActionFilter)1 IKeyStroke (org.eclipse.scout.rt.client.ui.action.keystroke.IKeyStroke)1 IContextMenu (org.eclipse.scout.rt.client.ui.action.menu.root.IContextMenu)1 IActionNode (org.eclipse.scout.rt.client.ui.action.tree.IActionNode)1