Search in sources :

Example 1 with FocusListInlineMenuHelper

use of com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper in project midpoint by Evolveum.

the class PageRoles method initLayout.

protected void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<RoleType> table = new MainObjectListPanel<RoleType>(ID_TABLE, RoleType.class) {

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

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            FocusListInlineMenuHelper<RoleType> listInlineMenuHelper = new FocusListInlineMenuHelper<RoleType>(RoleType.class, PageRoles.this, this) {

                private static final long serialVersionUID = 1L;

                protected boolean isShowConfirmationDialog(ColumnMenuAction action) {
                    return PageRoles.this.isShowConfirmationDialog(action);
                }

                protected IModel<String> getConfirmationMessageModel(ColumnMenuAction action, String actionName) {
                    return PageRoles.this.getConfirmationMessageModel(action, actionName);
                }
            };
            return listInlineMenuHelper.createRowActions(getType());
        }

        // @Override
        // protected List<IColumn<SelectableBean<RoleType>, String>> createDefaultColumns() {
        // return ColumnUtils.getDefaultRoleColumns();
        // }
        @Override
        protected List<ItemPath> getFixedSearchItems() {
            List<ItemPath> fixedSearchItems = new ArrayList<>();
            fixedSearchItems.add(ObjectType.F_NAME);
            fixedSearchItems.add(AbstractRoleType.F_DISPLAY_NAME);
            fixedSearchItems.add(AbstractRoleType.F_IDENTIFIER);
            return fixedSearchItems;
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with FocusListInlineMenuHelper

use of com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper in project midpoint by Evolveum.

the class PageOrgs method initLayout.

protected void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<OrgType> table = new MainObjectListPanel<OrgType>(ID_TABLE, OrgType.class, getQueryOptions()) {

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

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            FocusListInlineMenuHelper<OrgType> listInlineMenuHelper = new FocusListInlineMenuHelper<OrgType>(OrgType.class, PageOrgs.this, this) {

                private static final long serialVersionUID = 1L;

                protected boolean isShowConfirmationDialog(ColumnMenuAction action) {
                    return PageOrgs.this.isShowConfirmationDialog(action);
                }

                protected IModel<String> getConfirmationMessageModel(ColumnMenuAction action, String actionName) {
                    return PageOrgs.this.getConfirmationMessageModel(action, actionName);
                }
            };
            return listInlineMenuHelper.createRowActions(getType());
        }

        @Override
        protected List<IColumn<SelectableBean<OrgType>, String>> createDefaultColumns() {
            return ColumnUtils.getDefaultOrgColumns(getPageBase());
        }

        @Override
        protected List<ItemPath> getFixedSearchItems() {
            List<ItemPath> fixedSearchItems = new ArrayList<>();
            fixedSearchItems.add(ObjectType.F_NAME);
            fixedSearchItems.add(AbstractRoleType.F_DISPLAY_NAME);
            fixedSearchItems.add(OrgType.F_PARENT_ORG_REF);
            return fixedSearchItems;
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 3 with FocusListInlineMenuHelper

use of com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper in project midpoint by Evolveum.

the class PageServices method initLayout.

protected void initLayout() {
    Form mainForm = new MidpointForm(ID_MAIN_FORM);
    add(mainForm);
    MainObjectListPanel<ServiceType> table = new MainObjectListPanel<ServiceType>(ID_TABLE, ServiceType.class) {

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

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            FocusListInlineMenuHelper<ServiceType> listInlineMenuHelper = new FocusListInlineMenuHelper<ServiceType>(ServiceType.class, PageServices.this, this) {

                private static final long serialVersionUID = 1L;

                protected boolean isShowConfirmationDialog(ColumnMenuAction action) {
                    return PageServices.this.isShowConfirmationDialog(action);
                }

                protected IModel<String> getConfirmationMessageModel(ColumnMenuAction action, String actionName) {
                    return PageServices.this.getConfirmationMessageModel(action, actionName);
                }
            };
            return listInlineMenuHelper.createRowActions(getType());
        }

        @Override
        protected List<ItemPath> getFixedSearchItems() {
            List<ItemPath> fixedSearchItems = new ArrayList<>();
            fixedSearchItems.add(ObjectType.F_NAME);
            fixedSearchItems.add(AbstractRoleType.F_DISPLAY_NAME);
            fixedSearchItems.add(AbstractRoleType.F_IDENTIFIER);
            return fixedSearchItems;
        }
    };
    table.setOutputMarkupId(true);
    mainForm.add(table);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) Form(org.apache.wicket.markup.html.form.Form) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) ArrayList(java.util.ArrayList) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) UserProfileStorage(com.evolveum.midpoint.web.session.UserProfileStorage) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) ColumnMenuAction(com.evolveum.midpoint.web.component.data.column.ColumnMenuAction) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 4 with FocusListInlineMenuHelper

use of com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper in project midpoint by Evolveum.

the class PageUsers method createRowActions.

private List<InlineMenuItem> createRowActions() {
    List<InlineMenuItem> menu = new ArrayList<>();
    ButtonInlineMenuItem enableItem = new ButtonInlineMenuItem(createStringResource("pageUsers.menu.enable")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        updateActivationPerformed(target, true, null);
                    } else {
                        SelectableBean<UserType> rowDto = getRowModel().getObject();
                        updateActivationPerformed(target, true, rowDto.getValue());
                    }
                }
            };
        }

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

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.enableAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    };
    enableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectDisabled);
    menu.add(enableItem);
    ButtonInlineMenuItem disableItem = new ButtonInlineMenuItem(createStringResource("pageUsers.menu.disable")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        updateActivationPerformed(target, false, null);
                    } else {
                        SelectableBean<UserType> rowDto = getRowModel().getObject();
                        updateActivationPerformed(target, false, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public CompositedIconBuilder getIconCompositedBuilder() {
            CompositedIconBuilder builder = getDefaultCompositedIconBuilder(GuiStyleConstants.CLASS_OBJECT_USER_ICON);
            builder.appendLayerIcon(WebComponentUtil.createIconType(GuiStyleConstants.CLASS_BAN), IconCssStyle.BOTTOM_RIGHT_STYLE);
            return builder;
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.disableAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    };
    disableItem.setVisibilityChecker(FocusListInlineMenuHelper::isObjectEnabled);
    menu.add(disableItem);
    menu.add(new ButtonInlineMenuItem(createStringResource("pageUsers.menu.reconcile")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        reconcilePerformed(target, null);
                    } else {
                        SelectableBean<UserType> rowDto = getRowModel().getObject();
                        reconcilePerformed(target, rowDto.getValue());
                    }
                }
            };
        }

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

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.reconcileAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.unlock")) {

        private static final long serialVersionUID = 1L;

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

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    if (getRowModel() == null) {
                        unlockPerformed(target, null);
                    } else {
                        SelectableBean<UserType> rowDto = getRowModel().getObject();
                        unlockPerformed(target, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public IModel<String> getConfirmationMessageModel() {
            String actionName = createStringResource("pageUsers.message.unlockAction").getString();
            return getTable().getConfirmationMessageModel((ColumnMenuAction) getAction(), actionName);
        }
    });
    menu.add(getTable().createDeleteInlineMenu());
    menu.add(new InlineMenuItem(createStringResource("pageUsers.menu.merge")) {

        private static final long serialVersionUID = 1L;

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

                @Override
                public void onClick(AjaxRequestTarget target) {
                    OperationResult result = new OperationResult(OPERATION_LOAD_MERGE_CONFIGURATION);
                    List<MergeConfigurationType> mergeConfiguration;
                    try {
                        mergeConfiguration = getModelInteractionService().getMergeConfiguration(result);
                    } catch (ObjectNotFoundException | SchemaException ex) {
                        LOGGER.error("Couldn't load merge configuration: {}", ex.getLocalizedMessage());
                        result.recomputeStatus();
                        getFeedbackMessages().error(PageUsers.this, ex.getLocalizedMessage());
                        target.add(getFeedbackPanel());
                        return;
                    }
                    if (mergeConfiguration == null || mergeConfiguration.size() == 0) {
                        getFeedbackMessages().warn(PageUsers.this, createStringResource("PageUsers.noMergeConfigurationMessage").getString());
                        target.add(getFeedbackPanel());
                        return;
                    }
                    if (getRowModel() == null) {
                        mergePerformed(target, null);
                    } else {
                        SelectableBean<UserType> rowDto = getRowModel().getObject();
                        mergePerformed(target, rowDto.getValue());
                    }
                }
            };
        }

        @Override
        public boolean isHeaderMenuItem() {
            return false;
        }
    });
    return menu;
}
Also used : IModel(org.apache.wicket.model.IModel) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InlineMenuItemAction(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) 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) ArrayList(java.util.ArrayList) List(java.util.List) ButtonInlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem) FocusListInlineMenuHelper(com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper)

Aggregations

InlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)4 FocusListInlineMenuHelper (com.evolveum.midpoint.web.component.util.FocusListInlineMenuHelper)4 ArrayList (java.util.ArrayList)4 MainObjectListPanel (com.evolveum.midpoint.gui.api.component.MainObjectListPanel)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 ColumnMenuAction (com.evolveum.midpoint.web.component.data.column.ColumnMenuAction)3 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)3 UserProfileStorage (com.evolveum.midpoint.web.session.UserProfileStorage)3 Form (org.apache.wicket.markup.html.form.Form)3 CompositedIconBuilder (com.evolveum.midpoint.gui.impl.component.icon.CompositedIconBuilder)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 ButtonInlineMenuItem (com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem)1 InlineMenuItemAction (com.evolveum.midpoint.web.component.menu.cog.InlineMenuItemAction)1 SelectableBean (com.evolveum.midpoint.web.component.util.SelectableBean)1 List (java.util.List)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)1 IModel (org.apache.wicket.model.IModel)1