Search in sources :

Example 41 with CompiledObjectCollectionView

use of com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView in project midpoint by Evolveum.

the class LeftMenuPanel method addCollectionsMenuItems.

private void addCollectionsMenuItems(MainMenuItem mainMenuItem, QName type, Class<? extends PageBase> redirectToPage) {
    List<CompiledObjectCollectionView> objectViews = getPageBase().getCompiledGuiProfile().findAllApplicableObjectCollectionViews(type);
    objectViews.forEach(objectView -> {
        if (!WebComponentUtil.getElementVisibility(objectView.getVisibility())) {
            return;
        }
        OperationTypeType operationTypeType = objectView.getApplicableForOperation();
        if (operationTypeType != null && operationTypeType != OperationTypeType.MODIFY) {
            return;
        }
        if (objectView.getCollection() == null) {
            return;
        }
        DisplayType viewDisplayType = objectView.getDisplay();
        PageParameters pageParameters = new PageParameters();
        pageParameters.add(PageBase.PARAMETER_OBJECT_COLLECTION_NAME, objectView.getViewIdentifier());
        String label = "MenuItem.noName";
        PolyStringType display = WebComponentUtil.getCollectionLabel(viewDisplayType);
        if (display != null) {
            label = WebComponentUtil.getTranslatedPolyString(display);
        }
        String iconClass = WebComponentUtil.getIconCssClass(viewDisplayType);
        MenuItem userViewMenu = new MenuItem(label, StringUtils.isEmpty(iconClass) ? BaseMenuItem.DEFAULT_ICON : iconClass, redirectToPage, pageParameters, isObjectCollectionMenuActive(objectView));
        userViewMenu.setDisplayOrder(objectView.getDisplayOrder());
        mainMenuItem.addCollectionMenuItem(userViewMenu);
    });
// We need to sort after we get all the collections. Only then we have correct collection labels.
// We do not want to determine the labels twice.
// TODO: can this be combined in a single sort?
// collectionMenuItems.sort(Comparator.comparing(o -> o.getNameModel().getObject()));
// collectionMenuItems.sort(Comparator.comparingInt(o -> ObjectUtils.defaultIfNull(o.getDisplayOrder(), Integer.MAX_VALUE)));
// return collectionMenuItems;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters)

Aggregations

CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)41 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)14 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)13 WebPage (org.apache.wicket.markup.html.WebPage)8 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)6 ArrayList (java.util.ArrayList)6 MultiCompositedButtonPanel (com.evolveum.midpoint.web.component.MultiCompositedButtonPanel)5 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)5 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)5 MultiFunctinalButtonDto (com.evolveum.midpoint.web.component.MultiFunctinalButtonDto)4 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)4 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)3 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)3 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)3 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)3 Form (org.apache.wicket.markup.html.form.Form)3