Search in sources :

Example 1 with IAction

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

the class FormFieldContextMenu method handleOwnerEnabledChanged.

protected void handleOwnerEnabledChanged() {
    T container = getContainer();
    if (container == null) {
        return;
    }
    final boolean enabled = container.isEnabledIncludingParents();
    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)

Example 2 with IAction

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

the class AbstractContextMenu method calculateLocalVisibility.

protected void calculateLocalVisibility() {
    final IActionFilter activeFilter = ActionUtility.createMenuFilterMenuTypes(getCurrentMenuTypes(), true);
    if (activeFilter != null) {
        final BooleanHolder visibleHolder = new BooleanHolder(false);
        acceptVisitor(new IActionVisitor() {

            @Override
            public int visit(IAction action) {
                if (action instanceof IMenu) {
                    IMenu menu = (IMenu) action;
                    if (menu.hasChildActions() || menu.isSeparator() || menu instanceof IContextMenu) {
                        return CONTINUE;
                    } else if (activeFilter.accept(menu)) {
                        visibleHolder.setValue(true);
                        return CANCEL;
                    }
                }
                return CONTINUE;
            }
        });
        setVisible(visibleHolder.getValue());
    }
}
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) IActionFilter(org.eclipse.scout.rt.client.ui.action.IActionFilter) BooleanHolder(org.eclipse.scout.rt.platform.holders.BooleanHolder)

Example 3 with IAction

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

the class MenuUtility method getMenuByClass.

/**
 * @return the sub-menu of the given context menu owner that implements the given type. If no implementation is found,
 *         <code>null</code> is returned. Note: This method uses instance-of checks, hence the menu replacement
 *         mapping is not required.
 * @throws IllegalStateException
 *           when more than one menu implements the given type
 * @throws IllegalArgumentException
 *           when no context menu owner is provided.
 */
public static <T extends IMenu> T getMenuByClass(IContextMenuOwner contextMenuOwner, final Class<T> menuType) {
    if (contextMenuOwner == null) {
        throw new IllegalArgumentException("Argument 'contextMenuOwner' must not be null");
    }
    IContextMenu contextMenu = contextMenuOwner.getContextMenu();
    if (contextMenu == null || menuType == null) {
        return null;
    }
    final List<T> collectedMenus = new ArrayList<T>();
    contextMenu.acceptVisitor(new IActionVisitor() {

        @Override
        public int visit(IAction action) {
            if (menuType.isInstance(action)) {
                T menu = menuType.cast(action);
                collectedMenus.add(menu);
            }
            return CONTINUE;
        }
    });
    if (collectedMenus.isEmpty()) {
        return null;
    }
    if (collectedMenus.size() == 1) {
        return collectedMenus.get(0);
    }
    throw new IllegalStateException("Ambiguous menu type " + menuType.getName() + "! More than one implementation was found: " + CollectionUtility.format(collectedMenus));
}
Also used : IActionVisitor(org.eclipse.scout.rt.client.ui.action.IActionVisitor) IAction(org.eclipse.scout.rt.client.ui.action.IAction) IContextMenu(org.eclipse.scout.rt.client.ui.action.menu.root.IContextMenu) ArrayList(java.util.ArrayList)

Example 4 with IAction

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

the class JsonTable method initJsonProperties.

@Override
protected void initJsonProperties(T model) {
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_ENABLED, model) {

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

        @Override
        protected Boolean modelValue() {
            return getModel().isMultiSelect();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTI_CHECK, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isMultiCheck();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_MULTILINE_TEXT, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isMultilineText();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CHECKABLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isCheckable();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_ROW_ICON_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isRowIconVisible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_HEADER_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isHeaderVisible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_HEADER_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isHeaderEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_KEYBOARD_NAVIGATION, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().hasKeyboardNavigation();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_AUTO_RESIZE_COLUMNS, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isAutoResizeColumns();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_SCROLL_TO_SELECTION, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isScrollToSelection();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_TABLE_STATUS_VISIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isTableStatusVisible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_TABLE_STATUS, model) {

        @Override
        protected IStatus modelValue() {
            return getModel().getTableStatus();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return JsonStatus.toJson((IStatus) value);
        }
    });
    putJsonProperty(new JsonAdapterProperty<ITable>(ITable.PROP_TABLE_CONTROLS, model, getUiSession()) {

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

        @Override
        protected List<ITableControl> modelValue() {
            return getModel().getTableControls();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_DROP_TYPE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getDropType();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_DROP_MAXIMUM_SIZE, model) {

        @Override
        protected Long modelValue() {
            return getModel().getDropMaximumSize();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_SORT_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isSortEnabled();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_UI_SORT_POSSIBLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isUiSortPossible();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_LOADING, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isLoading();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_GROUPING_STYLE, model) {

        @Override
        protected GroupingStyle modelValue() {
            return getModel().getGroupingStyle();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            return ((GroupingStyle) value).name().toLowerCase();
        }
    });
    putJsonProperty(new JsonAdapterProperty<ITable>(ITable.PROP_KEY_STROKES, model, getUiSession()) {

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

        @Override
        protected List<IKeyStroke> modelValue() {
            return getModel().getKeyStrokes();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CSS_CLASS, model) {

        @Override
        protected String modelValue() {
            return getModel().getCssClass();
        }
    });
    putJsonProperty(new JsonProperty<ITable>(ITable.PROP_CONTEXT_COLUMN, model) {

        @Override
        protected Object modelValue() {
            return getModel().getContextColumn();
        }

        @Override
        public Object prepareValueForToJson(Object value) {
            if (value == null) {
                return null;
            }
            return m_jsonColumns.get(value).getId();
        }
    });
}
Also used : IStatus(org.eclipse.scout.rt.platform.status.IStatus) JsonAdapterPropertyConfig(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITableControl(org.eclipse.scout.rt.client.ui.basic.table.controls.ITableControl) JsonAdapterPropertyConfigBuilder(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder) ITable(org.eclipse.scout.rt.client.ui.basic.table.ITable) TextTransferObject(org.eclipse.scout.rt.client.ui.dnd.TextTransferObject) ResourceListTransferObject(org.eclipse.scout.rt.client.ui.dnd.ResourceListTransferObject) JSONObject(org.json.JSONObject) TransferObject(org.eclipse.scout.rt.client.ui.dnd.TransferObject) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) GroupingStyle(org.eclipse.scout.rt.client.ui.basic.table.GroupingStyle)

Example 5 with IAction

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

the class JsonTree method initJsonProperties.

@Override
protected void initJsonProperties(TREE model) {
    super.initJsonProperties(model);
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_TITLE, model) {

        @Override
        protected String modelValue() {
            return getModel().getTitle();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.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<TREE>(ITree.PROP_CSS_CLASS, model) {

        @Override
        protected String modelValue() {
            return getModel().getCssClass();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_CHECKABLE, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isCheckable();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_MULTI_CHECK, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isMultiCheck();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isEnabled();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_LAZY_EXPANDING_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isLazyExpandingEnabled();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_AUTO_CHECK_CHILDREN, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isAutoCheckChildNodes();
        }
    });
    putJsonProperty(new JsonProperty<ITree>(ITree.PROP_SCROLL_TO_SELECTION, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isScrollToSelection();
        }
    });
    putJsonProperty(new JsonProperty<ITree>(ITree.PROP_DROP_TYPE, model) {

        @Override
        protected Integer modelValue() {
            return getModel().getDropType();
        }
    });
    putJsonProperty(new JsonProperty<ITree>(ITree.PROP_DROP_MAXIMUM_SIZE, model) {

        @Override
        protected Long modelValue() {
            return getModel().getDropMaximumSize();
        }
    });
    putJsonProperty(new JsonAdapterProperty<ITree>(ITree.PROP_KEY_STROKES, model, getUiSession()) {

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

        @Override
        protected List<IKeyStroke> modelValue() {
            return getModel().getKeyStrokes();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_DISPLAY_STYLE, model) {

        @Override
        protected String modelValue() {
            return getModel().getDisplayStyle();
        }
    });
    putJsonProperty(new JsonProperty<TREE>(ITree.PROP_TOGGLE_BREADCRUMB_STYLE_ENABLED, model) {

        @Override
        protected Boolean modelValue() {
            return getModel().isToggleBreadcrumbStyleEnabled();
        }
    });
}
Also used : JsonAdapterPropertyConfig(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfig) IAction(org.eclipse.scout.rt.client.ui.action.IAction) ITree(org.eclipse.scout.rt.client.ui.basic.tree.ITree) JsonAdapterPropertyConfigBuilder(org.eclipse.scout.rt.ui.html.json.form.fields.JsonAdapterPropertyConfigBuilder) ResourceListTransferObject(org.eclipse.scout.rt.client.ui.dnd.ResourceListTransferObject) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) List(java.util.List)

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