Search in sources :

Example 1 with IActionNode

use of org.eclipse.scout.rt.client.ui.action.tree.IActionNode 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)1 IActionNode (org.eclipse.scout.rt.client.ui.action.tree.IActionNode)1 JsonAdapterPropertyConfig (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig)1 JsonAdapterPropertyConfigBuilder (org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder)1 JSONObject (org.json.JSONObject)1