Search in sources :

Example 51 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class UserPersonasPanel method initLayout.

protected void initLayout() {
    MainObjectListPanel<UserType> userListPanel = new MainObjectListPanel<UserType>(ID_PERSONAS_TABLE, UserType.class, null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IColumn<SelectableBean<UserType>, String> createCheckboxColumn() {
            return null;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            List<InlineMenuItem> menuItems = new ArrayList<>();
            menuItems.add(new ButtonInlineMenuItem(createStringResource("AssignmentPanel.viewTargetObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_NAVIGATE_ARROW);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return new ColumnMenuAction<SelectableBeanImpl<UserType>>() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            SelectableBean<UserType> personaRefSelectableBean = getRowModel().getObject();
                            UserType personaRefObj = personaRefSelectableBean.getValue();
                            ObjectReferenceType ort = new ObjectReferenceType();
                            ort.setOid(personaRefObj.getOid());
                            ort.setType(WebComponentUtil.classToQName(UserPersonasPanel.this.getPrismContext(), personaRefObj.getClass()));
                            WebComponentUtil.dispatchToObjectDetailsPage(ort, UserPersonasPanel.this, false);
                        }
                    };
                }

                @Override
                public boolean isHeaderMenuItem() {
                    return false;
                }
            });
            return menuItems;
        }

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, UserType object) {
        }

        @Override
        protected boolean isCreateNewObjectEnabled() {
            return false;
        }

        @Override
        protected ISelectableDataProvider<UserType, SelectableBean<UserType>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> getFocusPersonasQuery(), null);
        }

        // @Override
        // protected ObjectQuery getCustomizeContentQuery() {
        // 
        // }
        @Override
        protected boolean isObjectDetailsEnabled(IModel<SelectableBean<UserType>> rowModel) {
            return false;
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return null;
        }

        @Override
        protected boolean enableSavePageSize() {
            return false;
        }
    };
    userListPanel.setOutputMarkupId(true);
    add(userListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 52 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class ObjectTemplateItemPanel method createAdditionalColumns.

@Override
protected List<IColumn<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>, String>> createAdditionalColumns() {
    List<IColumn<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>, String>> columns = new ArrayList<>();
    columns.add(new AbstractColumn<>(createStringResource("ObjectTemplateItemDefinitionType.mapping")) {

        @Override
        public void populateItem(Item<ICellPopulator<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>>> cellItem, String componentId, IModel<PrismContainerValueWrapper<ObjectTemplateItemDefinitionType>> rowModel) {
            IModel<PrismContainerWrapper<MappingType>> mappingModel = PrismContainerWrapperModel.fromContainerValueWrapper(rowModel, ObjectTemplateItemDefinitionType.F_MAPPING);
            cellItem.add(new MappingColumnPanel(componentId, mappingModel));
        }
    });
    List<InlineMenuItem> items = new ArrayList<>();
    InlineMenuItem item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete")) {

        private static final long serialVersionUID = 1L;

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    getMultivalueContainerListPanel().deleteItemPerformed(target, getMultivalueContainerListPanel().getPerformedSelectedItems(getRowModel()));
                }
            };
        }
    };
    items.add(item);
    item = new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    getMultivalueContainerListPanel().editItemPerformed(target, getRowModel(), getMultivalueContainerListPanel().getSelectedItems());
                    target.add(getMultivalueContainerListPanel().getFeedbackPanel());
                }
            };
        }
    };
    items.add(item);
    columns.add(new InlineMenuButtonColumn(items, getPageBase()) {

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    return columns;
}
Also used : MappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.MappingType) ObjectTemplateMappingType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateMappingType) IModel(org.apache.wicket.model.IModel) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) ArrayList(java.util.ArrayList) ObjectTemplateItemDefinitionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectTemplateItemDefinitionType) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) MappingColumnPanel(com.evolveum.midpoint.gui.impl.component.MappingColumnPanel) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 53 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class FocusProjectionsTabPanel method initBasicColumns.

private List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> initBasicColumns() {
    IModel<PrismContainerDefinition<ShadowType>> shadowDef = Model.of(getShadowDefinition());
    List<IColumn<PrismContainerValueWrapper<ShadowType>, String>> columns = new ArrayList<>();
    columns.add(new CheckBoxHeaderColumn<>());
    columns.add(new CompositedIconColumn<PrismContainerValueWrapper<ShadowType>>(Model.of("")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected CompositedIcon getCompositedIcon(IModel<PrismContainerValueWrapper<ShadowType>> rowModel) {
            if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getRealValue() == null) {
                return new CompositedIconBuilder().build();
            }
            ShadowType shadow = createShadowType(rowModel);
            return WebComponentUtil.createAccountIcon(shadow, getPageBase(), true);
        }
    });
    columns.add(new PrismPropertyWrapperColumn<ShadowType, String>(shadowDef, ShadowType.F_NAME, ColumnType.LINK, getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onClick(AjaxRequestTarget target, IModel<PrismContainerValueWrapper<ShadowType>> rowModel) {
            getMultivalueContainerListPanel().itemDetailsPerformed(target, rowModel);
            target.add(getFeedbackPanel());
        }
    });
    columns.add(new PrismReferenceWrapperColumn<>(shadowDef, ShadowType.F_RESOURCE_REF, ColumnType.STRING, getPageBase()));
    columns.add(new PrismPropertyWrapperColumn<ShadowType, String>(shadowDef, ShadowType.F_OBJECT_CLASS, ColumnType.STRING, getPageBase()));
    columns.add(new PrismPropertyWrapperColumn<ShadowType, String>(shadowDef, ShadowType.F_KIND, ColumnType.STRING, getPageBase()) {

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    columns.add(new PrismPropertyWrapperColumn<ShadowType, String>(shadowDef, ShadowType.F_INTENT, ColumnType.STRING, getPageBase()) {

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    columns.add(new PrismContainerWrapperColumn<ShadowType>(shadowDef, ShadowType.F_PENDING_OPERATION, getPageBase()) {

        @Override
        public String getCssClass() {
            return "col-xs-2";
        }

        @Override
        protected <IW extends ItemWrapper> Component createColumnPanel(String componentId, IModel<IW> rowModel) {
            IW object = rowModel.getObject();
            if (object == null) {
                return new WebMarkupContainer(componentId);
            }
            List<PrismValueWrapper<PendingOperationType>> values = object.getValues();
            List<PendingOperationType> pendingOperations = new ArrayList<>();
            values.forEach(value -> pendingOperations.add(value.getRealValue()));
            return new PendingOperationPanel(componentId, (IModel<List<PendingOperationType>>) () -> pendingOperations);
        }
    });
    columns.add(new InlineMenuButtonColumn(createShadowMenu(), getPageBase()) {

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    return columns;
}
Also used : Arrays(java.util.Arrays) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PrismContainerWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismContainerWrapperColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ResourceSchemaFactory(com.evolveum.midpoint.schema.processor.ResourceSchemaFactory) DisplayableValue(com.evolveum.midpoint.util.DisplayableValue) ItemStatus(com.evolveum.midpoint.gui.api.prism.ItemStatus) ShadowPanel(com.evolveum.midpoint.gui.impl.prism.panel.ShadowPanel) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) PrismReferenceWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismReferenceWrapperColumn) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) ReadOnlyModel(com.evolveum.midpoint.gui.api.model.ReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) ListItem(org.apache.wicket.markup.html.list.ListItem) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) ConfirmationPanel(com.evolveum.midpoint.web.component.dialog.ConfirmationPanel) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) ProjectionsListProvider(com.evolveum.midpoint.web.component.util.ProjectionsListProvider) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Task(com.evolveum.midpoint.task.api.Task) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) PageAdminFocus(com.evolveum.midpoint.web.page.admin.PageAdminFocus) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) List(java.util.List) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) DeleteConfirmationPanel(com.evolveum.midpoint.web.component.dialog.DeleteConfirmationPanel) PropertyModel(org.apache.wicket.model.PropertyModel) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) PrismObjectWrapperFactory(com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory) QName(javax.xml.namespace.QName) PendingOperationPanel(com.evolveum.midpoint.gui.api.component.PendingOperationPanel) NotNull(org.jetbrains.annotations.NotNull) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) DisplayNamePanel(com.evolveum.midpoint.gui.api.component.DisplayNamePanel) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) com.evolveum.midpoint.web.component.search(com.evolveum.midpoint.web.component.search) SchemaConstants(com.evolveum.midpoint.schema.constants.SchemaConstants) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) BooleanUtils(org.apache.commons.lang3.BooleanUtils) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) Trace(com.evolveum.midpoint.util.logging.Trace) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ArrayList(java.util.ArrayList) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) PageStorage(com.evolveum.midpoint.web.session.PageStorage) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) TableId(com.evolveum.midpoint.web.session.UserProfileStorage.TableId) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) Popupable(com.evolveum.midpoint.web.component.dialog.Popupable) ProjectionDisplayNamePanel(com.evolveum.midpoint.gui.impl.component.ProjectionDisplayNamePanel) PrismPropertyWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismPropertyWrapperColumn) UserDtoStatus(com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus) ResourceObjectTypeDefinition(com.evolveum.midpoint.schema.processor.ResourceObjectTypeDefinition) ColumnType(com.evolveum.midpoint.gui.impl.component.data.column.AbstractItemWrapperColumn.ColumnType) LoggingUtils(com.evolveum.midpoint.util.logging.LoggingUtils) ISelectableDataProvider(com.evolveum.midpoint.web.component.data.ISelectableDataProvider) Validate(org.apache.commons.lang3.Validate) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) com.evolveum.midpoint.gui.api.prism.wrapper(com.evolveum.midpoint.gui.api.prism.wrapper) ResourceSchema(com.evolveum.midpoint.schema.processor.ResourceSchema) CompositedIconColumn(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconColumn) ObjectBrowserPanel(com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) ArrayList(java.util.ArrayList) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PendingOperationPanel(com.evolveum.midpoint.gui.api.component.PendingOperationPanel) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) List(java.util.List) ArrayList(java.util.ArrayList) Component(org.apache.wicket.Component) IModel(org.apache.wicket.model.IModel) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)

Example 54 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class FocusPersonasTabPanel method initLayout.

private void initLayout() {
    MainObjectListPanel<F> userListPanel = new MainObjectListPanel<F>(ID_PERSONAS_TABLE, (Class<F>) FocusType.class, null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IColumn<SelectableBean<F>, String> createCheckboxColumn() {
            return null;
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            List<InlineMenuItem> menuItems = new ArrayList<>();
            menuItems.add(new ButtonInlineMenuItem(createStringResource("AssignmentPanel.viewTargetObject")) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_NAVIGATE_ARROW);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return new ColumnMenuAction<SelectableBeanImpl<F>>() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClick(AjaxRequestTarget target) {
                            SelectableBean<F> personaRefSelectableBean = getRowModel().getObject();
                            F personaRefObj = personaRefSelectableBean.getValue();
                            ObjectReferenceType ort = new ObjectReferenceType();
                            ort.setOid(personaRefObj.getOid());
                            ort.setType(WebComponentUtil.classToQName(FocusPersonasTabPanel.this.getPrismContext(), personaRefObj.getClass()));
                            WebComponentUtil.dispatchToObjectDetailsPage(ort, FocusPersonasTabPanel.this, false);
                        }
                    };
                }

                @Override
                public boolean isHeaderMenuItem() {
                    return false;
                }
            });
            return menuItems;
        }

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, F object) {
        }

        @Override
        protected boolean isCreateNewObjectEnabled() {
            return false;
        }

        @Override
        protected ISelectableDataProvider<F, SelectableBean<F>> createProvider() {
            return createSelectableBeanObjectDataProvider(() -> getFocusPersonasQuery(), null);
        }

        // @Override
        // protected ObjectQuery getCustomizeContentQuery() {
        // 
        // }
        @Override
        protected boolean isObjectDetailsEnabled(IModel<SelectableBean<F>> rowModel) {
            return false;
        }

        @Override
        protected UserProfileStorage.TableId getTableId() {
            return null;
        }

        @Override
        protected boolean enableSavePageSize() {
            return false;
        }
    };
    userListPanel.setOutputMarkupId(true);
    add(userListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) SelectableBeanImpl(com.evolveum.midpoint.web.component.util.SelectableBeanImpl) ArrayList(java.util.ArrayList) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) FocusType(com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Example 55 with CompositedIconBuilder

use of com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder in project midpoint by Evolveum.

the class AssignmentPanel method getAssignmentMenuActions.

private <AH extends FocusType> List<InlineMenuItem> getAssignmentMenuActions() {
    List<InlineMenuItem> menuItems = new ArrayList<>();
    PrismObject<AH> obj = getMultivalueContainerListPanel().getFocusObject();
    try {
        boolean isUnassignAuthorized = getParentPage().isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_UNASSIGN_ACTION_URI, AuthorizationPhaseType.REQUEST, obj, null, null, null);
        if (isUnassignAuthorized) {
            menuItems.add(new ButtonInlineMenuItem(getAssignmentsLimitReachedUnassignTitleModel()) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return getMultivalueContainerListPanel().createDeleteColumnAction();
                }
            });
        }
    } catch (Exception ex) {
        LOGGER.error("Couldn't check unassign authorization for the object: {}, {}", obj.getName(), ex.getLocalizedMessage());
        if (WebComponentUtil.isAuthorized(AuthorizationConstants.AUTZ_UI_ADMIN_ASSIGN_ACTION_URI)) {
            menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.unassign")) {

                private static final long serialVersionUID = 1L;

                @Override
                public CompositedIconBuilder getIconCompositedBuilder() {
                    return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_DELETE_MENU_ITEM);
                }

                @Override
                public InlineMenuItemAction initAction() {
                    return getMultivalueContainerListPanel().createDeleteColumnAction();
                }
            });
        }
    }
    menuItems.add(new ButtonInlineMenuItem(createStringResource("PageBase.button.edit")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_EDIT_MENU_ITEM);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return getMultivalueContainerListPanel().createEditColumnAction();
        }
    });
    ButtonInlineMenuItem menu = new ButtonInlineMenuItem(createStringResource("AssignmentPanel.viewTargetObject")) {

        private static final long serialVersionUID = 1L;

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            return getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_NAVIGATE_ARROW);
        }

        @Override
        public InlineMenuItemAction initAction() {
            return new ColumnMenuAction<PrismContainerValueWrapper<AssignmentType>>() {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    PrismContainerValueWrapper<AssignmentType> assignmentContainer = getRowModel().getObject();
                    PrismReferenceWrapper<ObjectReferenceType> targetRef;
                    try {
                        targetRef = assignmentContainer.findReference(ItemPath.create(AssignmentType.F_TARGET_REF));
                    } catch (SchemaException e) {
                        getSession().error("Couldn't show details page. More information provided in log.");
                        LOGGER.error("Couldn't show details page, no targetRef reference wrapper found: {}", e.getMessage(), e);
                        target.add(getPageBase().getFeedbackPanel());
                        return;
                    }
                    if (targetRef != null && targetRef.getValues() != null && targetRef.getValues().size() > 0) {
                        PrismReferenceValueWrapperImpl<ObjectReferenceType> refWrapper = targetRef.getValues().get(0);
                        if (!StringUtils.isEmpty(refWrapper.getNewValue().getOid())) {
                            Class<? extends ObjectType> targetClass = ObjectTypes.getObjectTypeFromTypeQName(refWrapper.getRealValue().getType()).getClassDefinition();
                            WebComponentUtil.dispatchToObjectDetailsPage(targetClass, refWrapper.getNewValue().getOid(), AssignmentPanel.this, false);
                        }
                    }
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    };
    menu.setVisibilityChecker((InlineMenuItem.VisibilityChecker) (rowModel, isHeader) -> {
        PrismContainerValueWrapper<AssignmentType> assignment = (PrismContainerValueWrapper<AssignmentType>) rowModel.getObject();
        if (assignment == null) {
            return false;
        }
        PrismReferenceWrapper<Referencable> target = null;
        try {
            target = assignment.findReference(AssignmentType.F_TARGET_REF);
        } catch (Exception e) {
            LOGGER.error("Couldn't find targetRef in assignment");
        }
        return target != null && !target.isEmpty();
    });
    menuItems.add(menu);
    return menuItems;
}
Also used : PrismContainerWrapperModel(com.evolveum.midpoint.web.model.PrismContainerWrapperModel) VisibleBehaviour(com.evolveum.midpoint.web.component.util.VisibleBehaviour) PrismContainerWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PrismContainerWrapperColumn(com.evolveum.midpoint.gui.impl.component.data.column.PrismContainerWrapperColumn) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) AuthorizationConstants(com.evolveum.midpoint.security.api.AuthorizationConstants) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AssignmentCandidatesSpecification(com.evolveum.midpoint.model.api.AssignmentCandidatesSpecification) StringUtils(org.apache.commons.lang3.StringUtils) AjaxLinkColumn(com.evolveum.midpoint.web.component.data.column.AjaxLinkColumn) QNameUtil(com.evolveum.midpoint.util.QNameUtil) AbstractColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn) WebModelServiceUtils(com.evolveum.midpoint.gui.api.util.WebModelServiceUtils) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) IModel(org.apache.wicket.model.IModel) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) Search(com.evolveum.midpoint.web.component.search.Search) com.evolveum.midpoint.prism(com.evolveum.midpoint.prism) Label(org.apache.wicket.markup.html.basic.Label) AjaxIconButton(com.evolveum.midpoint.web.component.AjaxIconButton) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus) ListItem(org.apache.wicket.markup.html.list.ListItem) Collection(java.util.Collection) CompositedIcon(com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon) SearchFactory(com.evolveum.midpoint.web.component.search.SearchFactory) Model(org.apache.wicket.model.Model) Component(org.apache.wicket.Component) WebComponentUtil(com.evolveum.midpoint.gui.api.util.WebComponentUtil) Task(com.evolveum.midpoint.task.api.Task) SessionStorage(com.evolveum.midpoint.web.session.SessionStorage) MultivalueContainerListPanelWithDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerListPanelWithDetailsPanel) List(java.util.List) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) AssignmentListProvider(com.evolveum.midpoint.web.component.util.AssignmentListProvider) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PropertyModel(org.apache.wicket.model.PropertyModel) Item(org.apache.wicket.markup.repeater.Item) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) MultivalueContainerDetailsPanel(com.evolveum.midpoint.gui.impl.component.MultivalueContainerDetailsPanel) AssignmentPopup(com.evolveum.midpoint.gui.api.component.AssignmentPopup) SearchItemDefinition(com.evolveum.midpoint.web.component.search.SearchItemDefinition) QName(javax.xml.namespace.QName) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) NotNull(org.jetbrains.annotations.NotNull) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) PrismReferenceValueWrapperImpl(com.evolveum.midpoint.gui.impl.prism.wrapper.PrismReferenceValueWrapperImpl) AssignmentPopupDto(com.evolveum.midpoint.gui.api.component.AssignmentPopupDto) GuiDisplayTypeUtil(com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil) RefFilter(com.evolveum.midpoint.prism.query.RefFilter) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) IconCssStyle(com.evolveum.midpoint.gui.impl.component.icon.IconCssStyle) Trace(com.evolveum.midpoint.util.logging.Trace) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) GuiStyleConstants(com.evolveum.midpoint.gui.api.GuiStyleConstants) PageStorage(com.evolveum.midpoint.web.session.PageStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) InlineMenuButtonColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn) PrismReferenceWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) BasePanel(com.evolveum.midpoint.gui.api.component.BasePanel) AssignmentObjectRelation(com.evolveum.midpoint.model.api.AssignmentObjectRelation) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) AssignmentsDetailsPanel(com.evolveum.midpoint.gui.impl.component.AssignmentsDetailsPanel) ObjectTypes(com.evolveum.midpoint.schema.constants.ObjectTypes) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) CompositedIconColumn(com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconColumn) Collections(java.util.Collections) TraceManager(com.evolveum.midpoint.util.logging.TraceManager) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ArrayList(java.util.ArrayList) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) PrismReferenceWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismReferenceWrapper) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) CompositedIconBuilder(com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) PrismContainerValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)

Aggregations

CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)57 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)32 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)26 InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)26 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)26 ArrayList (java.util.ArrayList)26 IModel (org.apache.wicket.model.IModel)17 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)11 CompositedIconButtonDto (com.evolveum.midpoint.web.component.CompositedIconButtonDto)9 VisibleBehaviour (com.evolveum.midpoint.web.component.util.VisibleBehaviour)9 AssignmentObjectRelation (com.evolveum.midpoint.model.api.AssignmentObjectRelation)7 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)7 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)7 SelectableBeanImpl (com.evolveum.midpoint.web.component.util.SelectableBeanImpl)7 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)6 CompositedIcon (com.evolveum.midpoint.gui.impl.component.icon.CompositedIcon)6 PrismContainerValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerValueWrapper)5 CompositedIconColumn (com.evolveum.midpoint.gui.impl.component.data.column.CompositedIconColumn)4 InlineMenuButtonColumn (com.evolveum.midpoint.web.component.data.column.InlineMenuButtonColumn)4 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)4